Skip to content

Commit ffdd6d0

Browse files
authored
[tooling] Add support for the Task (go-task) task runner (#3863)
1 parent e4095d0 commit ffdd6d0

19 files changed

+294
-108
lines changed

.envrc

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Requires nix to be installed and available in the PATH.
2+
# To install nix: `./scripts/run_task.sh install-nix`
13
use flake
24

35
# Repo-local commands like ginkgo and tmpnetctl

.github/workflows/build-linux-binaries.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- run: go version
2626

2727
- name: Build the avalanchego binaries
28-
run: ./scripts/build.sh
28+
run: ./scripts/run_task.sh build
2929

3030
- name: Install aws cli
3131
run: sudo snap install aws-cli --classic
@@ -85,7 +85,7 @@ jobs:
8585
- run: go version
8686

8787
- name: Build the avalanchego binaries
88-
run: ./scripts/build.sh
88+
run: ./scripts/run_task.sh build
8989

9090
- name: Install aws cli
9191
run: sudo snap install aws-cli --classic

.github/workflows/build-macos-release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232

3333
# Runs a single command using the runners shell
3434
- name: Build the avalanchego binary
35-
run: ./scripts/build.sh
35+
run: ./scripts/run_task.sh build
3636

3737
- name: Try to get tag from git
3838
if: "${{ github.event.inputs.tag == '' }}"

.github/workflows/build-ubuntu-amd64-release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- run: go version
2424

2525
- name: Build the avalanchego binaries
26-
run: ./scripts/build.sh
26+
run: ./scripts/run_task.sh build
2727

2828
- name: Install aws cli
2929
run: sudo snap install aws-cli --classic
@@ -81,7 +81,7 @@ jobs:
8181
- run: go version
8282

8383
- name: Build the avalanchego binaries
84-
run: ./scripts/build.sh
84+
run: ./scripts/run_task.sh build
8585

8686
- name: Install aws cli
8787
run: sudo snap install aws-cli --classic

.github/workflows/build-ubuntu-arm64-release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- run: go version
2424

2525
- name: Build the avalanchego binaries
26-
run: ./scripts/build.sh
26+
run: ./scripts/run_task.sh build
2727

2828
- name: Install aws cli
2929
run: sudo snap install aws-cli --classic
@@ -81,7 +81,7 @@ jobs:
8181
- run: go version
8282

8383
- name: Build the avalanchego binaries
84-
run: ./scripts/build.sh
84+
run: ./scripts/run_task.sh build
8585

8686
- name: Install aws cli
8787
run: sudo snap install aws-cli --classic

.github/workflows/build-win-release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060

6161
# Runs a single command using the runners shell
6262
- name: Build the avalanchego binary
63-
run: ./scripts/build.sh
63+
run: ./scripts/run_task.sh build
6464
shell: bash
6565

6666
- name: Create zip

.github/workflows/ci.yml

+19-69
Original file line numberDiff line numberDiff line change
@@ -33,32 +33,28 @@ jobs:
3333
shell: bash
3434
if: matrix.os == 'windows-2022'
3535
run: echo "TIMEOUT=240s" >> "$GITHUB_ENV"
36-
- name: build_test
36+
- name: test-unit
3737
shell: bash
38-
run: ./scripts/build_test.sh
38+
run: ./scripts/run_task.sh test-unit
3939
env:
4040
TIMEOUT: ${{ env.TIMEOUT }}
4141
Fuzz:
4242
runs-on: ubuntu-latest
4343
steps:
4444
- uses: actions/checkout@v4
4545
- uses: ./.github/actions/setup-go-for-project
46-
- name: fuzz_test
46+
- name: test-fuzz
4747
shell: bash
48-
run: ./scripts/build_fuzz.sh 10 # Run each fuzz test 10 seconds
48+
run: ./scripts/run_task.sh test-fuzz
4949
e2e:
5050
runs-on: ubuntu-latest
5151
steps:
5252
- uses: actions/checkout@v4
5353
- uses: ./.github/actions/setup-go-for-project
54-
- name: Build AvalancheGo Binary
55-
shell: bash
56-
run: ./scripts/build.sh -r
5754
- name: Run e2e tests
5855
uses: ./.github/actions/run-monitored-tmpnet-cmd
5956
with:
60-
run: ./scripts/tests.e2e.sh
61-
run_env: E2E_SERIAL=1
57+
run: ./scripts/run_task.sh test-e2e-ci
6258
artifact_prefix: e2e
6359
filter_by_owner: avalanchego-e2e
6460
prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }}
@@ -70,14 +66,10 @@ jobs:
7066
steps:
7167
- uses: actions/checkout@v4
7268
- uses: ./.github/actions/setup-go-for-project
73-
- name: Build AvalancheGo Binary
74-
shell: bash
75-
run: ./scripts/build.sh -r
7669
- name: Run e2e tests
7770
uses: ./.github/actions/run-monitored-tmpnet-cmd
7871
with:
79-
run: ./scripts/tests.e2e.sh --activate-fortuna
80-
run_env: E2E_SERIAL=1
72+
run: ./scripts/run_task.sh test-e2e-ci -- --activate-fortuna
8173
artifact_prefix: e2e-post-fortuna
8274
filter_by_owner: avalanchego-e2e
8375
prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }}
@@ -89,14 +81,10 @@ jobs:
8981
steps:
9082
- uses: actions/checkout@v4
9183
- uses: ./.github/actions/setup-go-for-project
92-
- name: Build AvalancheGo Binary
93-
shell: bash
94-
run: ./scripts/build.sh -r
9584
- name: Run e2e tests with existing network
9685
uses: ./.github/actions/run-monitored-tmpnet-cmd
9786
with:
98-
run: ./scripts/tests.e2e.existing.sh
99-
run_env: E2E_SERIAL=1
87+
run: ./scripts/run_task.sh test-e2e-existing-ci
10088
artifact_prefix: e2e-existing-network
10189
prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }}
10290
prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }}
@@ -107,14 +95,11 @@ jobs:
10795
steps:
10896
- uses: actions/checkout@v4
10997
- uses: ./.github/actions/setup-go-for-project
110-
- name: Build AvalancheGo Binary
111-
shell: bash
112-
run: ./scripts/build.sh
11398
# TODO: Reactivate test once v1.13.0 is published
11499
# - name: Run e2e tests
115100
# uses: ./.github/actions/run-monitored-tmpnet-cmd
116101
# with:
117-
# run: ./scripts/tests.upgrade.sh
102+
# run: ./scripts/run_task.sh test-upgrade
118103
# artifact_prefix: upgrade
119104
# prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }}
120105
# prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }}
@@ -125,16 +110,10 @@ jobs:
125110
steps:
126111
- uses: actions/checkout@v4
127112
- uses: ./.github/actions/setup-go-for-project
128-
- name: Run static analysis tests
129-
shell: bash
130-
run: scripts/lint.sh
131-
- name: Run actionlint
132-
shell: bash
133-
run: scripts/actionlint.sh
134113
- uses: ./.github/actions/install-nix
135-
- name: Run shellcheck
136-
shell: bash
137-
run: nix develop --command bash -x scripts/shellcheck.sh
114+
- name: Runs all lint checks
115+
shell: nix develop --command bash -x {0}
116+
run: ./scripts/run_task.sh lint-all-ci
138117
buf-lint:
139118
name: Protobuf Lint
140119
runs-on: ubuntu-latest
@@ -161,40 +140,31 @@ jobs:
161140
# Use the dev shell instead of bufbuild/buf-action to ensure the dev shell provides the expected versions
162141
- uses: ./.github/actions/install-nix
163142
- shell: nix develop --command bash -x {0}
164-
run: scripts/protobuf_codegen.sh
165-
- shell: bash
166-
run: .github/workflows/check-clean-branch.sh
143+
run: ./scripts/run_task.sh check-generate-protobuf
167144
check_mockgen:
168145
name: Up-to-date mocks
169146
runs-on: ubuntu-latest
170147
steps:
171148
- uses: actions/checkout@v4
172149
- uses: ./.github/actions/setup-go-for-project
173150
- shell: bash
174-
run: |
175-
grep -lr -E '^// Code generated by MockGen\. DO NOT EDIT\.$' . | xargs -r rm
176-
go generate -run "go.uber.org/mock/mockgen" ./...
177-
.github/workflows/check-clean-branch.sh
151+
run: ./scripts/run_task.sh check-generate-mocks
178152
check_canotogen:
179153
name: Up-to-date canoto
180154
runs-on: ubuntu-latest
181155
steps:
182156
- uses: actions/checkout@v4
183157
- uses: ./.github/actions/setup-go-for-project
184158
- shell: bash
185-
run: go generate -run "github.com/StephenButtolph/canoto/canoto" ./...
186-
- shell: bash
187-
run: .github/workflows/check-clean-branch.sh
159+
run: ./scripts/run_task.sh check-generate-canoto
188160
go_mod_tidy:
189161
name: Up-to-date go.mod and go.sum
190162
runs-on: ubuntu-latest
191163
steps:
192164
- uses: actions/checkout@v4
193165
- uses: ./.github/actions/setup-go-for-project
194166
- shell: bash
195-
run: go mod tidy
196-
- shell: bash
197-
run: .github/workflows/check-clean-branch.sh
167+
run: ./scripts/run_task.sh check-go-mod-tidy
198168
test_build_image:
199169
name: Image build
200170
runs-on: ubuntu-latest
@@ -206,52 +176,32 @@ jobs:
206176
sudo apt -y install qemu-system qemu-user-static
207177
- name: Check image build
208178
shell: bash
209-
run: bash -x scripts/tests.build_image.sh
179+
run: ./scripts/run_task.sh test-build-image
210180
test_build_antithesis_avalanchego_images:
211181
name: Build Antithesis avalanchego images
212182
runs-on: ubuntu-latest
213183
steps:
214184
- uses: actions/checkout@v4
215185
- uses: ./.github/actions/setup-go-for-project
216-
- name: Build AvalancheGo Binary
217-
shell: bash
218-
run: ./scripts/build.sh -r
219-
- name: Check that the avalanchego workload is sane
220-
shell: bash
221-
run: go run ./tests/antithesis/avalanchego --avalanchego-path=./build/avalanchego --duration=120s
222186
- name: Check image build for avalanchego test setup
223187
shell: bash
224-
run: bash -x scripts/tests.build_antithesis_images.sh
225-
env:
226-
TEST_SETUP: avalanchego
188+
run: ./scripts/run_task.sh test-build-antithesis-images-avalanchego
227189
test_build_antithesis_xsvm_images:
228190
name: Build Antithesis xsvm images
229191
runs-on: ubuntu-latest
230192
steps:
231193
- uses: actions/checkout@v4
232194
- uses: ./.github/actions/setup-go-for-project
233-
- name: Build AvalancheGo Binary
234-
shell: bash
235-
run: ./scripts/build.sh -r
236-
- name: Build xsvm binary
237-
shell: bash
238-
run: ./scripts/build_xsvm.sh
239-
- name: Check that the xsvm workload is sane
240-
shell: bash
241-
run: go run ./tests/antithesis/xsvm --avalanchego-path=./build/avalanchego --duration=120s
242195
- name: Check image build for xsvm test setup
243196
shell: bash
244-
run: bash -x scripts/tests.build_antithesis_images.sh
245-
env:
246-
TEST_SETUP: xsvm
197+
run: ./scripts/run_task.sh test-build-antithesis-images-xsvm
247198
e2e_bootstrap_monitor:
248199
name: Run bootstrap monitor e2e tests
249200
runs-on: ubuntu-latest
250201
steps:
251202
- uses: actions/checkout@v4
252203
- uses: ./.github/actions/setup-go-for-project
253204
- uses: ./.github/actions/install-nix
254-
- run: nix develop --command echo "dependencies installed"
255205
- name: Run e2e tests
256206
shell: bash
257-
run: nix develop --command bash -x ./scripts/tests.e2e.bootstrap_monitor.sh
207+
run: nix develop --command ./scripts/run_task.sh test-bootstrap-monitor-e2e

