-
Notifications
You must be signed in to change notification settings - Fork 0
179 lines (156 loc) · 5.45 KB
/
test.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: Lint and Test
on:
pull_request:
branches-ignore: ['main']
push:
branches-ignore: ['main']
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
# Make sure we're not running multiple release steps at the same time as this can give issues with determining the next npm version to release.
# Ideally we only add this to the 'release' job so it doesn't limit PR runs, but github can't guarantee the job order in that case:
# "When concurrency is specified at the job level, order is not guaranteed for jobs or runs that queue within 5 minutes of each other."
concurrency:
group: credo-ts-${{ github.ref }}-${{ github.repository }}-${{ github.event_name }}
cancel-in-progress: true
jobs:
repo_ids:
runs-on: ubuntu-latest
outputs:
repo_name: ${{ steps.repo_ids.outputs.REPO_NAME }}
org_name: ${{ steps.repo_ids.outputs.ORG_NAME }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get repository identifiers
id: repo_ids
run: |
REPO_NAME=$(echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]')
ORG_NAME=$(echo "${{ github.event.repository.owner.name }}" | tr '[:upper:]' '[:lower:]')
echo $REPO_NAME
echo $ORG_NAME
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_OUTPUT
echo "ORG_NAME=$ORG_NAME" >> $GITHUB_OUTPUT
static-checks:
name: Run Static Analysis Checks
strategy:
fail-fast: false
matrix:
command: [lint, depcheck, check]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- name: Install Packages
run: npm install # maybe this should be changed to npm ci
- name: ${{ matrix.command }}
run: npm run ${{ matrix.command }}
tests:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- name: Install Packages
run: npm install # maybe this should be changed to npm ci
- name: Build the TypeScript OpenAPI with tsoa
run: npm run build
- name: Run tests
run: npm run test
check-version:
name: 'Check version'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check version
id: get_version
uses: digicatapult/check-version@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
build-docker:
name: 'Build docker image'
runs-on: ubuntu-latest
steps:
- name: 'Login to GitHub Container Registry'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: '--debug'
- name: Build image
uses: docker/build-push-action@v6
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Dockerfile
# The arm64 img is added only in release ( arm ETA build-time is ~1h )
platforms: linux/amd64
push: false
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},mode=max
integration-tests:
name: 'Run integration tests'
runs-on: ubuntu-latest
steps:
- name: 'Login to GitHub Container Registry'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: '--debug'
- uses: actions/checkout@v4
- name: Build testnet and integration images
uses: docker/bake-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
files: |
./docker-compose-testnet.yml
./docker-compose-integration-tests.yml
set: |
*.cache-from=type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
*.cache-to=type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},mode=max
load: true
push: false
- name: Run integration tests
run: |
docker compose \
-f docker-compose-testnet.yml \
-f docker-compose-integration-tests.yml \
up --exit-code-from integration-tests