forked from stacks-network/stacks-core
-
Notifications
You must be signed in to change notification settings - Fork 0
332 lines (303 loc) · 11.3 KB
/
ci.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
name: CI
# Only run when:
# - PRs are opened against the master branch
# - the workflow is started from the UI (an optional tag can be passed in via parameter)
# - If the optional tag parameter is passed in, a new tag will be generated based off the selected branch
on:
pull_request:
workflow_dispatch:
inputs:
tag:
description: "The tag to create (optional)"
required: false
concurrency:
group: stacks-blockchain-${{ github.ref }}
# Only cancel in progress if this is for a PR
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
# Run full genesis test
full-genesis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Single full genesis integration test
env:
DOCKER_BUILDKIT: 1
# Remove .dockerignore file so codecov has access to git info
run: |
rm .dockerignore
docker build -o coverage-output -f ./.github/actions/bitcoin-int-tests/Dockerfile.large-genesis .
- uses: codecov/codecov-action@v2
with:
files: ./coverage-output/lcov.info
name: large_genesis
fail_ci_if_error: false
# Run unit tests with code coverage
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run units tests (with coverage)
env:
DOCKER_BUILDKIT: 1
# Remove .dockerignore file so codecov has access to git info
run: |
rm .dockerignore
docker build -o coverage-output -f ./.github/actions/bitcoin-int-tests/Dockerfile.code-cov .
- uses: codecov/codecov-action@v2
with:
files: ./coverage-output/lcov.info
name: unit_tests
fail_ci_if_error: false
open-api-validation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run units tests (with coverage)
env:
DOCKER_BUILDKIT: 1
run: docker build -o dist/ -f .github/actions/open-api/Dockerfile.open-api-validate .
- name: Upload bundled html
uses: actions/upload-artifact@v2
with:
name: open-api-bundle
path: |
dist
# Run net-tests
nettest:
# disable this job/test for now, since we haven't seen this pass
# on github actions in a while, and the failures can take > 4 hours
if: ${{ false }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run network relay tests
env:
DOCKER_BUILDKIT: 1
run: docker build -f ./.github/actions/bitcoin-int-tests/Dockerfile.net-tests .
core-contracts-clarinet-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: "Execute core contract unit tests in Clarinet"
uses: docker://hirosystems/clarinet:1.1.0
with:
args: test --coverage --manifest-path=./contrib/core-contract-tests/Clarinet.toml
- name: "Export code coverage"
uses: codecov/codecov-action@v1
with:
files: ./coverage.lcov
verbose: true
fail_ci_if_error: false
# rustfmt checking
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run rustfmt check
env:
DOCKER_BUILDKIT: 1
run: docker build -f ./.github/actions/bitcoin-int-tests/Dockerfile.rustfmt .
# Create distributions
dist:
runs-on: ubuntu-latest
strategy:
matrix:
platform:
[
# disable mac builds until osxcross can be updated for bullseye
windows-x64,
# macos-x64,
# macos-arm64,
linux-x64,
linux-musl-x64,
linux-armv7,
linux-arm64,
]
steps:
- uses: actions/checkout@v2
- name: Set Vars
run: |
echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
echo "GITHUB_REF_SHORT=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build distributable
uses: docker/build-push-action@v2
with:
file: build-scripts/Dockerfile.${{ matrix.platform }}
outputs: dist/${{ matrix.platform }}
build-args: |
STACKS_NODE_VERSION=${{ github.event.inputs.tag || env.GITHUB_SHA_SHORT }}
GIT_BRANCH=${{ env.GITHUB_REF_SHORT }}
GIT_COMMIT=${{ env.GITHUB_SHA_SHORT }}
- name: Compress artifact
run: zip --junk-paths ${{ matrix.platform }} ./dist/${{ matrix.platform }}/*
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.platform }}
path: ${{ matrix.platform }}.zip
# call-docker-platforms-workflow:
# if: ${{ github.event.inputs.tag != '' }}
# uses: stacks-network/stacks-blockchain/.github/workflows/docker-platforms.yml@master
# with:
# tag: ${{ github.event.inputs.tag }}
# secrets:
# DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
# DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
# Build docker image, tag it with the git tag and `latest` if running on master branch, and publish under the following conditions
# Will publish if:
# - a tag was passed into this workflow
# - a tag was pushed up
# - this workflow was invoked against a non-master branch (a Docker image tag with the name of the branch will be published)
build-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set Vars
run: |
echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
echo "GITHUB_REF_SHORT=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
blockstack/${{ github.event.repository.name }}
tags: |
type=ref,event=branch
type=ref,event=pr
${{ github.event.inputs.tag }}
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build/Tag/Push Image
uses: docker/build-push-action@v2
with:
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
STACKS_NODE_VERSION=${{ github.event.inputs.tag || env.GITHUB_SHA_SHORT }}
GIT_BRANCH=${{ env.GITHUB_REF_SHORT }}
GIT_COMMIT=${{ env.GITHUB_SHA_SHORT }}
# Only push if (a tag was passed in) or (we're building a non-master branch which isn't a PR)
push: ${{ github.event.inputs.tag != '' || (github.ref != 'refs/heads/master' && !contains(github.ref, 'refs/pull')) }}
# Build docker image, tag it with the git tag and `latest` if running on master branch, and publish under the following conditions
# Will publish if:
# - a tag was passed into this workflow
# - a tag was pushed up
# - this workflow was invoked against a non-master branch (a Docker image tag with the name of the branch will be published)
build-publish-stretch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Stretch tag will be "<TAG>-stretch" if a tag was passed in, otherwise "<BRANCH>-stretch". If the BRANCH is master, will result in "latest-stretch"
# Also determines platforms to be build in docker step
- name: Determine Stretch Tag
run: |
if [[ -z ${TAG} ]]; then
REF=$(echo ${GITHUB_REF#refs/*/} | tr / -)
if [[ "${REF}" == "master" ]]; then
echo "STRETCH_TAG=latest-stretch" >> $GITHUB_ENV
else
echo "STRETCH_TAG=${REF}-stretch" >> $GITHUB_ENV
fi
else
echo "STRETCH_TAG=${TAG}-stretch" >> $GITHUB_ENV
fi
env:
TAG: ${{ github.event.inputs.tag }}
- name: Set Vars
run: |
echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
echo "GITHUB_REF_SHORT=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
blockstack/${{ github.event.repository.name }}
tags: |
type=ref,event=branch
type=ref,event=pr
${{ env.STRETCH_TAG }}
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build/Tag/Push Image
uses: docker/build-push-action@v2
with:
platforms: linux/amd64
file: Dockerfile.debian
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
STACKS_NODE_VERSION=${{ github.event.inputs.tag || env.GITHUB_SHA_SHORT }}
GIT_BRANCH=${{ env.GITHUB_REF_SHORT }}
GIT_COMMIT=${{ env.GITHUB_SHA_SHORT }}
# Only push if (a tag was passed in) or (we're building a non-master branch which isn't a PR)
push: ${{ github.event.inputs.tag != '' || (github.ref != 'refs/heads/master' && !contains(github.ref, 'refs/pull')) }}
# Create a new release if we're building a tag
create-release:
runs-on: ubuntu-latest
if: ${{ github.event.inputs.tag != '' }}
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
needs:
- dist
- build-publish
- build-publish-stretch
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
# Use custom secrets.GH_TOKEN instead of default secrets.GITHUB_TOKEN because the custom token will trigger the
# clarity-js-sdk-pr workflow. As events caused by default tokens do not trigger subsequent workflow runs to avoid loops.
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
tag_name: ${{ github.event.inputs.tag || github.ref }}
release_name: Release ${{ github.event.inputs.tag || github.ref }}
draft: false
prerelease: true
# Upload distributables to a new release if we're building a tag or a tag was passed in
upload-dist:
runs-on: ubuntu-latest
if: ${{ github.event.inputs.tag != '' }}
needs:
- create-release
strategy:
matrix:
platform:
[
# disable mac builds until osxcross can be updated for bullseye
windows-x64,
# macos-x64,
# macos-arm64,
linux-x64,
linux-musl-x64,
linux-armv7,
linux-arm64,
]
steps:
- uses: actions/checkout@v2
- name: Download distro
uses: actions/download-artifact@v2
with:
name: ${{ matrix.platform }}
path: dist/
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./dist/${{ matrix.platform }}.zip
asset_name: ${{ matrix.platform }}.zip
asset_content_type: application/zip