1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
|
name: Quick checks
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main
# For a PR #7488 against main branch, the `group` will become: CI-{{ 7488 || github.sha }}
# which eventually evaluates to: CI-7488 and 'sha' isn't used.
# NOTE: `||` acts as a logical OR and a default operator both,
# see: https://docs.github.com/en/actions/learn-github-actions/expressions#operators.
# When it isn't a PR against main but instead a commit pushed (or merged) to main, then `group` will
# evaluate to `${{ github.sha }}` but "cancel-in-progress" evaluates to false, so the CI on main
# will run in a new group `${{ github.sha }}`, but no previous CI will be cancelled on main
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
MACOSX_DEPLOYMENT_TARGET: 15.0
jobs:
Build:
name: LFortran CI (OS=${{ matrix.os }}, LLVM=${{ matrix.llvm-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
llvm-version: "11"
- os: macos-latest
llvm-version: "21"
- os: ubuntu-latest
llvm-version: "11"
- os: ubuntu-latest
llvm-version: "21"
- os: windows-2025
llvm-version: "11"
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: mamba-org/setup-micromamba@v2.0.2
with:
micromamba-version: '2.0.4-0'
environment-file: ci/environment.yml
create-args: >-
llvmdev=${{ matrix.llvm-version }}
- name: Install Windows Packages
if: contains(matrix.os, 'windows')
shell: bash -e -l {0}
run: |
micromamba install m2-bison=3.0.4 m2-filesystem cmake=3.21.1 zstd-static=1.5.5 zlib=1.2.13
- name: Install Linux / macOS Packages
if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos')
shell: bash -e -l {0}
run: |
micromamba install bison=3.4 openblas=0.3.21 llvm-openmp=14.0.4 zlib=1.3.1 llvmdev=${{ matrix.llvm-version }}
if [[ "${{ matrix.os }}" == *ubuntu* ]]; then
micromamba install openmpi=5.0.6=hb85ec53_102
elif [[ "${{ matrix.os }}" == *macos* ]]; then
micromamba install openmpi=5.0.6=h31ce4ef_102
fi
if [[ "${{ matrix.llvm-version }}" == "11" ]]; then
micromamba install zstd-static=1.5.6 nodejs=18.20.4 kokkos=4.4.01
elif [[ "${{ matrix.llvm-version }}" == "21" ]]; then
micromamba install zstd-static=1.5.7
fi
if [[ "${{ matrix.os }}" == *ubuntu* && "${{ matrix.llvm-version }}" != "11" ]]; then
micromamba install libunwind=1.7.2
fi
if [[ "${{ matrix.os }}" == *ubuntu* && "${{ matrix.llvm-version }}" == "11" ]]; then
micromamba install pandoc=3.1.13
fi
- uses: hendrikmuhs/ccache-action@main
with:
key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.llvm-version }}
- name: Setup Platform
shell: bash -e -l {0}
run: |
echo "LFORTRAN_CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV
echo "CMAKE_C_COMPILER_LAUNCHER=ccache" >> $GITHUB_ENV
echo "CMAKE_CXX_COMPILER_LAUNCHER=ccache" >> $GITHUB_ENV
echo "ENABLE_RUNTIME_STACKTRACE=yes" >> $GITHUB_ENV
# we need to run this only once for debugging purpose
- name: Print github concurrent group name
shell: bash -e -l {0}
if: contains(matrix.os, 'ubuntu') && contains(matrix.llvm-version, '21')
run: |
echo "Concurrency Group: ${{ github.workflow }}-${{ github.event.number || github.sha }}"
echo "Cancel-in-progress: ${{ github.event_name == 'pull_request' }}"
- name: Build (Linux / macOS)
shell: bash -e -l {0}
if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos')
run: |
export CXXFLAGS="-Werror -D_GLIBCXX_ASSERTIONS -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG"
export CFLAGS="-Werror -D_GLIBCXX_ASSERTIONS -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG"
export WIN=0
shell ci/build.sh
- name: Build (Windows)
if: contains(matrix.os, 'windows')
shell: cmd
run: |
set MAMBA_INSTALL_LOCN=C:\\Users\runneradmin\micromamba
call %MAMBA_INSTALL_LOCN%\Scripts\activate.bat
call micromamba activate lf
set LFORTRAN_CMAKE_GENERATOR=Ninja
set WIN=1
set MACOS=0
set ENABLE_RUNTIME_STACKTRACE=no
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
set CC=cl.exe
set CXX=cl.exe
set "PATH=%PATH:C:\mingw64\bin;=%"
shell ci\build.sh
- name: Test (Linux / macOS)
shell: bash -e -l {0}
if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos')
run: |
case "$OSTYPE" in darwin*) export MACOS=1;; *) export MACOS=0;; esac
export LFORTRAN_LLVM_VERSION=${{ matrix.llvm-version }}
export LFORTRAN_TEST_ENV_VAR='STATUS OK!'
shell ci/test.sh
- name: Test LFortran's Command Line Interface (Linux / macOS)
shell: bash -e -l {0}
if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos')
run: |
./test_lfortran_cmdline
- name: Test with specific Fortran standard
shell: bash -e -l {0}
if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos')
run: |
cd ./integration_tests
./run_tests.py -b llvm --std=f23
./run_tests.py -b llvm -f --std=f23 -nf16
- name: Test (Windows)
if: contains(matrix.os, 'windows')
shell: cmd
run: |
set MAMBA_INSTALL_LOCN=C:\\Users\runneradmin\micromamba
call %MAMBA_INSTALL_LOCN%\Scripts\activate.bat
call micromamba activate lf
set LFORTRAN_CMAKE_GENERATOR=Ninja
set WIN=1
set MACOS=0
set ENABLE_RUNTIME_STACKTRACE=no
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
set CC=cl.exe
set CXX=cl.exe
set "PATH=%PATH:C:\mingw64\bin;=%"
shell ci\test.sh
- name: Install Timeout (macOS)
shell: bash -e -l {0}
if: contains(matrix.os, 'macos')
run: brew install coreutils
# ~/.bash_logout wanted to run `/usr/bin/clear_console -q` while exiting
# login shells which frequently erred on ubuntu-latest since the shell was
# not run interactively.
- name: Disable ~/.bash_logout (Linux)
shell: bash -e {0}
if: contains(matrix.os, 'ubuntu') && contains(matrix.llvm-version, '11')
run: mv -v ~/.bash_logout ~/.bash_logout.bak
- name: LSP Test (Linux / macOS)
shell: bash -e -l {0}
if: (contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos')) && contains(matrix.llvm-version, '11')
timeout-minutes: 5
env:
EXIT_SUCCESS: 0
EXIT_TIMEOUT: 124
EXIT_KILL: 137
MAX_ATTEMPTS: 3
SIGTERM_TIMEOUT: 60s
SIGKILL_TIMEOUT: 10s
PYTEST_TIMEOUT: 10
run: |
set -ex
pip install src/server/tests tests/server
timeout -k $SIGKILL_TIMEOUT $SIGTERM_TIMEOUT \
pytest -vv \
--showlocals \
--timeout=$PYTEST_TIMEOUT \
--execution-strategy="concurrent" \
tests/server
set +e
for (( ATTEMPT = 1; ATTEMPT <= MAX_ATTEMPTS; ATTEMPT++ )); do
echo "Attempt $ATTEMPT of $MAX_ATTEMPTS"
timeout -k $SIGKILL_TIMEOUT $SIGTERM_TIMEOUT \
pytest -vv \
--showlocals \
--timeout=$PYTEST_TIMEOUT \
--execution-strategy="parallel" \
tests/server
EXIT_CODE=$?
if [ $EXIT_CODE -eq $EXIT_SUCCESS ]; then
break
fi
echo "Command failed with exit code: $EXIT_CODE" 1>&2
done
set -e
exit $EXIT_CODE
- name: Test GFortran, Debug Build, Fortran, OpenMP, C/C++ backend, Upload Tarball, CPP Build, WASM - Test integration_tests with GFortran
shell: bash -e -l {0}
if: contains(matrix.os, 'ubuntu') && contains(matrix.llvm-version, '11')
run: |
cd integration_tests
./run_tests.py -b gfortran
- name: Test GFortran, Debug Build, Fortran, OpenMP, C/C++ backend, Upload Tarball, CPP Build, WASM - Test Debug Build Linux
shell: bash -e -l {0}
if: contains(matrix.os, 'ubuntu') && contains(matrix.llvm-version, '11')
run: |
ctest
./run_tests.py
./run_tests.py -vh
cd integration_tests
./run_tests.py -m
./run_tests.py -b llvm
./run_tests.py -b llvm -f -nf16
./run_tests.py -b llvm_single_invocation
- name: Test GFortran, Debug Build, Fortran, OpenMP, C/C++ backend, Upload Tarball, CPP Build, WASM - Test OpenMP
shell: bash -e -l {0}
if: contains(matrix.os, 'ubuntu') && contains(matrix.llvm-version, '11')
run: |
cd integration_tests
./run_tests.py -b llvm_omp
- name: Test GFortran, Debug Build, Fortran, OpenMP, C/C++ backend, Upload Tarball, CPP Build, WASM - Test Target Offload
shell: bash -e -l {0}
if: contains(matrix.os, 'ubuntu') && contains(matrix.llvm-version, '11')
run: |
cd integration_tests
./run_tests.py -b target_offload
- name: Test GFortran, Debug Build, Fortran, OpenMP, C/C++ backend, Upload Tarball, CPP Build, WASM - Test Fortran Backend
shell: bash -e -l {0}
if: contains(matrix.os, 'ubuntu') && contains(matrix.llvm-version, '11')
run: |
cd integration_tests
./run_tests.py -b fortran -j1
./run_tests.py -b fortran -f -j1
- name: Test GFortran, Debug Build, Fortran, OpenMP, C/C++ backend, Upload Tarball, CPP Build, WASM - Test C/C++ Backend
shell: bash -e -l {0}
if: contains(matrix.os, 'ubuntu') && contains(matrix.llvm-version, '11')
run: |
mkdir build-kokkos
cd build-kokkos
wget https://github.com/kokkos/kokkos/archive/3.1.01.tar.gz
tar xaf 3.1.01.tar.gz
cd kokkos-3.1.01
mkdir build
cd build
export LFORTRAN_KOKKOS_DIR=$HOME/ext/kokkos
cmake -DCMAKE_INSTALL_PREFIX=$LFORTRAN_KOKKOS_DIR -DKokkos_ENABLE_OPENMP=On -DKokkos_ARCH_HSW=On ..
make
make install
cd ../../..
cd integration_tests
./run_tests.py -b cpp c c_nopragma
./run_tests.py -b cpp c c_nopragma -f
- name: Test GFortran, Debug Build, Fortran, OpenMP, C/C++ backend, Upload Tarball, CPP Build, WASM - Test CPP
shell: bash -e -l {0}
if: contains(matrix.os, 'ubuntu') && contains(matrix.llvm-version, '11')
run: |
shell ci/test_cpp_version.sh
- name: Test GFortran, Debug Build, Fortran, OpenMP, C/C++ backend, Upload Tarball, CPP Build, WASM - Show Node Info
shell: bash -e -l {0}
if: contains(matrix.os, 'ubuntu') && contains(matrix.llvm-version, '11')
run: |
set -ex
which node
node --version
- name: Test GFortran, Debug Build, Fortran, OpenMP, C/C++ backend, Upload Tarball, CPP Build, WASM - Test WASM backend
shell: bash -e -l {0}
if: contains(matrix.os, 'ubuntu') && contains(matrix.llvm-version, '11')
run: |
cd integration_tests
./run_tests.py -b wasm
./run_tests.py -b wasm -f
- name: Check Bison Grammar for Essential Conflicts
if: contains(matrix.os, 'ubuntu') && contains(matrix.llvm-version, '21')
shell: bash -e -l {0}
run: |
./ci/grammar_conflicts.sh
# Run last. Script checks out to first commit in PR history
- name: Check for Added Binary Files
shell: bash -e -l {0}
if: contains(matrix.os, 'ubuntu') && contains(matrix.llvm-version, '21')
run: |
python3 check_binary_file_in_git_history.py
build_to_wasm_and_upload:
name: Build LFortran to WASM and Upload
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: mamba-org/setup-micromamba@v2.0.2
with:
micromamba-version: '2.0.4-0'
environment-file: ci/environment_linux.yml
create-args: >-
python=3.10
- uses: hendrikmuhs/ccache-action@main
with:
variant: sccache
key: ${{ github.job }}-${{ matrix.os }}
- name : Remove existing node
shell: bash -e -l {0}
run : |
which node
node -v
sudo rm -rf /usr/local/bin/node /usr/local/bin/npm
- name: Setup Emscripten SDK
shell: bash -l {0}
run: |
set -ex
mkdir -p $HOME/ext
cd $HOME/ext
curl -o emsdk.tar.gz -L https://github.com/emscripten-core/emsdk/archive/refs/tags/4.0.13.tar.gz
tar -xvf emsdk.tar.gz
mv emsdk-4.0.13 emsdk
export EMSDK_PATH=$HOME/ext/emsdk
echo $EMSDK_PATH
cd $EMSDK_PATH
./emsdk install 3.1.35
./emsdk activate 3.1.35
./emsdk install node-18.20.3-64bit
./emsdk activate node-18.20.3-64bit
- name: Show Emscripten and Node Info
shell: bash -l {0}
run: |
set -ex
# Activate PATH and other environment variables in the current terminal
source $HOME/ext/emsdk/emsdk_env.sh
emcc -v
em++ -v
which node
node -v
- name: Build to WASM
shell: bash -l {0}
run: |
set -ex
source $HOME/ext/emsdk/emsdk_env.sh # Activate Emscripten
./build_to_wasm.sh
- name: Test built lfortran.wasm
shell: bash -l {0}
run: |
set -ex
source $HOME/ext/emsdk/emsdk_env.sh # Activate Emscripten
which node
node -v
node src/lfortran/tests/test_lfortran.js
- name: Upload to wasm_builds
shell: bash -l {0}
run: |
ci/upload_lfortran_wasm.sh
env:
SSH_PRIVATE_KEY_WASM_BUILDS: ${{ secrets.SSH_PRIVATE_KEY_WASM_BUILDS }}
|