|
| 1 | +name: Test PR |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize, reopened] |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - develop |
| 9 | + schedule: |
| 10 | + - cron: "9 2 * * 0" # at 9:02 on sunday |
| 11 | + |
| 12 | +jobs: |
| 13 | + quality: |
| 14 | + uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-precommit-run.yml@v2 |
| 15 | + with: |
| 16 | + skip-hooks: "no-commit-to-branch" |
| 17 | + |
| 18 | + checks: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + strategy: |
| 21 | + matrix: |
| 22 | + python-version: ["3.11"] |
| 23 | + |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v3 |
| 26 | + |
| 27 | + - name: Set up Python ${{ matrix.python-version }} |
| 28 | + uses: actions/setup-python@v4 |
| 29 | + with: |
| 30 | + python-version: ${{ matrix.python-version }} |
| 31 | + |
| 32 | + - name: Install basic dependencies |
| 33 | + run: | |
| 34 | + python -m pip install --upgrade pip |
| 35 | + pip install pytest pytest-md pytest-emoji |
| 36 | +
|
| 37 | + - name: Detect changed packages |
| 38 | + id: changed-packages |
| 39 | + run: | |
| 40 | + CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }}) |
| 41 | + echo "training_changed=$(echo "$CHANGED_FILES" | grep -q '^training/.*\.py$' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT |
| 42 | + echo "graphs_changed=$(echo "$CHANGED_FILES" | grep -q '^graphs/.*\.py$' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT |
| 43 | + echo "models_changed=$(echo "$CHANGED_FILES" | grep -q '^models/.*\.py$' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT |
| 44 | +
|
| 45 | + - name: Install training package |
| 46 | + run: | |
| 47 | + if [[ ${{ steps.changed-packages.outputs.training_changed }} == 'true' ]]; then |
| 48 | + echo "Installing training from local source" |
| 49 | + pip install -e ./training[tests] |
| 50 | + else |
| 51 | + echo "Installing training from PyPI" |
| 52 | + pip install anemoi-training[tests] |
| 53 | + fi |
| 54 | +
|
| 55 | + - name: Install graphs package |
| 56 | + run: | |
| 57 | + if [[ ${{ steps.changed-packages.outputs.graphs_changed }} == 'true' ]]; then |
| 58 | + echo "Installing graphs from local source" |
| 59 | + pip install -e ./graphs[tests] |
| 60 | + else |
| 61 | + echo "Installing graphs from PyPI" |
| 62 | + pip install anemoi-graphs[tests] |
| 63 | + fi |
| 64 | +
|
| 65 | + - name: Install models package |
| 66 | + run: | |
| 67 | + if [[ ${{ steps.changed-packages.outputs.models_changed }} == 'true' ]]; then |
| 68 | + echo "Installing models from local source" |
| 69 | + pip install -e ./models[tests] |
| 70 | + else |
| 71 | + echo "Installing models from PyPI" |
| 72 | + pip install anemoi-models[tests] |
| 73 | + fi |
| 74 | +
|
| 75 | + - name: Run pytest for changed training package |
| 76 | + if: steps.changed-packages.outputs.training_changed == 'true' |
| 77 | + uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-pytest-pyproject.yml@v2 |
| 78 | + with: |
| 79 | + python-version: ${{ matrix.python-version }} |
| 80 | + install-dependencies: false |
| 81 | + custom-pytest: pytest training/tests |
| 82 | + |
| 83 | + - name: Run pytest for changed graphs package |
| 84 | + if: steps.changed-packages.outputs.graphs_changed == 'true' |
| 85 | + uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-pytest-pyproject.yml@v2 |
| 86 | + with: |
| 87 | + python-version: ${{ matrix.python-version }} |
| 88 | + install-dependencies: false |
| 89 | + custom-pytest: pytest graphs/tests |
| 90 | + |
| 91 | + - name: Run pytest for changed models package |
| 92 | + if: steps.changed-packages.outputs.models_changed == 'true' |
| 93 | + uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-pytest-pyproject.yml@v2 |
| 94 | + with: |
| 95 | + python-version: ${{ matrix.python-version }} |
| 96 | + install-dependencies: false |
| 97 | + custom-pytest: pytest models/tests |
| 98 | + |
| 99 | + - name: Run integration tests |
| 100 | + if: success() |
| 101 | + uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-pytest-pyproject.yml@v2 |
| 102 | + with: |
| 103 | + python-version: ${{ matrix.python-version }} |
| 104 | + install-dependencies: false |
0 commit comments