-
Notifications
You must be signed in to change notification settings - Fork 1
194 lines (159 loc) · 5.25 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
name: Continuous Integration
on:
push:
pull_request:
types: [ opened, reopened ]
jobs:
golang:
name: Go CI
runs-on: ubuntu-20.04
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.17
- uses: innovationnorway/[email protected]
with:
version: '1.5.2'
- name: Check out code
uses: actions/[email protected]
with:
submodules: recursive
- uses: actions/[email protected]
id: go-mod-cache
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Get dependencies
run: go mod download
- name: Lint
run: |
result=$(make lint)
echo "$result"
[ -n "$(echo "$result" | grep 'diff -u')" ] && exit 1 || exit 0
- name: Build
run: make build
- name: Build sandbox
run: |
(cd notary ; make cross)
docker-compose -f notary/docker-compose.sandbox.yml build
- name: Run sandbox
run: docker-compose -f notary/docker-compose.sandbox.yml up -d
- name: Wait for notary server to be ready
run: |
health_check=https://localhost:4443/_notary_server/health
while [[ "$(curl --insecure -sLSo /dev/null -w ''%{http_code}'' ${health_check})" != "200" ]]; \
do echo "Waiting for ${health_check}" && sleep 1; \
done
echo 'OK!'
curl -X GET -sIL --insecure ${health_check}
- name: Test and Cover
run: go test -v -race -count=1 -covermode=atomic -coverprofile=coverage.out ./...
- name: Upload Code Coverage
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.out
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
verbose: true
- name: Shutdown sandbox
run: docker-compose -f notary/docker-compose.sandbox.yml down
nodejs:
name: NodeJS CI
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [16.x]
fail-fast: true
env:
CI: true
steps:
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Check out code
uses: actions/[email protected]
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/[email protected]
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Dependencies
working-directory: web
run: yarn
- name: Build local packages
working-directory: web
run: yarn build
- name: Test and coverage
working-directory: web
run: yarn test --coverage
- name: Upload Code Coverage
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./web/coverage/clover.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
verbose: true
release:
name: Release artifacts
needs: [golang, nodejs]
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/[email protected]
with:
fetch-depth: 0
submodules: recursive
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.17
- name: Login to Docker Registries
if: startsWith(github.ref, 'refs/tags/')
run: |
echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Release ${{ (!startsWith(github.ref, 'refs/tags/') && 'snapshot') || '' }}
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: release --rm-dist ${{ (!startsWith(github.ref, 'refs/tags/') && '--snapshot') || '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release Docker dctna-web
run: |
make dockerize-web
if [ "${{ startsWith(github.ref, 'refs/tags/') }}" == 'true' ] ; then
make docker-publish-web
fi
- name: Logout from Docker Registries
if: ${{ always() }}
run: |
docker logout
docker logout ghcr.io
provenance:
name: Generate provenance
runs-on: ubuntu-20.04
needs: [release]
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Generate provenance for release
uses: philips-labs/[email protected]
with:
command: generate
subcommand: github-release
arguments: --artifact-path release-assets --output-path provenance.json --tag-name ${{ github.ref_name }}
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"