CI: Fix cmd syntax in win tests #219
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: basictest_win | |
on: | |
push: | |
pull_request: | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [windows-2019, windows-2022] | |
#windows-latest is windows-2022 (Nov 2024) | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
path: src | |
- name: Setup python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
- name: Monolithic pip install of repo | |
shell: cmd | |
run: python3 -m pip install .\src\ | |
- name: pip install extra deps | |
shell: cmd | |
run: | | |
python -mpip install numpy matplotlib gemmi spglib ase mpmath | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
python -c "import numpy; print('numpy imported ok')" | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
python -c "import gemmi; print('gemmi imported ok')" | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
python -c "import spglib; print('spglib imported ok')" | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
python -c "import ase; print('ase imported ok')" | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
python -c "import mpmath; print('mpmath imported ok')" | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
python -c "import matplotlib.pyplot; print('matplotlib imported ok')" | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
- name: Various commandline tests | |
shell: cmd | |
run: | | |
ncrystal-config --summary | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
ncrystal-config --help | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
python3 -c "import NCrystal; NCrystal.test()" | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
python3 -c "import NCrystal as n; mat=n.load('Al_sg225.ncmat;temp=350K'); mat.dump()" | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
nctool --test | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
nctool --dump Al_sg225.ncmat | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
python3 -mNCrystal nctool --test | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
python3 ./src/examples/ncrystal_example_py | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
ncrystal_vdos2ncmat --help | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
ncrystal_cif2ncmat --help | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
ncrystal_ncmat2cpp --help | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
ncrystal_hfg2ncmat --help | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
ncrystal_verifyatompos --help | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
ncrystal_cif2ncmat codid::9008460 | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
ncrystal_ncmat2hkl --help | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
ncrystal_ncmat2hkl --format=laz "Al_sg225.ncmat;temp=250K;dcutoff=0.75" -o test_Al.laz | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
ncrystal_ncmat2hkl --format=lau "Al_sg225.ncmat;temp=250K;dcutoff=0.75" -o test_Al.lau | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
nctool -d ./test_Al.laz | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
nctool -d ./test_Al.lau | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
ncrystal_ncmat2cpp stdlib::Al_sg225.ncmat -o test.cpp | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
cat test.cpp | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
nctool --pdf Al_sg225.ncmat | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
#Two ways of enabling cl.exe and other tools. One is via an external action...: | |
- name: Setup VS in shell | |
uses: ilammy/msvc-dev-cmd@v1 | |
#...but a simpler one might be to simply invoke the correct vcvars64.bat | |
#file first, like...: | |
# | |
# - name: whatever | |
# shell: cmd | |
# run: | | |
# call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" | |
# cl /help | |
# | |
#...but since we also want to support VS 2019, we use the above action for now | |
- name: Use cl.exe | |
shell: cmd | |
run: | | |
cl /help | |
- name: Test downstream compilation and build flags | |
shell: cmd | |
run: | | |
cl /help | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
echo "Set BUILDFLAGS variable" | |
ncrystal-config --show buildflags > buildflags.txt | |
set /p BUILDFLAGS=<buildflags.txt | |
echo "Got:" %BUILDFLAGS% | |
@REM Examples from README: | |
copy .\src\examples\ncrystal_example_cpp.cc my_cpp_code.cpp | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
copy .\src\examples\ncrystal_example_c.c my_c_code.c | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
dir | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
ncrystal-config --show buildflags | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
@REM cl %BUILDFLAGS% my_c_code.c | |
cl my_c_code.c %BUILDFLAGS% | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
echo "Custom compilation of downstream C/C++ code succeeded" | |