forked from janus-idp/backstage-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (100 loc) · 3.18 KB
/
pr-playwright.yaml
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
name: Playwright tests
on:
pull_request:
branches: [main]
jobs:
changes:
name: Scan for changes
runs-on: ubuntu-latest
outputs:
plugins: ${{ steps.scan.outputs.plugins }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
node-version: 18
- name: Determine changes
id: scan
env:
HEAD: ${{ github.sha }}
BASE: ${{ github.event.pull_request.base.sha }}
run: |
root=$(pwd)
cd plugins
changed=()
for f in */; do
if git diff --name-only $BASE $HEAD | grep $f -q; then
if [[ ! -L "$f" && -f "$f/package.json" ]]; then
cd $f
if npm run | grep ui-test -q; then
changed+=($f)
fi
cd $root/plugins
fi
fi
done
JSON="[$(echo ${changed[@]} | sed 's/ /,/g')]"
echo "plugins=$(echo $JSON)" >> $GITHUB_OUTPUT
playwright:
name: 'Run Playwright Tests'
needs: changes
if: needs.changes.outputs.plugins != '[]'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
node-version: 18
- name: Install dependencies
run: yarn
- name: Install playwright
run: yarn playwright install --with-deps chromium
- name: Run tests
env:
PLUGINS: ${{ needs.changes.outputs.plugins }}
run: |
root=$(pwd)
cd packages/backend
readarray folders < <(echo $PLUGINS | sed 's/[][]//g' | sed 's/,/ /g')
# enable permission support and RBAC plugins
printf "\npermission:\n enabled: true\n" >> ${root}/app-config.yaml
cd $root/plugins
# Launch suitable plugins with changes
for f in $folders; do
cd $f
echo "Starting $f plugin"
tmpfile=$(mktemp)
# Start the plugin
yarn start >$tmpfile 2>&1 &
for attempt in $(seq 1 45); do
sleep 1
if grep -q "Error:" $tmpfile; then
cat $tmpfile
exit 1
fi
if grep -q "webpack compiled" $tmpfile; then
echo "$f started"
break
fi
if [[ attempt -eq 45 ]]; then
echo "Failed to launch $f"
cat $tmpfile
exit 1
fi
done
# Run UI tests
yarn run ui-test
# Kill the plugin
pid=$(lsof -i :3000 -Fp | grep p | sed s/p//)
kill -9 $pid
echo "$f shut down"
cd $root/plugins
done
- uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4
if: always()
with:
name: playwright-report
path: plugins/*/playwright-report/
retention-days: 1