This repository has been archived by the owner on Oct 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 103
116 lines (112 loc) · 3.48 KB
/
e2e-test.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
name: E2E Playwright tests
env:
LABEL_RUNNING: e2e-running
LABEL_SUCCESS: e2e-passed
LABEL_FAIL: e2e-failed
on:
pull_request:
types: [labeled]
workflow_dispatch:
inputs:
page_url:
description: "Url of the instance you want to check"
required: false
default: "https://shopware-pwa-canary.storefrontcloud.io/"
jobs:
init:
name: Init dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: "16"
- name: Cache node_modules
uses: actions/cache@v2
id: step-cache-node-modules
env:
cache-name: cache-node-modules-test
with:
path: |
node_modules
packages/*/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}
- name: Install dependencies
if: steps.step-cache-node-modules.outputs.cache-hit != 'true'
run: |
yarn --frozen-lockfile
test:
name: Playwright tests
needs: init
if: github.event.label.name == 'e2e-running' || github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: "16"
# Clear labels for e2e results
- name: remove e2e fail label
uses: buildsville/add-remove-label@v1
with:
token: ${{secrets.GITHUB_TOKEN}}
label: ${{ env.LABEL_FAIL }}
type: remove
- name: remove e2e success label
uses: buildsville/add-remove-label@v1
with:
token: ${{secrets.GITHUB_TOKEN}}
label: ${{ env.LABEL_SUCCESS }}
type: remove
- name: Cache node_modules
uses: actions/cache@v2
id: step-cache-node-modules
env:
cache-name: cache-node-modules-test
with:
path: |
node_modules
packages/*/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}
- name: get preview url
id: get-preview-url
uses: patzick/action-get-comment-url@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
platform: StorefrontCloud
- name: Set the env value
id: set-env-value
run: |
echo "BASE_URL=${{ github.event.inputs.page_url || steps.get-preview-url.outputs.comment_url }}" >> $GITHUB_ENV
- name: yarn test theme e2e
run: |
npx playwright install
yarn test:theme
env:
BASE_URL: ${{ github.event.inputs.page_url || steps.get-preview-url.outputs.comment_url }}
# Take care of labels
- name: remove running label
if: failure() || success()
uses: buildsville/add-remove-label@v1
with:
token: ${{secrets.GITHUB_TOKEN}}
label: ${{ env.LABEL_RUNNING }}
type: remove
- name: add fail label if failed
if: failure()
uses: buildsville/add-remove-label@v1
with:
token: ${{secrets.GITHUB_TOKEN}}
label: ${{ env.LABEL_FAIL }}
type: add
- name: add success label if tests passed
if: success()
uses: buildsville/add-remove-label@v1
with:
token: ${{secrets.GITHUB_TOKEN}}
label: ${{ env.LABEL_SUCCESS }}
type: add