-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (122 loc) · 4.46 KB
/
ci.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
name: CI
on:
# Can run on command
workflow_dispatch:
# Can be run by other actions
workflow_call:
# Runs on pull requests
pull_request:
branches: [master]
jobs:
build:
name: build-and-test
# Running on ubuntu-latest, nothing special
runs-on: ubuntu-latest
steps:
# As usual, we simply checkout the project
- name: Checkout
uses: actions/checkout@v4
# Setup the latest version of Bun
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
# Install project dependencies
- name: Install dependencies
run: bun install --frozen-lockfile
# Make sure the application can build
- name: Build application
run: bun run build
# Now we run our tests
- name: Run tests
run: bun run test
# Now we run our lints
- name: Run lints
run: bun run lint
# Now we run our pretty checks for code formatting
- name: Run pretty checks
run: bun run pretty-check
# Finally we run svelte-check for some last minute svelte sanity
- name: Run svelte-check
run: bun run svelte-check
- name: Jest Coverage Comment
# This comments the current Jest Coverage Report containing JUnit XML reports
# and a Code Coverage Summary
uses: MishaKav/jest-coverage-comment@434e6d2d37116d23d812809b61d499639842fa3b # v1.0.26
with:
title: "Unit Test Coverage Report"
junitxml-path: ./test-results.xml
junitxml-title: Unit Test Report
test:
# Runs on execution of build
needs: build
name: playwright-test
# Running on ubuntu-latest, nothing special
runs-on: ubuntu-latest
steps:
# As usual, we simply checkout the project
- name: Checkout
uses: actions/checkout@v4
# Setup the latest version of Bun
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
# Install project dependencies
- name: Install dependencies
run: bun install --frozen-lockfile
# Install Playwright browsers
- name: Install Playwright Browsers
run: bunx playwright install --with-deps
# Run Playwright tests
- name: Run tests
run: bun run test:playwright
analyze:
# Runs on successful playwright
needs: [build, test]
name: lighthouse-test
# Running on ubuntu-latest, nothing special
runs-on: ubuntu-latest
steps:
# As usual, we simply checkout the project
- name: Checkout
uses: actions/checkout@v4
# Setup the latest version of Bun
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
# Install project dependencies
- name: Install dependencies
run: bun install --frozen-lockfile
# Install Playwright browsers
- name: Install Playwright Browsers
run: bunx playwright install --with-deps
# Run Lighthouse Playwright tests
- name: Run Playwright tests
run: bun run test:lighthouse
- name: Read JSON and set output
id: json-reader
run: |
categories=$(jq -c '.categories' ./lighthouse-reports/lighthouse.json)
echo "::set-output name=json::$categories"
- name: Format Lighthouse Score
# Transform the audit results into a single, friendlier output
id: format-lighthouse-score
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
env:
# using env as input to our script
# see https://github.com/actions/github-script#use-env-as-input
LIGHTHOUSE_RESULT: ${{ steps.json-reader.outputs.json }}
with:
# Run as a separate file so we do not have to inline all of our formatting logic.
# See https://github.com/actions/github-script#run-a-separate-file for more info.
script: |
const { formatLighthouseResults } = await import('${{github.workspace}}/scripts/lighthouse/index.js')
await formatLighthouseResults({core})
- name: Add Comment to PR
if: ${{ github.event_name == 'pull_request' && github.base_ref != 'master' }}
# Replace the previous message with our formatted lighthouse results
uses: thollander/actions-comment-pull-request@d61db783da9abefc3437960d0cce08552c7c004f # v2.4.2
with:
# Reference the previously created comment
comment_tag: "lighthouse-audit"
message: |
${{ steps.format-lighthouse-score.outputs.comment }}