Repository navigation
77 lines (67 loc) · 2.35 KB
/
Copy pathtest-code-playwright.yml
File metadata and controls
77 lines (67 loc) · 2.35 KB
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
name: Playwright Test Code
on:
workflow_call:
inputs:
configs-placeholder:
required: false
type: string
package-manager:
required: false
default: 'npm'
type: string
concurrency:
group: callee-playwright-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Setup package manager and install dependencies
id: setup-deps
run: |
if [ "${{ inputs.package-manager }}" = "npm" ]; then
echo "::set-output name=cache-dir::$(npm config get cache)"
npm install
elif [ "${{ inputs.package-manager }}" = "yarn" ]; then
echo "::set-output name=cache-dir::$(yarn cache dir)"
npm install -g yarn
yarn install
elif [ "${{ inputs.package-manager }}" = "pnpm" ]; then
echo "::set-output name=cache-dir::$(npx -q pnpm config get store)"
npm install -g pnpm
pnpm install
else
echo "Unsupported package manager specified. Supported package managers are npm, yarn, and pnpm."
exit 1
fi
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.npm
~/.yarn
~/.pnpm-store
key: ${{ runner.os }}-${{ inputs.package-manager }}-${{ hashFiles('**/lockfiles') }}
restore-keys: |
${{ runner.os }}-${{ inputs.package-manager }}-
- name: Install Playwright Browsers
run: npx ${{ inputs.package-manager }} exec playwright install --with-deps
- name: Build and start server
run: |
npx ${{ inputs.package-manager }} run build
npx ${{ inputs.package-manager }} run start & # This starts the server in the background
sleep 5 # This allows the server some time to start up
- name: Run Playwright tests
run: npx ${{ inputs.package-manager }} exec playwright test
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30