.github/workflows/fuzz.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,4 @@ jobs:
1616
- name: Set up Go
1717
uses: ./.github/actions/setup-go-for-project
1818
- name: Run fuzz tests
19-
shell: bash
20-
run: ./scripts/build_fuzz.sh 180 # Run each fuzz test 180 seconds
19+
run: ./scripts/run_task.sh test-fuzz-long

.github/workflows/fuzz_merkledb.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@ jobs:
1818
- name: Set up Go
1919
uses: ./.github/actions/setup-go-for-project
2020
- name: Run merkledb fuzz tests
21-
shell: bash
22-
run: ./scripts/build_fuzz.sh 900 ./x/merkledb # Run each merkledb fuzz tests 15 minutes
21+
run: ./scripts/run_task.sh test-fuzz-merkledb

.github/workflows/publish_antithesis_images.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,13 @@ jobs:
3232
password: ${{ secrets.ANTITHESIS_GAR_JSON_KEY }}
3333

3434
- name: Build and push images for avalanchego test setup
35-
run: bash -x ./scripts/build_antithesis_images.sh
35+
run: ./scripts/run_task.sh build-antithesis-images-avalanchego
3636
env:
3737
IMAGE_PREFIX: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}
3838
IMAGE_TAG: ${{ github.event.inputs.image_tag || 'latest' }}
39-
TEST_SETUP: avalanchego
4039

