Skip to content

ci: Reinstantiate CI files #23

ci: Reinstantiate CI files

ci: Reinstantiate CI files #23

name: Test PR
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- develop
schedule:
- cron: "9 2 * * 0" # at 9:02 on sunday
jobs:
quality:
uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-precommit-run.yml@v2
with:
skip-hooks: "no-commit-to-branch"
checks:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform: ["ubuntu-latest", "macos-latest"]
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install basic dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-md pytest-emoji
- name: Detect changed packages
id: changed-packages
run: |
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
echo "training_changed=$(echo "$CHANGED_FILES" | grep -q '^training/.*\.py$' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
echo "graphs_changed=$(echo "$CHANGED_FILES" | grep -q '^graphs/.*\.py$' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
echo "models_changed=$(echo "$CHANGED_FILES" | grep -q '^models/.*\.py$' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
- name: Install training package
run: |
if [[ ${{ steps.changed-packages.outputs.training_changed }} == 'true' ]]; then
echo "Installing training from local source"
pip install -e ./training[all,tests]
else
echo "Installing training from PyPI"
pip install anemoi-training[all,tests]
fi
- name: Install graphs package
run: |
if [[ ${{ steps.changed-packages.outputs.graphs_changed }} == 'true' ]]; then
echo "Installing graphs from local source"
pip install -e ./graphs[all,tests]
else
echo "Installing graphs from PyPI"
pip install anemoi-graphs[all,tests]
fi
- name: Install models package
run: |
if [[ ${{ steps.changed-packages.outputs.models_changed }} == 'true' ]]; then
echo "Installing models from local source"
pip install -e ./models[all,tests]
else
echo "Installing models from PyPI"
pip install anemoi-models[all,tests]
fi
- name: Run pytest for changed training package
if: steps.changed-packages.outputs.training_changed == 'true'
uses: pavelzw/pytest-action@v2
with:
report-title: "Test report Anemoi Training (python ${{ matrix.python-version }} on ${{ matrix.platform }})"
custom-pytest: cd ./training && ${{ inputs.custom-pytest }}
- name: Run pytest for changed graphs package
if: steps.changed-packages.outputs.graphs_changed == 'true'
uses: pavelzw/pytest-action@v2
with:
report-title: "Test report Anemoi Graphs (python ${{ matrix.python-version }} on ${{ matrix.platform }})"
custom-pytest: cd ./graphs && ${{ inputs.custom-pytest }}
- name: Run pytest for changed models package
if: steps.changed-packages.outputs.models_changed == 'true'
uses: pavelzw/pytest-action@v2
with:
report-title: "Test report Anemoi Models (python ${{ matrix.python-version }} on ${{ matrix.platform }})"
custom-pytest: cd ./models && ${{ inputs.custom-pytest }}
- name: Run integration tests
if: success()
uses: pavelzw/pytest-action@v2
with:
report-title: "Test report Anemoi Core Integration (python ${{ inputs.python-version }} on ${{ matrix.platform }})"
custom-pytest: pytest tests/