-
Notifications
You must be signed in to change notification settings - Fork 13
179 lines (146 loc) · 5.16 KB
/
ci.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
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: CI
on:
workflow_dispatch:
push:
pull_request:
release:
types: [published]
jobs:
Validate-CITATION-cff:
runs-on: ubuntu-latest
name: Validate CITATION.cff
env:
RSPM: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"
steps:
- uses: actions/checkout@v2
- name: Install V8
run: sudo apt-get install -y libv8-dev
- name: cff-validator
uses: dieghernan/cff-validator@main
- name: Upload cff-validator error artifact
uses: actions/[email protected]
if: failure()
with:
name: citation-cff-errors
path: citation_cff_errors.md
checks:
name: checks
runs-on: ${{ matrix.os }}
needs: Validate-CITATION-cff
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Setting Python and OS environment variables on Linux and Mac
if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }}
run: |
echo "PYTHON=${{ matrix.python-version }}" >> $GITHUB_ENV
echo "OS=${{ runner.os }}" >> $GITHUB_ENV
- name: Setting Python and OS environment variables on Windows
if: ${{ runner.os == 'Windows' }}
run: |
echo "PYTHON=${{ matrix.python-version }}" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
echo "OS=${{ runner.os }}" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- name: Python location
run: echo "Python location ${{ env.pythonLocation }}"
- name: Cache pip
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-${{ env.pythonLocation }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/dev_requirements.txt') }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade --upgrade-strategy eager -r requirements.txt -r dev_requirements.txt
- name: isort
run: isort --check-only pymusas tests scripts
- name: flake8
run: |
pip list
flake8
- name: Cache mypy
uses: actions/cache@v2
with:
path: ./.mypy_cache
key: ${{ runner.os }}-${{ env.pythonLocation }}
- name: mypy
run: mypy
- name: Code coverage testing
run: |
coverage run
- name: Code coverage report
run: |
coverage report
coverage xml
- name: CodeCov
uses: codecov/codecov-action@v2
with:
env_vars: OS,PYTHON
fail_ci_if_error: false
- 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" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- name: Cache Doc Test download files
uses: actions/cache@v2
with:
path: ${{ env.PYMUSAS_HOME }}
key: ${{ runner.os }}-${{ env.PYMUSAS_HOME }}
- name: Doc Tests
run: |
coverage run -m pytest --doctest-modules pymusas/
coverage report
update-binder-requirements:
name: update-binder-requirements
needs: checks
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: update env checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: update env commits
run: |
git branch
git checkout 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
publish:
name: Publish to PyPI
needs: checks
runs-on: ubuntu-latest
if: github.repository == 'UCREL/pymusas' && github.event_name == 'release'
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade build twine
- name: Build package
run: |
python -m build
- name: Twine check
run: python -m twine check --strict dist/*
- name: Upload to twine
run: |
python -m twine upload --repository pypi dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}