-
Notifications
You must be signed in to change notification settings - Fork 10
160 lines (154 loc) · 5.22 KB
/
rust-build-and-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
name: Rust Build and Test
on:
pull_request: {}
merge_group:
branches: [ "main" ]
workflow_dispatch:
inputs:
test_selector:
description: 'Test selector'
required: false
default: '.'
options:
- "fast"
- "slow"
- "."
env:
CARGO_TERM_COLOR: always
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
jobs:
check:
runs-on: ubuntu-latest
container: 'public.ecr.aws/r5b3e0r5/3box/rust-builder:latest'
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
with:
# The prefix cache key, this can be changed to start a new cache manually.
# default: "v0-rust"
prefix-key: v0
# Cache only the cargo registry
cache-targets: false
- uses: mozilla-actions/[email protected]
- name: git file permission config
run: git config --global --add safe.directory '*'
- name: Check fmt
run: make check-fmt
- name: Check clippy
run: make check-clippy
- name: Check generated servers
run: |
make check-api-server
make check-kubo-rpc-server
- name: Check deps
run: make check-deps
test:
runs-on: ubuntu-latest
container: 'public.ecr.aws/r5b3e0r5/3box/rust-builder:latest'
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
with:
# The prefix cache key, this can be changed to start a new cache manually.
# default: "v0-rust"
prefix-key: v0
# Cache only the cargo registry
cache-targets: false
- uses: mozilla-actions/[email protected]
- name: Run tests
run: make test
build:
runs-on: ubuntu-latest
outputs:
build_tag: ${{ steps.build.outputs.build_tag }}
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
with:
# The prefix cache key, this can be changed to start a new cache manually.
# default: "v0-rust"
prefix-key: v0
# Cache only the cargo registry
cache-targets: false
- uses: mozilla-actions/[email protected]
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Public ECR
uses: docker/login-action@v2
with:
registry: public.ecr.aws
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
env:
AWS_REGION: us-east-1
-
name: Build and Publish Docker Image
id: build
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
BUILD_TAG=$(echo ${{ github.event.pull_request.head.sha }} | head -c 12)
else
BUILD_TAG=$(echo ${{ github.sha }} | head -c 12)
fi
make SHA_TAG="$BUILD_TAG" TAG_LATEST="false" publish-docker
echo "Build tag:"
echo ${BUILD_TAG}
echo "build_tag=${BUILD_TAG}" >> $GITHUB_OUTPUT
correctness-tests:
runs-on: ubuntu-latest
environment: dev-qa-2024
needs:
- build
steps:
- uses: actions/checkout@v3
-
name: Setup GKE auth
uses: 'google-github-actions/auth@v1'
with:
credentials_json: ${{ secrets.GKE_SA_KEY }}
-
name: Get GKE credentials
uses: 'google-github-actions/get-gke-credentials@v1'
with:
cluster_name: ${{ vars.GKE_CLUSTER }}
location: ${{ vars.GKE_ZONE }}
-
name: Get Network template and update
env:
RUST_CERAMIC_IMAGE_TAG: ${{ needs.build.outputs.build_tag }}
RUST_CERAMIC_IMAGE_REPO: public.ecr.aws/r5b3e0r5/3box/ceramic-one
run: |
set -ex
export RUST_CERAMIC_IMAGE=${RUST_CERAMIC_IMAGE_REPO}:${RUST_CERAMIC_IMAGE_TAG}
export KERAMIK_NETWORK_NAME=hermetic-rust-ceramic-${RUST_CERAMIC_IMAGE_TAG}
mkdir ./bin
curl -L https://github.com/mikefarah/yq/releases/download/v4.40.5/yq_linux_amd64 -o ./bin/yq
chmod +x ./bin/yq
curl -L https://github.com/3box/ceramic-tests/releases/download/v0.2.0/hermetic-driver-x86_64-linux -o ./bin/hermetic-driver
chmod +x ./bin/hermetic-driver
curl -LO https://raw.githubusercontent.com/3box/ceramic-tests/main/networks/basic-rust.yaml
./bin/yq -i '.spec.ceramic[0].ipfs.rust.image = strenv(RUST_CERAMIC_IMAGE)' basic-rust.yaml
./bin/yq -i '.metadata.name = strenv(KERAMIK_NETWORK_NAME)' basic-rust.yaml
./bin/yq --no-colors basic-rust.yaml
-
name: Run correctness-tests
# On PRs run fast tests
# On merges to main, run all tests
# Workflow_dispatch picks what to run
run: |
set -ex
if [ "${{ github.event_name }}" == "pull_request" ]; then
TEST_SELECTOR="correctness/fast"
elif [ "${{ github.event_name }}" == "merge_group" ]; then
TEST_SELECTOR="correctness"
elif [ "${{ github.event_name}}" == "workflow_dispatch" ]; then
TEST_SELECTOR="${{ github.event.inputs.test_selector || 'correctness' }}"
fi
./bin/hermetic-driver test \
--network basic-rust.yaml \
--flavor correctness \
--test-selector ${TEST_SELECTOR} \
--network-ttl 3600