Merge pull request #202 from glotzerlab/dependabot-github_actions-tru… #375
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: Unit test | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
# Trigger on pull requests. | |
pull_request: | |
# Trigger on pushes to the mainline branches. This prevents building commits twice when the pull | |
# request source branch is in the same repository. | |
push: | |
branches: | |
- "trunk" | |
# Trigger on request. | |
workflow_dispatch: | |
# Use multiple jobs to reduce the amount of time spent on GPU runners. Use GitHub Hosted runners | |
# for compiling all tests configurations (GPU and CPU), then upload the installation directory | |
# as an artifact. Test jobs depend on the build job, download the install directory, and run the | |
# tests. Upload each build configuration to a separate artifact. | |
# Copy and paste the matrix from `build_linux` to `test_linux`. The list in `test_linux` must be a | |
# subset of the list in `build_linux`. | |
jobs: | |
build_linux: | |
name: Build [${{ matrix.image }}] | |
runs-on: ubuntu-latest | |
container: | |
image: ${{ matrix.repository }}/ci:2023.02-${{ matrix.image }} | |
credentials: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
strategy: | |
matrix: | |
include: | |
- {repository: glotzerlab, image: clang14_py311, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: true } | |
- {repository: glotzerlab, image: clang13_py310, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: clang12_py310, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: clang11_py310, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: clang10_py38, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: clang9_py38, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: clang8_py38, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: clang7_py38, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: clang6_py37, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: gcc12_py311, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: gcc11_py310, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: gcc10_py310, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: gcc9_py39, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: gcc8_py37, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: gcc7_py37, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: joaander, image: optix60_cuda118_py310, test_runner: [self-hosted,GPU,optix], test_docker_options: '-e NVIDIA_DRIVER_CAPABILITIES=compute,graphics --gpus=all', render_gallery: false } | |
steps: | |
- uses: actions/[email protected] | |
with: | |
path: code | |
submodules: true | |
- name: Configure | |
run: | | |
mkdir -p build | |
cd build | |
cmake ../code -GNinja \ | |
-DENABLE_EMBREE=${ENABLE_EMBREE:-"ON"} \ | |
-DENABLE_OPTIX=${ENABLE_OPTIX:-"OFF"} \ | |
-DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install | |
env: | |
ENABLE_OPTIX: ${{ contains(matrix.image, 'optix') }} | |
ENABLE_EMBREE: ${{ !contains(matrix.image, 'optix') }} | |
- name: Build | |
run: ninja install | |
working-directory: build | |
# Tar the installation directory to preserve permissions and reduce HTTP requests on upload. | |
- name: 'Tar install' | |
run: tar --use-compress-program='zstd -10 -T0' -cvf install.tar install | |
# Upload the tarball. Retain the file for a limited time in case developers need to download | |
# and run tests locally for further debugging. | |
- uses: actions/[email protected] | |
name: 'Upload install' | |
with: | |
name: install-${{ matrix.image }}-${{ github.sha }} | |
path: install.tar | |
retention-days: 7 | |
test_linux: | |
needs: build_linux | |
runs-on: ${{ matrix.test_runner }} | |
container: | |
image: ${{ matrix.repository }}/ci:2023.02-${{ matrix.image }} | |
options: ${{ matrix.test_docker_options }} -e CUDA_VISIBLE_DEVICES | |
credentials: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
strategy: | |
matrix: | |
include: | |
- {repository: glotzerlab, image: clang14_py311, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: true } | |
- {repository: glotzerlab, image: clang13_py310, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: clang12_py310, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: clang11_py310, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: clang10_py38, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: clang9_py38, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: clang8_py38, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: clang7_py38, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: clang6_py37, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: gcc12_py311, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: gcc11_py310, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: gcc10_py310, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: gcc9_py39, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: gcc8_py37, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: glotzerlab, image: gcc7_py37, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false } | |
- {repository: joaander, image: optix60_cuda118_py310, test_runner: [self-hosted,GPU,optix], test_docker_options: '-e NVIDIA_DRIVER_CAPABILITIES=compute,graphics --gpus=all', render_gallery: false } | |
steps: | |
- name: Clean workspace | |
run: ( shopt -s dotglob nullglob; rm -rf ./* ) | |
shell: bash | |
- uses: actions/[email protected] | |
with: | |
name: install-${{ matrix.image }}-${{ github.sha }} | |
- name: Untar install | |
run: tar --use-compress-program='zstd -10 -T0' -xvf install.tar | |
- name: Run tests | |
run: python3 -m pytest --pyargs fresnel -v --log-level=DEBUG --durations=0 --durations-min=0.1 | |
env: | |
PYTHONPATH: ${{ github.workspace }}/install | |
- uses: actions/[email protected] | |
if: ${{ matrix.render_gallery }} | |
with: | |
submodules: true | |
path: code | |
- name: Render gallery images | |
if: ${{ matrix.render_gallery }} | |
run: for i in *.py; do echo "Rendering $i" && python3 $i || exit 1; done | |
working-directory: code/doc/gallery | |
env: | |
PYTHONPATH: ${{ github.workspace }}/install | |
- name: Clean workspace | |
run: ( shopt -s dotglob nullglob; rm -rf ./* ) | |
shell: bash | |
- name: Clean HOME | |
run: ( shopt -s dotglob nullglob; rm -rf $HOME/* ) | |
shell: bash | |
build_test_windows: | |
name: Build and test on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- {os: windows-2019, cmake_generator: "Visual Studio 16 2019"} | |
- {os: windows-2022, cmake_generator: "Visual Studio 17 2022"} | |
steps: | |
- uses: actions/[email protected] | |
with: | |
path: code | |
submodules: true | |
# setup-miniconda doesn't understand .conda format packages and removes them | |
# - name: Cache conda packages | |
# uses: actions/[email protected] | |
# with: | |
# path: ~/conda_pkgs_dir | |
# key: | |
# ${{ matrix.os }}-${{ hashFiles('code/.github/workflows/environments/conda.yml') }} | |
- name: Create conda environment | |
uses: conda-incubator/[email protected] | |
with: | |
environment-file: code/.github/workflows/environments/conda.yml | |
activate-environment: ${{ github.workspace }}/env | |
python-version: 3.11 | |
miniforge-variant: Mambaforge | |
miniforge-version: "latest" | |
use-mamba: true | |
env: | |
CONDA: ${{ github.workspace }}\miniconda | |
- name: Add environment to system path | |
# these are all needed because miniconda installs libraries to a variety of paths | |
run: | | |
echo "$env:GITHUB_WORKSPACE\env" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
echo "$env:GITHUB_WORKSPACE\env\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
echo "$env:GITHUB_WORKSPACE\env\Scripts" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
echo "$env:GITHUB_WORKSPACE\env\Library\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
- name: Configure | |
run: > | |
cmake -S code -B build | |
-DENABLE_EMBREE=ON | |
-DENABLE_OPTIX=OFF | |
-DPYTHON_EXECUTABLE="$env:GITHUB_WORKSPACE"\env\python.exe | |
-DCMAKE_INSTALL_PREFIX="$env:GITHUB_WORKSPACE"\install | |
-G "${{ matrix.cmake_generator }}" | |
env: | |
CMAKE_PREFIX_PATH: ${{ github.workspace }}\env | |
- name: Build | |
run: cmake --build build --config Release -j | |
- name: Install | |
run: cmake --install build --config Release | |
- name: Run tests | |
run: python -m pytest --pyargs fresnel -v --log-level=DEBUG --durations=0 --durations-min=0.1 | |
env: | |
PYTHONPATH: ${{ github.workspace }}\install | |
# This job is used to provide a single requirement for branch merge conditions. | |
tests_complete: | |
name: Unit test | |
needs: [build_linux, test_linux, build_test_windows] | |
runs-on: ubuntu-latest | |
steps: | |
- run: echo "Done!" |