-
Notifications
You must be signed in to change notification settings - Fork 9
183 lines (181 loc) · 6.58 KB
/
docker-image.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
180
181
182
183
name: Pycroft CI
on:
push:
branches: [ master, develop ]
pull_request:
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# TODO: find a way to shallow clone precisely pr_base..pr_head;
# wee need this context to do an adequate `darker` report.
# as it stands this is wasteful.
# assuming no PR has more than 50 commits.
fetch-depth: 50
- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
- name: "Run pre-commit hooks for HEAD"
uses: pre-commit/[email protected]
if: github.event_name != 'pull_request'
- name: "Run pre-commit hooks for PR range"
uses: pre-commit/[email protected]
with:
extra_args: >
--from-ref=${{ github.event.pull_request.base.sha }}
--to-ref=${{ github.event.pull_request.head.sha }}
if: github.event_name == 'pull_request'
python-lint:
runs-on: ubuntu-latest
steps:
- name: Check out pycroft and submodules
uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
- name: print information about pip cache
run: pip cache info && pip cache list
- name: ensure presence of `wheel`
run: pip install wheel
- name: install pip dependencies
run: pip install -r requirements.txt -r requirements.dev.txt
id: pip-install
# now come the tests
- name: Execute ruff
run: ruff check --format=github .
if: success() || steps.pip-install.conclusion == 'success'
- name: Execute mypy
run: ./scripts/run_mypy.sh
if: success() || steps.pip-install.conclusion == 'success'
# docs stuff
- name: Build sphinx docs
run: make SPHINXOPTS="-EN -w sphinx.log" -C doc html
if: success() || steps.pip-install.conclusion == 'success'
- name: Render sphinx warnings as annotations
run: python ./scripts/render_sphinx_log.py doc/sphinx.log
if: success() || steps.pip-install.conclusion == 'success'
- name: Publish sphinx docs as pages artifact
uses: actions/upload-pages-artifact@v1
with:
path: doc/_build/html
# see https://github.com/actions/deploy-pages#usage
deploy-docs:
if: (github.event_name == 'push') && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master')
# Add a dependency to the build job
needs: python-lint
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment. see
# https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment
# for general information abotu environments.
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy sphinx docs to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
npm-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
- run: npm run build
- name: Check for outdated NPM packages
run: |
(npm outdated --json | tee outdated.json) || [[ $? == 1 ]]
python ./scripts/render_outdated.py outdated.json >> "${GITHUB_STEP_SUMMARY}"
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'true'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
version: v0.10.0
- name: Fix permissions
run: sudo chmod -R a+rw .
- name: print buildx definition
run: docker buildx bake --file docker-compose.prod.yml --print
- name: Build the Docker image
run: docker buildx bake --file docker-compose.prod.yml --load
- name: Login to GitLab Registry
uses: docker/login-action@v1
with:
registry: registry.agdsn.de
username: "github-actions"
password: ${{ secrets.GITLAB_REGISTRY_PASSWORD }}
- name: Tag built image
run: docker tag agdsn/pycroft-prod:latest registry.agdsn.de/agdsn/coreos/pycroft/pycroft:${GITHUB_REF##*/}
- name: Push to GitLab registry
run: docker push registry.agdsn.de/agdsn/coreos/pycroft/pycroft:${GITHUB_REF##*/}
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'true'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
version: v0.10.0
- name: Fix permissions
run: sudo chmod -R a+rw .
- name: print buildx definition
run: docker buildx bake --print
- name: Build
run: docker buildx bake --load
- name: Run test-app entrypoints
run: docker compose -f docker-compose.test.yml run --rm --no-deps test-app
- name: Start
run: docker compose -f docker-compose.test.yml up --wait --wait-timeout=60 test-app
- name: Run webpack
run: docker compose -f docker-compose.test.yml run --rm test-app webpack --mode production
- name: Run tests
run: >
docker compose -f docker-compose.test.yml run --rm test-app
test -m "not legacy"
--junitxml=junit/test-results.xml
--cov=pycroft --cov=web --cov=ldap_sync --cov=hades_logs --cov-append
--cov-report html --cov-report xml
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: always() # always run even if the previous step fails
with:
report_paths: 'junit/test-*.xml'
- name: Publish coverage XML report as markdown comment
uses: irongut/[email protected]
with:
filename: coverage.xml
badge: true
fail_below_min: false
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '60 80'
- name: Add Coverage to PR summary
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
- name: Publish coverage HTML report as artifact
uses: actions/upload-artifact@v3
if: always()
with:
name: coverage
path: htmlcov