-
Notifications
You must be signed in to change notification settings - Fork 9
171 lines (166 loc) · 6.16 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
161
162
163
164
165
166
167
168
169
170
name: Rust Build and Test
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
merge_group:
branches: [ "main" ]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- 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: Install Protoc
run: |
PROTOC_VERSION=3.20.1
PROTOC_ARCH=linux-x86_64
PROTOC_ZIP=protoc-$PROTOC_VERSION-$PROTOC_ARCH.zip
curl --retry 3 --retry-max-time 90 -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -OL https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*'
rm -f $PROTOC_ZIP
echo "PROTOC=/usr/local/bin/protoc" >> $GITHUB_ENV
echo "PROTOC_INCLUDE=/usr/local/include" >> $GITHUB_ENV
- 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
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- 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: Install Protoc
run: |
PROTOC_VERSION=3.20.1
PROTOC_ARCH=linux-x86_64
PROTOC_ZIP=protoc-$PROTOC_VERSION-$PROTOC_ARCH.zip
curl --retry 3 --retry-max-time 90 -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -OL https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*'
rm -f $PROTOC_ZIP
echo "PROTOC=/usr/local/bin/protoc" >> $GITHUB_ENV
echo "PROTOC_INCLUDE=/usr/local/include" >> $GITHUB_ENV
- name: Run tests
run: make test
build:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.build.outputs.build_tag }}
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- 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: Install Protoc
run: |
PROTOC_VERSION=3.20.1
PROTOC_ARCH=linux-x86_64
PROTOC_ZIP=protoc-$PROTOC_VERSION-$PROTOC_ARCH.zip
curl --retry 3 --retry-max-time 90 -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -OL https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*'
rm -f $PROTOC_ZIP
echo "PROTOC=/usr/local/bin/protoc" >> $GITHUB_ENV
echo "PROTOC_INCLUDE=/usr/local/include" >> $GITHUB_ENV
- name: Build
run: make build
-
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
id: build
run: |
SHA_TAG=$(echo ${{ github.SHA }} | head -c 12)
BUILD_TAG=$SHA_TAG
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
if [[ $(echo "$COMMIT_MESSAGE" | grep 'chore: version v') ]]; then
RELEASE_TAG=$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].version' | tr -d '"')
# Use the release tag to deploy, if one is available.
BUILD_TAG=$RELEASE_TAG
fi
make SHA="${{ github.SHA }}" SHA_TAG="$SHA_TAG" RELEASE_TAG="$RELEASE_TAG" publish-docker
echo "Build tag:"
echo ${BUILD_TAG}
echo "build_tag=${BUILD_TAG}" >> $GITHUB_OUTPUT
correctness-tests:
runs-on: ubuntu-latest
environment: github-tests-2024
needs:
- build
steps:
- uses: actions/checkout@v3
- name: Get Network template and update
env:
RUST_CERAMIC_IMAGE: ${{ needs.build.outputs.build_tag }}
run: |
set -ex
mkdir ./bin
sudo apt-get update && sudo apt-get install -y curl
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 --no-colors basic-rust.yaml
-
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: Run correctness-tests
run: |
./bin/hermetic-driver test \
--network basic-rust.yaml \
--flavor correctness \
--test-selector "fast"