-
Notifications
You must be signed in to change notification settings - Fork 6
181 lines (156 loc) · 6.02 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
name: Proposal tests
# NB: This job works differently for PRs and non-PRs. If you make significant changes,
# be sure to manually trigger the non-PR workflow before merging.
# In PRS,
# - build and run 'test' images
# - no pushing of images
#
# In `main` pushes and manual triggers,
# - build and run 'test' images
# - build 'use' images for *all passed proposals* AND push to registry (e.g. use-upgrade-10)
# In both cases it uses a remote builder with depot.dev (see depot.json) to get a persistent
# build cache and automatic multiplatform builds and image management.
# If `main` fails, you'll make a PR to fix it but its CI will only run the PR flow above.
# To test the non-PR way, you need to manually trigger this workflow by going to,
# https://github.com/Agoric/agoric-3-proposals/actions/workflows/ci.yml
# and clicking "Run workflow", specifying this branch.
on:
pull_request:
workflow_dispatch:
merge_group:
push:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
test-package:
runs-on: 'ubuntu-latest'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
# 18.19 causes this problem running tsx:
# The --loader flag was deprecated in Node v20.6.0
node-version: 18.18
- name: Install deps
run: |
# Enable corepack for packageManager config
corepack enable || sudo corepack enable
yarn install
- name: Format
run: yarn format --check
- name: Typecheck
run: yarn tsc
working-directory: packages/synthetic-chain
- name: Test
run: yarn test
working-directory: packages/synthetic-chain
# see https://docs.docker.com/build/ci/github-actions/test-before-push/
test-proposals:
permissions:
# allow issuing OIDC tokens for this workflow run
id-token: write
# allow at least reading the repo contents, add other permissions if necessary
contents: read
# to push the resulting images
packages: write
runs-on: 'ubuntu-latest'
steps:
- name: free up disk space
run: |
# Workaround to provide additional free space for testing.
# https://github.com/actions/runner-images/issues/2840#issuecomment-790492173
# If this turns out not to be enough, maybe look instead at
# https://github.com/actions/runner-images/issues/2840#issuecomment-1540506686
df -h
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
echo "=== After cleanup:"
df -h
- name: Checkout repository
uses: actions/checkout@v4
- uses: depot/setup-action@v1
with:
oidc: true # to set DEPOT_TOKEN for later steps
# make Docker's CLI use depot to build
- run: depot configure-docker
- name: Log in to the Container registry
uses: docker/login-action@v3
# see https://docs.github.com/en/actions/publishing-packages/publishing-docker-images
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ${{ env.REGISTRY }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Install deps
run: |
# Enable corepack for packageManager config
corepack enable || sudo corepack enable
yarn install
- name: Prepare Docker config
run: |
yarn build-cli
# prepare files for bake-action
yarn synthetic-chain prepare-build
# Verify that all "use" images build across platforms.
- name: Build proposal "use" images
uses: depot/bake-action@v1
with:
files: |
./docker-bake.json
./docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
targets: use
# Verify that proposals' tests pass.
# Note this builds each proposal testing image sequentially. It does that so it can delete the image
# after it passees, freeing up disk space.
- name: Build and run proposal tests
run: yarn test
# Push the images if the tests pass and this is not a PR
- name: Push proposal "use" images
# If we pushed from PRs, each one would overwrite main's (e.g. use-upgrade-8)
# To push PR "use" images we'll need to qualify the tag (e.g. use-upgrade-8-pr-2).
if: ${{ github.event_name != 'pull_request' }}
uses: depot/bake-action@v1
with:
files: |
./docker-bake.json
./docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
targets: use
push: true
# Just like the "use" image above but has to begin after that ends
# because the "build" here is merely to retag the latest "use" image.
# We could do this with imagetools but this lets use keep the tagging logic
# in Bake instead of mixed into CI. This step should do hardly any building
# because its FROM image was just built above.
- name: Push "latest" image
# Same reason as for "use" images
if: ${{ github.event_name != 'pull_request' }}
uses: depot/bake-action@v1
with:
files: |
./docker-bake.json
./docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
targets: latest
push: true
- name: notify on failure
if: failure() && github.event_name != 'pull_request'
uses: ./.github/actions/notify-status
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
from: ${{ secrets.NOTIFY_EMAIL_FROM }}
to: ${{ secrets.NOTIFY_EMAIL_TO }}
password: ${{ secrets.NOTIFY_EMAIL_PASSWORD }}