-
Notifications
You must be signed in to change notification settings - Fork 16
154 lines (126 loc) · 4.42 KB
/
python-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
# This GitHub Action workflow will
# - Format code using Black
# - Build project with all dependencies
# - Check code with flake8 linter
# - Run tests with pytest
# ubuntu-latest has 7GB RAM and 14GB SSD. macos-latest has 14GB RAM and 14GB SSD. Using macos assuming more RAM -> faster tests -> less timeouts
# Nonetheless, our tests seem to need >10 GB RAM and >16,7 GB SSD Space. Test refactoring needed.
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
name: Build and test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
formatting:
outputs:
new_sha: ${{ steps.sha.outputs.SHA }}
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }} # ${{ github.event.pull_request.head.sha }}
- name: Setup Python 3.8
uses: actions/setup-python@v2
with:
python-version: "3.8"
cache: 'pip'
- name: Setup isort and Black
run: |
python -m pip install --upgrade pip
pip install isort black
- name: Run isort
run: |
isort --profile black .
- name: Run Black formatter
run: |
black .
- name: Commit changes
uses: EndBug/add-and-commit@v8
with:
message: 'Fix styling'
add: '*.py'
- name: Get commit hash
id: sha
run: |
sha_new=$(git rev-parse HEAD)
echo $sha_new
echo "::set-output name=SHA::$sha_new"
build:
if: always()
needs: formatting
runs-on: macos-latest
steps:
- name: Checkout to latest changes
uses: actions/checkout@v3
with:
ref: ${{ needs.formatting.outputs.new_sha }}
fetch-depth: 0
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: "3.8"
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov pytest-github-actions-annotate-failures
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install -e .
- name: Install model dependencies
run: |
python src/medigan/execute_model/install_model_dependencies.py
lint:
needs: build
runs-on: macos-latest
steps:
- name: Checkout to latest changes
uses: actions/checkout@v3
with:
ref: ${{ needs.formatting.outputs.new_sha }}
fetch-depth: 0
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: "3.8"
cache: 'pip'
- name: Install cached dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install flake8
pip install -e .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --max-line-length=88 --extend-ignore=E203,E501
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=88 --extend-ignore=E203,E501 --statistics
test:
needs: build
runs-on: macos-latest #windows-latest
steps:
- name: Checkout to latest changes
uses: actions/checkout@v3
with:
ref: ${{ needs.formatting.outputs.new_sha }}
fetch-depth: 0
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: "3.8"
cache: 'pip'
- name: Install cached dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install pytest pytest-cov pytest-github-actions-annotate-failures
pip install -e .
python src/medigan/execute_model/install_model_dependencies.py
# for windows: pip install -r requirements.txt
# for mac/linux: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with pytest
run: |
pytest tests -W ignore::DeprecationWarning --verbose --failed-first --log-cli-level=INFO #--cov=. --cov-report html #--capture=tee-sys