-
-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (148 loc) · 5.25 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
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
# this is heavily influenced by
# https://github.com/tomdye/vercel-lighthouse-action
name: CI
on:
pull_request:
branches: [main]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions:
checks: read
contents: read
pull-requests: write
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: restore dependencies
uses: bahmutov/npm-install@v1
- run: npm run lint:all
test:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: restore dependencies
uses: bahmutov/npm-install@v1
- run: npm run test
type_check:
name: type check
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: restore dependencies
uses: bahmutov/npm-install@v1
- run: npm run type-check
lighthouse_desktop:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: restore dependencies
uses: bahmutov/npm-install@v1
- name: awaiting preview url
uses: patrickedqvist/[email protected]
id: vercel_preview_url
with:
token: ${{ secrets.GITHUB_TOKEN }}
max_timeout: 300 # 5min
- name: add comment to PR
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ github.event.pull_request.number }}
header: lighthouse desktop
message: |
🚦 Running Lighthouse audit on desktop...
- name: audit urls using lighthouse emulating desktop
id: lighthouse_audit
uses: treosh/lighthouse-ci-action@v9
with:
urls: |
${{ steps.vercel_preview_url.outputs.url }}
${{ steps.vercel_preview_url.outputs.url }}/about
${{ steps.vercel_preview_url.outputs.url }}/posts
${{ steps.vercel_preview_url.outputs.url }}/posts/post-design-system
${{ steps.vercel_preview_url.outputs.url }}/posts/the-perfect-header-animation
uploadArtifacts: true
temporaryPublicStorage: true
runs: 3
configPath: './.github/lighthouse/desktop.lighthouserc.js'
- name: format lighthouse result
id: lighthouse_result
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
require('./.github/lighthouse/formatLighthouseResult.js')({
core,
type: 'Desktop',
links: ${{ steps.lighthouse_audit.outputs.links }},
manifest: ${{ steps.lighthouse_audit.outputs.manifest }}
})
- name: add lighthouse comment to PR
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ github.event.pull_request.number }}
header: lighthouse desktop
message: |
${{ steps.lighthouse_result.outputs.comment }}
lighthouse_mobile:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: restore dependencies
uses: bahmutov/npm-install@v1
- name: awaiting preview url
uses: patrickedqvist/[email protected]
id: vercel_preview_url
with:
token: ${{ secrets.GITHUB_TOKEN }}
max_timeout: 300 # 5min
- name: add comment to PR
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ github.event.pull_request.number }}
header: lighthouse mobile
message: |
🚦 Running Lighthouse audit on mobile...
- name: audit urls using lighthouse emulating mobile
id: lighthouse_audit
uses: treosh/lighthouse-ci-action@v9
with:
urls: |
${{ steps.vercel_preview_url.outputs.url }}
${{ steps.vercel_preview_url.outputs.url }}/about
${{ steps.vercel_preview_url.outputs.url }}/posts
${{ steps.vercel_preview_url.outputs.url }}/posts/post-design-system
${{ steps.vercel_preview_url.outputs.url }}/posts/the-perfect-header-animation
uploadArtifacts: true
temporaryPublicStorage: true
runs: 3
configPath: './.github/lighthouse/mobile.lighthouserc.js'
- name: format lighthouse result
id: lighthouse_result
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
require('./.github/lighthouse/formatLighthouseResult.js')({
core,
type: 'Mobile',
links: ${{ steps.lighthouse_audit.outputs.links }},
manifest: ${{ steps.lighthouse_audit.outputs.manifest }}
})
- name: add lighthouse comment to PR
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ github.event.pull_request.number }}
header: lighthouse mobile
message: |
${{ steps.lighthouse_result.outputs.comment }}