-
Notifications
You must be signed in to change notification settings - Fork 15
156 lines (129 loc) · 5.15 KB
/
ci.yml
File metadata and controls
156 lines (129 loc) · 5.15 KB
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
150
151
152
153
154
name: CI
on:
workflow_dispatch: # Manually trigger a workflow run using the GitHub API, GitHub CLI, or the GitHub UI.
push:
pull_request:
release:
types: [published]
jobs:
Validate-CITATION-cff:
runs-on: ubuntu-latest
name: Validate CITATION.cff
steps:
- name: Checkout Repository
uses: actions/checkout@v5
- name: Validate CITATION.cff
id: validate_cff
uses: dieghernan/cff-validator@v4
with:
citation-path: "CITATION.cff"
- name: Upload cff-validator error artifact if failed to validate
uses: actions/upload-artifact@v4
if: ${{ failure() && steps.validate_cff.conclusion == 'failure' }}
with:
name: citation-cff-errors
path: citation_cff.md
overwrite: true
if-no-files-found: warn
checks:
name: checks
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
id: python-setup
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v7
id: setup-uv
with:
# Install a specific version of uv.
version: "0.9.6"
enable-cache: true
restore-cache: true
save-cache: true
prune-cache: true
cache-dependency-glob: "uv.lock"
- name: Install the project
run: uv sync --locked
- name: check uv cache is working
if: steps.setup-uv.outputs.cache-hit == 'true'
run: echo "uv cache was restored"
- name: isort
run: uv run isort --check-only pymusas tests scripts
- name: flake8 Ubuntu and Mac
if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }}
run: |
uv run flake8 --config ./.flake8 pymusas tests scripts
- name: flake8 Window
if: ${{ runner.os == 'Windows' }}
run: |
uv run flake8 --config .\.flake8 pymusas tests scripts
- name: Cache mypy
uses: actions/cache@v4
with:
path: ./.mypy_cache
key: ${{ runner.os }}-${{ steps.python-setup.outputs.python-version }}-${{ hashFiles('uv.lock') }}
- name: mypy
run: uv run mypy
- name: Code coverage testing
run: |
uv run coverage run
- name: Code coverage report
run: |
uv run coverage report
- name: Set pymusas cache home directory for Ubuntu and Mac
if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }}
run: |
echo "PYMUSAS_HOME=$HOME/.cache/doc_test_pymusas" >> "$GITHUB_ENV"
- name: Set pymusas cache home directory for Windows
if: ${{ runner.os == 'Windows' }}
run: |
echo "PYMUSAS_HOME=$HOME\.cache\doc_test_pymusas" >> $env:GITHUB_ENV
- name: Cache Doc Test download files
uses: actions/cache@v4
with:
path: ${{ env.PYMUSAS_HOME }}
key: ${{ runner.os }}-${{ steps.python-setup.outputs.python-version }}-${{ env.PYMUSAS_HOME }}
- name: Doc Tests
run: |
uv run coverage run -m pytest --doctest-modules pymusas/
- name: Build and Functional Tests Ubuntu and Mac
if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }}
run: |
uv build
PYMUSAS_VERSION=$(uv run scripts/get_version.py ./pyproject.toml)
uv run --with "dist/pymusas-${PYMUSAS_VERSION}-py3-none-any.whl" \
--with pytest --no-project --isolated pytest --doctest-modules pymusas/
uv run --with "dist/pymusas-${PYMUSAS_VERSION}-py3-none-any.whl" \
--with pytest --no-project --isolated pytest tests/functional_tests
- name: Build and Functional Tests Windows
if: ${{ runner.os == 'Windows' }}
run: |
uv build
$PYMUSAS_VERSION = & { uv run scripts/get_version.py ./pyproject.toml }
uv run --with "dist/pymusas-${PYMUSAS_VERSION}-py3-none-any.whl" --with pytest --no-project --isolated pytest --doctest-modules pymusas/
uv run --with "dist/pymusas-${PYMUSAS_VERSION}-py3-none-any.whl" --with pytest --no-project --isolated pytest tests/functional_tests
update-binder-requirements:
name: update-binder-requirements
needs: checks
if: github.ref == 'refs/heads/main' && github.repository == 'UCREL/pymusas'
runs-on: ubuntu-latest
steps:
- name: update env checkout
uses: actions/checkout@v5
- name: update env commits
run: |
git branch
git fetch --depth=1 origin binder-main
git checkout -b binder-main origin/binder-main
git checkout main binder/environment.yml
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
if [ $(git diff-index binder-main | wc -l) -gt 0 ]; then git commit -m "update"; git push origin binder-main; fi