-
Notifications
You must be signed in to change notification settings - Fork 2
/
action.yml
149 lines (134 loc) · 4.57 KB
/
action.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
name: "OctoPrint E2E Test"
description: "Runs OctoPrint's E2E tests"
inputs:
ref:
description: "OctoPrint ref to check out"
required: false
default: master
octoprint:
description: "OctoPrint dep to install via pip"
required: false
default: "."
deps:
description: "Additional dependencies to install via pip, e.g. plugins"
required: false
default: ""
python:
description: "Python version to use"
required: false
default: "3.12"
suffix:
description: "Suffix to use for the generated artifacts"
required: false
default: ""
server:
description: "URL of existing server to test"
required: false
default: ""
runs:
using: "composite"
steps:
- name: "⬇ Checkout OctoPrint with E2E tests"
uses: actions/checkout@v4
with:
repository: OctoPrint/OctoPrint
ref: ${{ inputs.ref }}
fetch-depth: 0
path: OctoPrint
- name: 🏗 Set up Python ${{ inputs.python }}
if: ${{ !inputs.server }}
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python }}
- name: 🏗 Install OctoPrint
if: ${{ !inputs.server }}
working-directory: ./OctoPrint/
shell: bash
run: |
pip install ${{ inputs.octoprint }}
[ -z "${{ inputs.deps }}" ] || pip install --force-reinstall ${{ inputs.deps }}
- name: 🏗 Create base config for test server
if: ${{ !inputs.server }}
shell: bash
run: |
mkdir e2econfig
cp -r OctoPrint/.github/fixtures/with_acl/* e2econfig
- name: 🏗 Install mfa dummy plugin if available
if: ${{ !inputs.server }}
shell: bash
run: |
mfa_dummy="OctoPrint/.github/fixtures/mfa_dummy"
if [ -d "$mfa_dummy" ]; then
mkdir -p e2econfig/plugins
cp -r "$mfa_dummy" "e2econfig/plugins/mfa_dummy"
echo "TEST_MFA=1" >> $GITHUB_ENV
fi
- name: 🏗 Prepare Playwright env
working-directory: ./OctoPrint/tests/playwright
shell: bash
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
shell: bash
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
shell: bash
run: |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
npx playwright install-deps
- name: 🎭 Start server and run Playwright
if: ${{ !inputs.server }}
working-directory: ./OctoPrint/tests/playwright
shell: bash
run: |
npx playwright test
env:
OCTOPRINT_SERVER_BASE: ${{ github.workspace }}/e2econfig
TEST_MFA: ${{ env.TEST_MFA }}
- name: 🎭 Run Playwright against existing server
if: ${{ inputs.server }}
working-directory: ./OctoPrint/tests/playwright
shell: bash
run: |
npx playwright test
env:
NO_SERVER: true
PLAYWRIGHT_BASEURL: ${{ inputs.server }}
- name: 🔎 Check octoprint.log for errors
if: ${{ inputs.server }} === ""
shell: bash
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${{ inputs.suffix }}
path: ${{ github.workspace }}/OctoPrint/tests/playwright/playwright-report
- name: ⬆ Upload OctoPrint logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: octoprint-logs${{ inputs.suffix }}
path: ${{ github.workspace }}/e2econfig/logs