-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (94 loc) · 3.22 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Test and Release
on:
push:
workflow_dispatch:
permissions:
id-token: write
contents: write
issues: write
actions: write
env:
CI: 1
FORCE_COLOR: 3
jobs:
e2e-tests:
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22.x"
cache: "npm"
- name: Install dependencies
run: npm ci --no-audit
- name: Check 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: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
# The role is set up via https://github.com/bifravst/ci
# secrets.AWS_ACCOUNT_ID_CI is an organization secret
role-to-assume: |
arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID_CI }}:role/${{ github.repository_owner }}-ci-${{ github.event.repository.name }}
# vars.AWS_REGION_CI is an organization variable
aws-region: ${{ vars.AWS_REGION_CI }}
- name: Generate Stack ID
run: |
RANDOM_STRING=`node -e "const crypto = require('crypto'); process.stdout.write(crypto.randomBytes(Math.ceil(8 * 0.5)).toString('hex').slice(0, 8));"`
echo "STACK_NAME=sim-details-${RANDOM_STRING}" >> $GITHUB_ENV
- name: Deploy solution stack
env:
JSII_SILENCE_WARNING_UNTESTED_NODE_VERSION: 1
run: npx cdk deploy --require-approval never
- name: Run End-to-End Tests
run: npm run test:e2e
- name: Print failed End-to-End tests
if: failure()
run:
cat e2e-test-result.json | npx tsx --no-warnings
./features/console-reporter.ts --only-failed --with-timestamps
- name: Clean up End-to-End test resources
env:
JSII_SILENCE_WARNING_UNTESTED_NODE_VERSION: 1
if: always()
run: |
npx cdk destroy -f
release:
needs:
- e2e-tests
runs-on: ubuntu-24.04
if: github.ref == 'refs/heads/saga'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22.x"
cache: "npm"
- name: Install dependencies
run: npm ci --no-audit
- name: Semantic release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
# The role is set up via https://github.com/bifravst/ci
# secrets.AWS_ACCOUNT_ID_CI is an organization secret
role-to-assume: |
arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID_CI }}:role/${{ github.repository_owner }}-ci-${{ github.event.repository.name }}
# vars.AWS_REGION_CI is an organization variable
aws-region: ${{ vars.AWS_REGION_CI }}
- name: Trigger deployment workflow
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh workflow run deploy.yaml \
-F ref=${{ github.sha }}