-
Notifications
You must be signed in to change notification settings - Fork 9
138 lines (111 loc) · 4.11 KB
/
pytest.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
name: Test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: "0 5 * * *"
# Cancel previous runs that have not completed
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
# Location of RCLONE configuration file
RCLONE_CONFIG: ci/rclone.conf
# Path & URL fragments for uploaded historical data & diagnostics
gcs_bucket: gcs:data.transportenergy.org/historical/ci/
gcs_url: https://storage.googleapis.com/data.transportenergy.org/historical/ci/
jobs:
pytest:
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
version:
- { python: "3.8", others: "" }
# Pint 0.24 with numpy 2.0 compatibility is not available for Python 3.9.
# Use earlier numpy to be compatible with pint < 0.24.
- { python: "3.9", others: "'numpy < 2'" }
- { python: "3.10", others: "" }
- { python: "3.11", others: "" }
- { python: "3.12", others: "" }
# TEMPORARY Never run diagnostics
run-diagnostics:
- false
fail-fast: false
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }}-py${{ matrix.version.python }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.version.python }}
cache: pip
cache-dependency-path: "**/pyproject.toml"
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install the Python package and its dependencies
run: pip install .[tests] ${{ matrix.version.others }}
- name: Run pytest
env:
OK_API_KEY: ${{ secrets.OPENKAPSARC_API_KEY }}
run: pytest --color=yes --cov-report=xml --verbose item
- name: Upload test coverage to Codecov.io
uses: codecov/codecov-action@v5
with: { token: "${{ secrets.CODECOV_TOKEN }}" }
diagnostics:
# Temporarily disabled to merge #84
if: false
# True if the event is a pull request and the incoming branch is within the
# transportenergy/database repo (as opposed to a fork). Only under this
# condition is the GCS_SERVICE_ACCOUNT_* secret available.
# if: github.event_name != 'pull_request' || startsWith(github.event.pull_request.head.label, 'transportenergy:')
needs: [pytest]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-python@v5
with: # Should be the same as the latest supported version, above
python-version: "3.12"
cache: pip
cache-dependency-path: "**/pyproject.toml"
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install the Python package and its dependencies
run: pip install .[tests]
- name: Set up Rclone
uses: AnimMouse/setup-rclone@v1
- name: Create diagnostics and upload to Google Cloud Storage
env:
service_account_json: ${{ secrets.GCS_SERVICE_ACCOUNT_1 }}
run: |
echo "$service_account_json" >ci/service-account-key.json
item historical diagnostics output/
rclone --progress copy output ${{ env.gcs_bucket }}${{ github.run_id }}/
- uses: LouisBrunner/checks-action@v2.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Upload historical database & diagnostics
conclusion: success
details_url: ${{ env.gcs_url }}${{ github.run_id }}/index.html
output: |
{"summary": "${{ env.gcs_url }}${{ github.run_id }}/index.html"}
pre-commit:
name: Code quality
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with: { python-version: 3.x }
- name: Force recreation of pre-commit virtual environment for mypy
if: github.event_name == 'schedule' # Comment this line to run on a PR
run: gh cache list -L 999 | cut -f2 | grep pre-commit | xargs -I{} gh cache delete "{}" || true
env: { GH_TOKEN: "${{ github.token }}" }
- uses: pre-commit/action@v3.0.1