This repository was archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
108 lines (85 loc) · 2.79 KB
/
Copy pathtest-and-release.yaml
File metadata and controls
108 lines (85 loc) · 2.79 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
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
name: Test and Release
on: push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
AWS_ROLE: ${{ secrets.AWS_ROLE }}
WEBAPP_STACK_NAME: ${{ secrets.WEBAPP_STACK_NAME }}
permissions:
id-token: write
contents: write
issues: write
jobs:
test-and-release:
runs-on: ubuntu-22.04
environment: production
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
- uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "npm"
- name: Cache AWS CLI (Linux)
id: cache-aws-cli
uses: actions/cache@v4
with:
path: aws/
key: cache-aws-cli
- name: Install AWS
if: steps.cache-aws-cli.outputs.cache-hit != 'true'
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip -q awscliv2.zip
sudo ./aws/install --update
- name: configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.AWS_ROLE }}
role-session-name: web-app-ci
aws-region: ${{ env.AWS_REGION }}
- name: Install dependencies
run: npm ci --no-audit
- name: Get web app configuration
run: node .github/workflows/web-app-config.js >> $GITHUB_ENV
- name: Install playwright
run: npx playwright install
- 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 unit tests
run: npm test
- name: Build
env:
PUBLIC_VERSION: ${{ github.sha }}
run: npm run build
- uses: actions/upload-artifact@v4
if: always()
with:
if-no-files-found: error
name: asset-tracker-cloud-app-aws-${{ github.sha }}
path: build
- name: Run end-to-end tests
run: npm run test:e2e
- name: Cleanup test artifacts
if: ${{ failure() }}
run: |
aws iot delete-thing --thing-name `cat test-session/asset.json | jq -r '.thingName'`
aws iot delete-thing --thing-name `cat test-session/asset-no-gnss.json | jq -r '.thingName'`
- name: Cleanup old assets
run: npx tsx e2e-tests/clean-up/cleanOldAssets.ts
- uses: actions/upload-artifact@v4
if: always()
with:
if-no-files-found: error
name: playwright-artifacts-${{ github.sha }}
path: |
server.log
test-session
- name: Semantic release
continue-on-error: true
run: npx semantic-release