-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (80 loc) · 2.8 KB
/
test-and-release.yaml
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
name: Test and Release
on:
push:
workflow_dispatch:
permissions:
contents: write
actions: write
jobs:
main:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "npm"
- name: Install dependencies
run: npm ci --no-audit
- name: Compile TypeScript
run: npx tsc
- name: Check source code with eslint
run: npx eslint ./
- name: Check if source code is properly formatted
run: npx prettier -c ./
- name: Run tests
run: npm test
- name: Ensure it builds
env:
REGISTRY_ENDPOINT: ${{ vars.REGISTRY_ENDPOINT }}
run: |
npm run build
cp -L -r ./static ./build/client
mkdir -p build/client/node_modules/maplibre-gl/dist/
cp node_modules/maplibre-gl/dist/maplibre-gl.css build/client/node_modules/maplibre-gl/dist/
- name: Store Playwright's Version
run: |
PLAYWRIGHT_VERSION=$(npm ls @playwright/test | grep @playwright | sed 's/.*@//')
echo "Playwright's Version: $PLAYWRIGHT_VERSION"
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
- name: Cache Playwright Browsers for Playwright's Version
id: cache-playwright-browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }}
- name: Install Playwright Browsers
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
run: npx playwright install --with-deps
- name: Run end to end tests
env:
VERSION: ${{ env.VERSION }}
REGISTRY_ENDPOINT: ${{ vars.REGISTRY_ENDPOINT }}
# Encoded in QR code
DOMAIN_NAME: hello.nrfcloud.com
run: npm run test:e2e
# This generates a string containing the current date which is used in
# in artifact names to simplify locating and distinguishing them once they have
# been downloaded
- name: Generate date string
id: dateAsString
run: echo "dateAsString=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
- uses: actions/upload-artifact@v4
if: failure()
with:
name: e2e-test-results-${{ env.dateAsString }}-${{ github.sha }}
path: |
test-results
- name: Semantic release
continue-on-error: true
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Trigger deployment workflow
if: github.ref == 'refs/heads/saga'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh workflow run deploy.yaml