-
Notifications
You must be signed in to change notification settings - Fork 2
181 lines (163 loc) Β· 5.35 KB
/
build.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
name: Build pipeline
on:
push:
branches:
- master
- devel
release:
types: [released]
jobs:
build:
name: π¨ Build distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: π Set up Python 3.7
uses: actions/setup-python@v5
with:
python-version: 3.7
- name: π Install build dependencies
run: >-
python -m pip install wheel --user
- name: π¨ Build a binary wheel and a source tarball
run: >-
python setup.py sdist bdist_wheel
- name: β¬ Upload build result
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
pre-commit:
name: π§Ή Pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: π Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: π Set up pre-commit
run: |
pip install pre-commit
- name: π Run pre-commit
run: |
pre-commit run --all-files --show-diff-on-failure
e2e:
name: π§ͺ E2E tests
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.7", "3.12"]
steps:
- name: "β¬ Checkout OctoPrint with E2E tests"
uses: actions/checkout@v4
with:
repository: OctoPrint/OctoPrint
path: OctoPrint
- name: β¬ Download build result
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: π Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: π Install OctoPrint
run: |
cd OctoPrint
pip install .
pip install ${{ github.workspace }}/dist/*.whl
- name: π Create base config for test server
run: |
mkdir e2econfig
cp -r OctoPrint/.github/fixtures/with_acl/* e2econfig
- name: π Install dummy mfa plugin
run: |
mkdir -p e2econfig/plugins
cp -r OctoPrint/.github/fixtures/mfa_dummy e2econfig/plugins/mfa_dummy
- name: π Prepare Playwright env
working-directory: ./OctoPrint/tests/playwright
run: |
npm ci
PLAYWRIGHT_VERSION=$(npm ls --json @playwright/test | jq --raw-output '.dependencies["@playwright/test"].version')
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
- name: π§° Cache Playwright browser binaries
uses: actions/cache@v4
id: playwright-cache
with:
path: "~/.cache/ms-playwright"
key: "${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}"
restore-keys: |
${{ runner.os }}-playwright-
- name: π Install Playwright browser binaries & OS dependencies
if: steps.playwright-cache.outputs.cache-hit != 'true'
working-directory: ./OctoPrint/tests/playwright
run: |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
npx playwright install --with-deps
- name: π Install Playwright OS dependencies
if: steps.playwright-cache.outputs.cache-hit == 'true'
working-directory: ./OctoPrint/tests/playwright
run: |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
npx playwright install-deps
- name: π Run Playwright
working-directory: ./OctoPrint/tests/playwright
run: |
npx playwright test
env:
OCTOPRINT_SERVER_BASE: ${{ github.workspace }}/e2econfig
TEST_MFA: true
- name: π Check octoprint.log for errors
run: |
log=${{ github.workspace }}/e2econfig/logs/octoprint.log
if grep "\- ERROR \-" $log; then
echo "::error::Errors were logged to octoprint.log"
grep -Pazo '(?m)^\N+\- ERROR \-\N*\n(^\N*?\n)*?(?=\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3} \- )' $log
exit 1
fi
- name: β¬ Upload Playwright report
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report-py${{ matrix.python }}
path: tests/playwright/playwright-report
- name: β¬ Upload OctoPrint logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: octoprint-logs-py${{ matrix.python }}
path: ${{ github.workspace }}/e2econfig/logs
publish-on-testpypi:
name: π¦ Publish on TestPyPI
if: github.event_name == 'release'
needs:
- build
- pre-commit
- e2e
runs-on: ubuntu-latest
steps:
- name: β¬ Download build result
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: π¦ Publish to index
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository_url: https://test.pypi.org/legacy/
publish-on-pypi:
name: π¦ Publish tagged releases to PyPI
if: github.event_name == 'release'
needs: publish-on-testpypi
runs-on: ubuntu-latest
steps:
- name: β¬ Download build result
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: π¦ Publish to index
uses: pypa/gh-action-pypi-publish@release/v1