Skip to content

Commit

Permalink
workflows: Add petsc docker workflow test
Browse files Browse the repository at this point in the history
  • Loading branch information
ZoeLeibowitz committed Jun 8, 2024
1 parent f4f3333 commit 38a93db
Showing 1 changed file with 118 additions and 0 deletions.
118 changes: 118 additions & 0 deletions .github/workflows/pytest_petsc_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: CI-petsc

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
branches:
- master
pull_request:
branches:
- master

jobs:
pytest:
name: ${{ matrix.name }}-${{ matrix.set }}
runs-on: "${{ matrix.os }}"

env:
DEVITO_ARCH: "${{ matrix.arch }}"
DEVITO_LANGUAGE: ${{ matrix.language }}
OMP_NUM_THREADS: 2

strategy:
# Prevent all build to stop if a single one fails
fail-fast: false

matrix:
name: [
pytest-docker-py39
]
set: [base, adjoint]
include:
- name: pytest-docker-py39
python-version: '3.9'
os: ubuntu-latest
arch: "gcc"
language: "C"
sympy: "1.12"

- set: base
test-set: 'not adjoint'

- set: adjoint
test-set: 'adjoint'

exclude:
- name: pytest-osx-py312-clang-omp
set: adjoint

steps:
- name: Checkout devito
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
if: "!contains(matrix.name, 'docker')"
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Build docker image
if: contains(matrix.name, 'docker')
run: |
docker build . --file docker/Dockerfile.devito --tag devito_img --build-arg base=zoeleibowitz/zoeleibowitz:petsc6
- name: Set run prefix
run: |
if [[ "${{ matrix.name }}" =~ "docker" ]]; then
echo "RUN_CMD=docker run --rm -t -e CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} --name testrun devito_img" >> $GITHUB_ENV
else
echo "RUN_CMD=" >> $GITHUB_ENV
fi
id: set-run

- name: Install ${{ matrix.arch }} compiler
if: "runner.os == 'linux' && !contains(matrix.name, 'docker') && matrix.arch !='custom' "
run : |
sudo apt-get install -y ${{ matrix.arch }}
- name: Set tests (reduced number for OSX)
run : |
if [ "${{ runner.os }}" == 'macOS' ]; then
echo "TESTS=tests/test_operator.py" >> $GITHUB_ENV
else
echo "TESTS=tests/" >> $GITHUB_ENV
fi
id: set-tests

- name: Set pip flags for latest python (3.12)
run: |
if [ "${{ matrix.python-version }}" == '3.12' ]; then
echo "PIPFLAGS='--break-system-packages'" >> $GITHUB_ENV
fi
- name: Install dependencies
if: "!contains(matrix.name, 'docker')"
run: |
pip install ${{ env.PIPFLAGS }} --upgrade pip
pip install ${{ env.PIPFLAGS }} -e .[tests]
pip install ${{ env.PIPFLAGS }} sympy==${{matrix.sympy}}
- name: Check configuration
run: |
${{ env.RUN_CMD }} python3 -c "from devito import configuration; print(''.join(['%s: %s \n' % (k, v) for (k, v) in configuration.items()]))"
- name: Test with pytest
run: |
${{ env.RUN_CMD }} pytest -k "${{ matrix.test-set }}" -m "not parallel" --cov --cov-config=.coveragerc --cov-report=xml ${{ env.TESTS }} --ignore=tests/test_petsc.py
- name: Upload coverage to Codecov
if: "!contains(matrix.name, 'docker')"
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: ${{ matrix.name }}

0 comments on commit 38a93db

Please sign in to comment.