-
Notifications
You must be signed in to change notification settings - Fork 155
221 lines (204 loc) · 8.09 KB
/
pipeline.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
# SPDX-License-Identifier: MIT
#
# Copyright (c) 2024 Berachain Foundation
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
name: pipeline
on:
push:
branches:
- main
tags:
- "v*"
pull_request:
merge_group:
concurrency:
group: ci-${{ github.ref }}-tests
# We don't want to cancel in progress on main. This is to allow
# us to debug main if a bad commit is pushed.
# Case 1: The base branch is main and the event triggered via merge group => we DO NOT want to cancel in progress
# Case 2: The reference branch is not main => we want to cancel in progress
cancel-in-progress: ${{ !(github.base_ref == 'refs/heads/main' && github.event_name == 'merge_group') || github.ref != 'refs/heads/main' }}
env:
GCP_ID_PROVIDER: "projects/341806074811/locations/global/workloadIdentityPools/oidc-apps-automation-st-01-pool/providers/gh-apps-oidc-provider"
GCP_SERVICE_ACCOUNT: "sa-apps-deployment@prj-berachain-automation-st-01.iam.gserviceaccount.com"
GCP_REGISTRY: northamerica-northeast1-docker.pkg.dev
GHCR_REGISTRY: ghcr.io
PUSH_DOCKER_IMAGE: ${{ (github.base_ref == github.head_ref && github.event_name == 'push') || github.ref == 'refs/tags/v*'}}
VERSION: ${{ github.ref_name }}
jobs:
# -------------------------------------------------------------------------- #
# Main Pipeline #
# -------------------------------------------------------------------------- #
ci:
strategy:
matrix:
args:
- "build"
- "lint"
- "slither"
- "gosec"
- "markdownlint"
- "generate-check"
- "tidy-sync-check"
- "test-unit-cover"
- "test-unit-bench"
- "test-unit-fuzz"
- "test-forge-cover"
- "test-forge-fuzz"
os:
- ubuntu-24.04-beacon-kit
name: ${{ matrix.args }}
runs-on:
labels: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
if: ${{ matrix.args == 'lint' || matrix.args == 'generate-check' || matrix.args == 'test-forge-cover' || matrix.args == 'test-forge-fuzz' }}
- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version: "1.23.4"
check-latest: true
cache-dependency-path: "**/*.sum"
if: ${{ !(matrix.args == 'test-forge-cover' || matrix.args == 'test-forge-fuzz') }}
- name: Run ${{ matrix.args }}
run: |
make ${{ matrix.args }}
env:
GOPATH: /home/runner/go
- name: Upload to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./${{ matrix.args }}.txt
if: ${{ matrix.args == 'test-unit-cover' || matrix.args == 'test-forge-cover'}}
# -------------------------------------------------------------------------- #
# E2E Testing #
# -------------------------------------------------------------------------- #
ci-e2e:
strategy:
matrix:
args:
- "test-e2e"
os:
- ubuntu-24.04-e2e
name: ${{ matrix.args }}
runs-on:
labels: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: https://index.docker.io/v1/
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version: "stable"
check-latest: true
cache-dependency-path: "**/*.sum"
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Install Kurtosis
run: |
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list
sudo apt update
sudo apt install kurtosis-cli=$(go list -m -f '{{.Version}}' github.com/kurtosis-tech/kurtosis/api/golang | sed 's/^v//') -y
kurtosis engine start
if: ${{ matrix.args == 'test-e2e' }}
- name: Run ${{ matrix.args }}
run: |
make ${{ matrix.args }}
env:
GOPATH: /home/runner/go
# -------------------------------------------------------------------------- #
# Docker Container Build and Push #
# -------------------------------------------------------------------------- #
build-and-push-container:
runs-on:
labels: ubuntu-24.04-beacon-kit
permissions:
id-token: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Echo GitHub Context Variables
run: |
echo "GitHub Actor: ${{ github.actor }}"
echo "GitHub Repository: ${{ github.repository }}"
echo "GitHub Event Name: ${{ github.event_name }}"
echo "GitHub SHA: ${{ github.sha }}"
echo "GitHub Ref: ${{ github.ref }}"
echo "GitHub Workflow: ${{ github.workflow }}"
echo "GitHub Action: ${{ github.action }}"
echo "GitHub Run ID: ${{ github.run_id }}"
echo "GitHub Run Number: ${{ github.run_number }}"
echo "GitHub Job: ${{ github.job }}"
echo "GitHub Server URL: ${{ github.server_url }}"
echo "GitHub API URL: ${{ github.api_url }}"
echo "GitHub GraphQL URL: ${{ github.graphql_url }}"
echo "Github Ref: ${{ github.ref }}"
echo "GitHub Head Ref: ${{ github.head_ref }}"
echo "GitHub Base Ref: ${{ github.base_ref }}"
echo "PUSH_DOCKER_IMAGE: ${{ env.PUSH_DOCKER_IMAGE }}"
echo "VERSION: ${{ env.VERSION }}"
- name: Build Docker image
run: |
make build-docker
- if: ${{ env.PUSH_DOCKER_IMAGE == 'true' }}
name: Authenticate to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.GHCR_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}
- if: ${{ env.PUSH_DOCKER_IMAGE == 'true' }}
name: Authenticate to Google Cloud
id: "auth"
uses: "google-github-actions/auth@v2"
with:
workload_identity_provider: ${{ env.GCP_ID_PROVIDER }}
service_account: ${{ env.GCP_SERVICE_ACCOUNT }}
- if: ${{ env.PUSH_DOCKER_IMAGE == 'true' }}
name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v2"
- if: ${{ env.PUSH_DOCKER_IMAGE == 'true' }}
name: Setup Docker to use Google Cloud OIDC
run: |
gcloud auth configure-docker ${{ env.GCP_REGISTRY }} --quiet
- if: ${{ env.PUSH_DOCKER_IMAGE == 'true' }}
name: Push Docker image
run: |
make push-docker-gcp push-docker-github