4140
- name: Build and push images for xsvm test setup
42-
run: bash -x ./scripts/build_antithesis_images.sh
41+
run: ./scripts/run_task.sh build-antithesis-images-xsvm
4342
env:
4443
IMAGE_PREFIX: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}
4544
IMAGE_TAG: ${{ github.event.inputs.image_tag || 'latest' }}
46-
TEST_SETUP: xsvm

.github/workflows/publish_docker_image.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ jobs:
2727
DOCKER_PASS: ${{ secrets.docker_pass }}
2828
DOCKER_IMAGE: ${{ secrets.docker_repo }}
2929
BUILD_MULTI_ARCH: 1
30-
run: scripts/build_image.sh
30+
run: scripts/run_task.sh build-image
3131
- name: Build and publish bootstrap-monitor image to DockerHub
3232
env:
3333
DOCKER_USERNAME: ${{ secrets.docker_username }}
3434
DOCKER_PASS: ${{ secrets.docker_pass }}
3535
DOCKER_IMAGE: avaplatform/bootstrap-monitor
3636
BUILD_MULTI_ARCH: 1
37-
run: scripts/build_bootstrap_monitor_image.sh
37+
run: scripts/run_task.sh build-bootstrap-monitor-image

CONTRIBUTING.md

+13-5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ To start developing on AvalancheGo, you'll need a few things installed.
1010

