-
Notifications
You must be signed in to change notification settings - Fork 3
163 lines (139 loc) · 4.91 KB
/
test_against_testrig.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
name: "Test against testrig"
# Needed secrets:
# - DEPLOY_KEY: private ssh key to access fab@flashhost.lan
# - DEPLOY_KNOWN_HOSTS: known hosts including fab@flashhost.lan
# - TAILSCALE_AUTHKEY: reusable, ephemeral, tagged tailscale auth key to access flashhost
# and DUTs
on:
workflow_dispatch:
inputs:
target:
description: "Target DUT to deploy to"
required: true
default: 'pic'
image:
description: "Image to deploy"
required: false
default: '0.18.0-latest'
jobs:
deploy:
name: "🏗 Deploy"
runs-on: ubuntu-latest
outputs:
target: ${{ env.TARGET }}
image: ${{ env.IMAGE }}
steps:
- name: "🧥 Cloak some stuff"
env:
TESTRIG_WIFI_NAME: ${{ secrets.TESTRIG_WIFI_NAME }}
TESTRIG_WIFI_KEY: ${{ secrets.TESTRIG_WIFI_KEY }}
run: |
echo "::add-mask::$TESTRIG_WIFI_NAME"
echo "::add-mask::$TESTRIG_WIFI_KEY"
- name: "🔑 Install SSH key in agent"
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.DEPLOY_KEY }}
known_hosts: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
- name: "🌐 Connect to tailscale network"
uses: tailscale/github-action@v1
with:
authkey: ${{ secrets.TAILSCALE_AUTHKEY }}
- name: ✔ Check if tailscale is running
run: |
tailscale --version
tailscale status
ping -c 3 flashhost
ssh fab@flashhost flashhost_list_images
- name: 🔍 Determine image
run: |
IMAGE=${{ github.event.inputs.image }}
if [[ "$IMAGE" == https://* ]] || [[ $IMAGE == http://* ]]
then
URL="$IMAGE"
IMAGE="github-run-${{ github.run_id }}-${{ github.run_attempt }}"
ssh fab@flashhost flashhost_fetch_image:"$URL",$IMAGE
fi
echo "Image: $IMAGE"
echo "IMAGE=$IMAGE" >> $GITHUB_ENV
- name: "🔥 Flash & provision image"
env:
TARGET: ${{ github.event.inputs.target }}
IMAGE: ${{ env.IMAGE }}
run: |
ssh -o SendEnv=TARGET fab@flashhost flashhost_flash_and_provision:$IMAGE octopi_wait:headless=1
- name: "🐙 Preconfigure OctoPrint"
env:
TARGET: ${{ github.event.inputs.target }}
run: |
ssh -o SendEnv=TARGET fab@flashhost octopi_test_provisioned:headless=1,config=configs/e2e
- name: "🧹 Clean up if needed"
if: always()
run: |
IMAGE="${{ env.IMAGE }}"
if [[ "$IMAGE" == github-run-* ]]
then
ssh fab@flashhost flashhost_remove_image:$IMAGE
fi
e2e:
name: "🧪 E2E"
runs-on: ubuntu-latest
needs: deploy
steps:
- name: "🌐 Connect to tailscale network"
uses: tailscale/github-action@v1
with:
authkey: ${{ secrets.TAILSCALE_AUTHKEY }}
- name: ✔ Check if tailscale is running and make sure DUT is up
run: |
tailscale --version
tailscale status
curl http://flashhost/${{ github.event.inputs.target }}/
- name: "⬇ Checkout maintenance OctoPrint with Playwright E2E tests"
uses: actions/checkout@v3
with:
repository: OctoPrint/OctoPrint
ref: maintenance
path: OctoPrint
- 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@v3
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:
NO_SERVER: true
PLAYWRIGHT_BASEURL: "http://flashhost/${{ github.event.inputs.target }}"
- name: 📷 Check webcam
run: |
curl -i -o webcam.jpg http://flashhost/${{ github.event.inputs.target }}/webcam/?action=snapshot
- name: ⬆ Upload Playwright report
uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: OctoPrint/tests/playwright/playwright-report