Skip to content

Commit c26c8d3

Browse files
Merge pull request #1040 from martincostello/lighthouse-audit
Add Lighthouse workflow
2 parents bd2af88 + baffce6 commit c26c8d3

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

.github/workflows/lighthouse.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: lighthouse
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
8+
env:
9+
DOTNET_CLI_TELEMETRY_OPTOUT: true
10+
DOTNET_MULTILEVEL_LOOKUP: 0
11+
DOTNET_NOLOGO: true
12+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
13+
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1
14+
NUGET_XMLDOC_MODE: skip
15+
TERM: xterm
16+
17+
jobs:
18+
lighthouse:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
23+
- name: Checkout code
24+
uses: actions/checkout@v3
25+
26+
- name: Setup .NET SDK
27+
uses: actions/setup-dotnet@v2
28+
29+
- name: Start website
30+
shell: pwsh
31+
run: |
32+
Push-Location (Join-Path "src" "Website")
33+
npm ci
34+
npm run build
35+
Pop-Location
36+
Start-Process nohup 'dotnet run --project ./src/Website/Website.csproj --configuration Release'
37+
$StatusCode = 0
38+
$Attempts = 0
39+
While ($Attempts -lt 10) {
40+
$Response = Try {
41+
Invoke-WebRequest "https://localhost:5001" -SkipCertificateCheck
42+
} catch {
43+
$_.Exception.Response
44+
}
45+
$StatusCode = $Response.StatusCode
46+
If ($StatusCode -eq 200) {
47+
break
48+
}
49+
$Attempts++
50+
Start-Sleep -Seconds 5
51+
}
52+
If ($StatusCode -ne 200) {
53+
throw "Failed to successfully connect to website after $Attempts attempts."
54+
}
55+
New-Item -Path ${{ github.workspace }}/artifacts -ItemType Directory | Out-Null
56+
57+
- name: Lighthouse
58+
uses: foo-software/[email protected]
59+
with:
60+
device: 'all'
61+
gitHubAccessToken: ${{ secrets.GITHUB_TOKEN }}
62+
outputDirectory: ${{ github.workspace }}/artifacts
63+
prCommentEnabled: true
64+
urls: 'https://localhost:5001'
65+
wait: true
66+
67+
- name: Publish artifacts
68+
uses: actions/upload-artifact@v3
69+
if: ${{ always() }}
70+
with:
71+
name: lighthouse
72+
path: ${{ github.workspace }}/artifacts

0 commit comments

Comments
 (0)