1111
On MacOS, a modern version of bash is required (e.g. via [homebrew](https://brew.sh/) with `brew install bash`). The version installed by default is not compatible with AvalancheGo's [shell scripts](scripts).
1212

13+
## Running tasks
14+
15+
This repo uses the [Task](https://taskfile.dev/) task runner to simplify usage and discoverability of development tasks. To list available tasks:
16+
17+
```bash
18+
./scripts/run_task.sh
19+
```
20+
1321
## Issues
1422

1523
### Security
@@ -44,7 +52,7 @@ On MacOS, a modern version of bash is required (e.g. via [homebrew](https://brew
4452
- Any changes to protobuf message types require that protobuf files are regenerated.
4553

4654
```sh
47-
./scripts/protobuf_codegen.sh
55+
./scripts/run_task.sh generate-protobuf
4856
```
4957

5058
#### Autogenerated mocks
@@ -56,7 +64,7 @@ Mocks are auto-generated using [mockgen](https://pkg.go.dev/go.uber.org/mock/moc
5664
- To **re-generate all mocks**, use the command below from the root of the project:
5765

5866
```sh
59-
go generate -run "go.uber.org/mock/mockgen" ./...
67+
./scripts/run_task.sh generate-mocks
6068
```
6169

6270
- To **add** an interface that needs a corresponding mock generated:
@@ -90,19 +98,19 @@ Mocks are auto-generated using [mockgen](https://pkg.go.dev/go.uber.org/mock/moc
9098
- Build the avalanchego binary
9199

92100
```sh
93-
./scripts/build.sh
101+
./scripts/run_task.sh build
94102
```
95103

96104
- Run unit tests
97105

98106
```sh
99-
./scripts/build_test.sh
107+
./scripts/run_task.sh test-unit
100108
```
101109

102110
- Run the linter
103111

104112
```sh
105-
./scripts/lint.sh
113+
./scipts/run_task.sh lint
106114
```
107115

108116
### Continuous Integration (CI)

0 commit comments

Comments
 (0)