-
Notifications
You must be signed in to change notification settings - Fork 1
149 lines (140 loc) · 5.13 KB
/
ci.yaml
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: CI
on:
pull_request:
push:
branches: [main]
tags: ['v*']
jobs:
mypy:
if: ${{ !github.event.pull_request.draft }}
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: mypy
run: make mypy
pre-commit:
if: ${{ !github.event.pull_request.draft }}
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: pre-commit
run: make pre-commit
docs:
if: ${{ !github.event.pull_request.draft }}
runs-on: ubuntu-latest
env:
REF_DATA_ROOT: ${{ github.workspace }}/.esgpull/data
REF_OUTPUT_ROOT: ${{ github.workspace }}/out
REF_DATABASE_URL: "sqlite:///${{ github.workspace }}/.ref/db/ref.db"
steps:
- name: Check out repository
uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: Cache test data
id: cache-test-data
uses: actions/cache@v4
with:
path: .esgpull
key: test-data-${{ hashFiles('scripts/fetch_test_data.py') }}
- if: ${{ steps.cache-test-data.outputs.cache-hit != 'true' }}
run: |
echo "Rerun after cache generation in tests job"
exit 1
- name: docs
run: |
mkdir -p ${{ github.workspace }}/.ref/db
uv run ref datasets ingest --source-type cmip6 .esgpull/data
uv run mkdocs build --strict
tests:
strategy:
fail-fast: false
matrix:
os: [ "ubuntu-latest" ]
python-version: [ "3.10", "3.11", "3.12", "3.13" ]
runs-on: "${{ matrix.os }}"
defaults:
run:
# This might be needed for Windows and doesn't seem to affect unix-based systems
# so we include it. If you have better proof of whether this is needed or not,
# feel free to update.
shell: bash
steps:
- name: Check out repository
uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
python-version: ${{ matrix.python-version }}
# Share a cache of test data across all test jobs
- name: Cache test data
id: cache-test-data
uses: actions/cache@v4
with:
path: .esgpull
key: test-data-${{ hashFiles('scripts/fetch_test_data.py') }}
- name: Install esgpull
run: |
uv run esgpull self install .esgpull || uv run esgpull self choose .esgpull
- if: ${{ steps.cache-test-data.outputs.cache-hit != 'true' }}
name: Fetch the test data
run: |
uv run esgpull config api.index_node esgf-node.llnl.gov
make fetch-test-data
- name: Run tests
run: |
uv run --package ref pytest packages/ref -r a -v --doctest-modules --cov=packages/ref/src --cov-report=term
uv run --package ref-core pytest packages/ref-core -r a -v --doctest-modules --cov=packages/ref-core/src --cov-report=term --cov-append
uv run --package ref-metrics-example pytest packages/ref-metrics-example -r a -v --doctest-modules --cov=packages/ref-metrics-example/src --cov-report=term --cov-append
uv run --package ref-metrics-esmvaltool pytest packages/ref-metrics-esmvaltool -r a -v --doctest-modules --cov=packages/ref-metrics-esmvaltool/src --cov-report=term --cov-append
uv run coverage xml
# Run integration tests (without adding to the coverage)
uv run pytest tests -r a -v
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
imports-without-extras:
strategy:
fail-fast: false
matrix:
os: [ "ubuntu-latest" ]
python-version: [ "3.10", "3.11", "3.12", "3.13" ]
runs-on: "${{ matrix.os }}"
steps:
- name: Check out repository
uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
python-version: ${{ matrix.python-version }}
- name: Check importable without extras
run: uv run --package ref-core python scripts/test-install.py
# Check if a changelog message was added to the PR
# Only runs on pull requests
check-for-changelog:
runs-on: ubuntu-latest
if: github.event.pull_request
steps:
- name: Check out repository
uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: Get all changelog files
id: changed-changelog-files
uses: tj-actions/changed-files@v45
with:
# Avoid using single or double quotes for multiline patterns
files: |
changelog/*.md
- name: Print out the changed files
if: steps.changed-files-specific.outputs.any_changed == 'true'
env:
ALL_CHANGED_FILES: ${{ steps.changed-changelog-files.outputs.all_changed_files }}
run: |
make changelog-draft
- name: Fail if no changelog message is present
if: steps.changed-changelog-files.outputs.any_changed == 'false'
run: |
echo "No changelog present."
exit 1