generated from JacksonBurns/blank-python-project
-
Notifications
You must be signed in to change notification settings - Fork 4
170 lines (157 loc) · 5.29 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
name: Continuous Integration
on:
schedule:
- cron: "0 8 * * 1-5"
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
concurrency:
group: actions-id-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
check-formatting:
name: Check Build and Formatting Errors
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Dependencies
run: |
python -m pip install pycodestyle isort
- name: Check Build
run: |
python -m pip install .
- name: Run pycodestyle
run: |
pycodestyle --statistics --count --max-line-length=150 --show-source --ignore=E203 .
- name: Check Import Ordering Errors
run: |
isort --check-only --verbose .
build-and-test:
needs: check-formatting
continue-on-error: true
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -el {0}
name: ${{ matrix.os }} Python ${{ matrix.python-version }} Subtest
steps:
- uses: actions/checkout@v3
- uses: mamba-org/setup-micromamba@main
with:
environment-name: temp
condarc: |
channels:
- defaults
- conda-forge
channel_priority: flexible
create-args: |
python=${{ matrix.python-version }}
- name: Install Minimal Dependencies
run: |
python -m pip install -e .
python -m pip install coverage pytest
- name: Run Minimal Tests
run: |
coverage run --source=. --omit=astartes/__init__.py,setup.py,test/* -m pytest -v
- name: Install Molecules Dependencies
run: |
python -m pip install -e .[molecules]
- name: Run All Tests
run: |
coverage run --source=. --omit=astartes/__init__.py,setup.py,test/* -m pytest -v
- name: Show Coverage
run: |
coverage report -m
ipynb-ci:
needs: check-formatting
strategy:
fail-fast: false
matrix:
nb-file:
["barrier_prediction_with_RDB7/RDB7_barrier_prediction_example", "train_val_test_split_sklearn_example/train_val_test_split_example", "split_comparisons/split_comparisons", "mlpds_2023_astartes_demonstration/mlpds_2023_demo"]
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
name: Check ${{ matrix.nb-file }} Notebook Execution
steps:
- uses: actions/checkout@v3
- uses: mamba-org/setup-micromamba@main
with:
environment-name: temp
condarc: |
channels:
- defaults
- conda-forge
channel_priority: flexible
create-args: |
python=3.11
- name: Install dependencies
run: |
python -m pip install -e .[molecules,demos]
python -m pip install notebook
- name: Test Execution
run: |
cd examples/$(dirname ${{ matrix.nb-file }})
jupyter nbconvert --to script $(basename ${{ matrix.nb-file }}).ipynb
ipython $(basename ${{ matrix.nb-file }}).py
coverage-check:
if: contains(github.event.pull_request.labels.*.name, 'PR Ready for Review')
needs: [build-and-test, ipynb-ci]
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: "3.10"
- name: Install Dependencies
run: |
python -m pip install -e .[molecules]
python -m pip install coverage
- name: Run Tests
run: |
coverage run --source=. --omit=astartes/__init__.py,setup.py,test/*,astartes/samplers/sampler.py -m unittest discover -v
- name: Show Coverage
run: |
coverage report -m > temp.txt
cat temp.txt
python .github/workflows/coverage_helper.py
echo "COVERAGE_PERCENT=$(cat temp2.txt)" >> $GITHUB_ENV
- name: Request Changes via Review
if: ${{ env.COVERAGE_PERCENT < 90 }}
uses: andrewmusgrave/[email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
event: REQUEST_CHANGES
body: "Increase test coverage from ${{ env.COVERAGE_PERCENT }}% to at least 90% before merging."
- name: Approve PR if Coverage Sufficient
if: ${{ env.COVERAGE_PERCENT > 89 }}
uses: andrewmusgrave/[email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
event: APPROVE
body: "Test coverage meets or exceeds 90% threshold (currently ${{ env.COVERAGE_PERCENT }}%)."
ci-report-status:
name: report CI status
needs: [build-and-test, ipynb-ci]
runs-on: ubuntu-latest
steps:
- run: |
result_1="${{ needs.build-and-test.result }}"
result_2="${{ needs.ipynb-ci.result }}"
if test $result_1 == "success" && test $result_2 == "success"; then
exit 0
else
exit 1
fi