-
Notifications
You must be signed in to change notification settings - Fork 7
104 lines (90 loc) · 3.59 KB
/
python-pull-request.yml
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
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:
matrix:
python-version: ["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[tests]
else
echo "Installing training from PyPI"
pip install anemoi-training[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[tests]
else
echo "Installing graphs from PyPI"
pip install anemoi-graphs[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[tests]
else
echo "Installing models from PyPI"
pip install anemoi-models[tests]
fi
- name: Run pytest for changed training package
if: steps.changed-packages.outputs.training_changed == 'true'
uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-pytest-pyproject.yml@v2
with:
python-version: ${{ matrix.python-version }}
install-dependencies: false
custom-pytest: pytest training/tests
- name: Run pytest for changed graphs package
if: steps.changed-packages.outputs.graphs_changed == 'true'
uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-pytest-pyproject.yml@v2
with:
python-version: ${{ matrix.python-version }}
install-dependencies: false
custom-pytest: pytest graphs/tests
- name: Run pytest for changed models package
if: steps.changed-packages.outputs.models_changed == 'true'
uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-pytest-pyproject.yml@v2
with:
python-version: ${{ matrix.python-version }}
install-dependencies: false
custom-pytest: pytest models/tests
- name: Run integration tests
if: success()
uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-pytest-pyproject.yml@v2
with:
python-version: ${{ matrix.python-version }}
install-dependencies: false