-
Notifications
You must be signed in to change notification settings - Fork 127
199 lines (173 loc) · 6.52 KB
/
Copy pathci.yml
File metadata and controls
199 lines (173 loc) · 6.52 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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: CI
on:
push:
branches:
- master
- develop
- beta
- next
tags-ignore:
- "**"
paths-ignore:
- "**/CHANGELOG.md"
- "**/package.json"
pull_request:
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Use Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: ".nvmrc"
# https://github.com/actions/cache/blob/main/examples.md#node---npm
- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- name: Cache node modules
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install deps
run: npm ci --audit=false
- name: Lint ESLint
run: npm run lint:eslint
- name: Lint Prettier
run: npm run lint:prettier
test:
strategy:
fail-fast: false
matrix:
suite:
[
api:blocks,
api:bns,
api:cache,
api:datastore,
api:event-replay,
api:event-server,
api:mempool,
api:microblocks,
api:principal,
api:redis,
api:smart-contracts,
api:sockets,
api:synthetic-txs,
api:transactions,
api:v2-proxy,
api:v3,
api:pox5,
# krypton:bns-e2e,
# krypton:faucet-btc,
# krypton:faucet-sbtc,
# krypton:faucet-stx,
# krypton:pox-4-btc-address-formats,
# krypton:pox-4-burnchain-delegate-stx,
# krypton:pox-4-burnchain-stack-stx,
# krypton:pox-4-delegate-aggregation,
# krypton:pox-4-delegate-revoked-stacking,
# krypton:pox-4-delegate-stacking,
# krypton:pox-4-stack-extend-increase,
# krypton:rpc,
snp,
]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Use Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: ".nvmrc"
# https://github.com/actions/cache/blob/main/examples.md#node---npm
- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- name: Cache node modules
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install deps
run: npm ci --audit=false
- name: Install client deps
working-directory: client
run: npm ci --audit=false
- name: Setup replay directory permissions
if: matrix.suite == 'api:event-replay'
run: |
mkdir -p tests/api/event-replay/.tmp/local/
sudo chown 999:999 tests/api/event-replay/.tmp/local/
sudo chmod -R 777 tests/api/event-replay/.tmp/local/
- name: Run tests
run: npx c8 --reporter=lcov npm run test:${{ matrix.suite }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@e53489f4d376d79066609109e7a95a29eb3740b1 # v7.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
if: always()
build-publish:
runs-on: ubuntu-latest
needs: [lint, test]
environment: Production
permissions:
id-token: write
contents: read
packages: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
- name: Configure AWS Credentials via OIDC
uses: aws-actions/configure-aws-credentials@254c19bd240aabef8777f48595e9d2d7b972184b # v6.2.1
with:
role-to-assume: ${{ vars.AWS_ROLE_ARN }}
aws-region: ${{ vars.AWS_REGION || 'us-east-2' }}
- name: Login to Amazon ECR
id: ecr_login
uses: aws-actions/amazon-ecr-login@b040164c4934333d597f3f9c67502ff28f814e9c # v2.1.6
- name: Docker Meta
id: docker_meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: |
ghcr.io/${{ github.repository }}
hirosystems/${{ github.event.repository.name }}
${{ steps.ecr_login.outputs.registry }}/${{ vars.AWS_ECR_REPOSITORY }}
tags: |
type=ref,event=branch
type=ref,event=pr
- name: Log in to GitHub Container Registry
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.0
with:
username: ${{ secrets.HIROSYSTEMS_DOCKERHUB_USERNAME }}
password: ${{ secrets.HIROSYSTEMS_DOCKERHUB_TOKEN }}
- name: Build/Tag/Push Image
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
with:
context: .
platforms: ${{ github.ref == 'refs/heads/master' && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
# Only push on non-PR events, or PRs that aren't from forks
push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}