Skip to content

[tooling] Add support for the Task (go-task) task runner #3863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 14, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Requires nix to be installed and available in the PATH.
# To install nix: `./scripts/run_task.sh install_nix`
use flake

# Repo-local commands like ginkgo and tmpnetctl
Expand Down
88 changes: 19 additions & 69 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,28 @@ jobs:
shell: bash
if: matrix.os == 'windows-2022'
run: echo "TIMEOUT=240s" >> "$GITHUB_ENV"
- name: build_test
- name: test-unit
shell: bash
run: ./scripts/build_test.sh
run: ./scripts/run_task.sh test-unit
env:
TIMEOUT: ${{ env.TIMEOUT }}
Fuzz:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go-for-project
- name: fuzz_test
- name: test-fuzz
shell: bash
run: ./scripts/build_fuzz.sh 10 # Run each fuzz test 10 seconds
run: ./scripts/run_task.sh test-fuzz
e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go-for-project
- name: Build AvalancheGo Binary
shell: bash
run: ./scripts/build.sh -r
- name: Run e2e tests
uses: ./.github/actions/run-monitored-tmpnet-cmd
with:
run: ./scripts/tests.e2e.sh
run_env: E2E_SERIAL=1
run: ./scripts/run_task.sh test-e2e-ci
artifact_prefix: e2e
filter_by_owner: avalanchego-e2e
prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }}
Expand All @@ -70,14 +66,10 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go-for-project
- name: Build AvalancheGo Binary
shell: bash
run: ./scripts/build.sh -r
- name: Run e2e tests
uses: ./.github/actions/run-monitored-tmpnet-cmd
with:
run: ./scripts/tests.e2e.sh --activate-fortuna
run_env: E2E_SERIAL=1
run: ./scripts/run_task.sh test-e2e-ci -- --activate-fortuna
artifact_prefix: e2e-post-fortuna
filter_by_owner: avalanchego-e2e
prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }}
Expand All @@ -89,14 +81,10 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go-for-project
- name: Build AvalancheGo Binary
shell: bash
run: ./scripts/build.sh -r
- name: Run e2e tests with existing network
uses: ./.github/actions/run-monitored-tmpnet-cmd
with:
run: ./scripts/tests.e2e.existing.sh
run_env: E2E_SERIAL=1
run: ./scripts/run_task.sh test-e2e-existing-ci
artifact_prefix: e2e-existing-network
prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }}
prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }}
Expand All @@ -107,14 +95,11 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go-for-project
- name: Build AvalancheGo Binary
shell: bash
run: ./scripts/build.sh
# TODO: Reactivate test once v1.13.0 is published
# - name: Run e2e tests
# uses: ./.github/actions/run-monitored-tmpnet-cmd
# with:
# run: ./scripts/tests.upgrade.sh
# run: ./scripts/run_task.sh test-upgrade
# artifact_prefix: upgrade
# prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }}
# prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }}
Expand All @@ -125,16 +110,10 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go-for-project
- name: Run static analysis tests
shell: bash
run: scripts/lint.sh
- name: Run actionlint
shell: bash
run: scripts/actionlint.sh
- uses: ./.github/actions/install-nix
- name: Run shellcheck
shell: bash
run: nix develop --command bash -x scripts/shellcheck.sh
- name: Runs all lint checks
shell: nix develop --command bash -x {0}
run: ./scripts/run_task.sh lint-all-ci
buf-lint:
name: Protobuf Lint
runs-on: ubuntu-latest
Expand All @@ -161,40 +140,31 @@ jobs:
# Use the dev shell instead of bufbuild/buf-action to ensure the dev shell provides the expected versions
- uses: ./.github/actions/install-nix
- shell: nix develop --command bash -x {0}
run: scripts/protobuf_codegen.sh
- shell: bash
run: .github/workflows/check-clean-branch.sh
run: ./scripts/run_task.sh check-generate-protobuf
check_mockgen:
name: Up-to-date mocks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go-for-project
- shell: bash
run: |
grep -lr -E '^// Code generated by MockGen\. DO NOT EDIT\.$' . | xargs -r rm
go generate -run "go.uber.org/mock/mockgen" ./...
.github/workflows/check-clean-branch.sh
run: ./scripts/run_task.sh check-generate-mocks
check_canotogen:
name: Up-to-date canoto
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go-for-project
- shell: bash
run: go generate -run "github.com/StephenButtolph/canoto/canoto" ./...
- shell: bash
run: .github/workflows/check-clean-branch.sh
run: ./scripts/run_task.sh check-generate-canoto
go_mod_tidy:
name: Up-to-date go.mod and go.sum
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go-for-project
- shell: bash
run: go mod tidy
- shell: bash
run: .github/workflows/check-clean-branch.sh
run: ./scripts/run_task.sh check-go-mod-tidy
test_build_image:
name: Image build
runs-on: ubuntu-latest
Expand All @@ -206,52 +176,32 @@ jobs:
sudo apt -y install qemu-system qemu-user-static
- name: Check image build
shell: bash
run: bash -x scripts/tests.build_image.sh
run: ./scripts/run_task.sh test-build-image
test_build_antithesis_avalanchego_images:
name: Build Antithesis avalanchego images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go-for-project
- name: Build AvalancheGo Binary
shell: bash
run: ./scripts/build.sh -r
- name: Check that the avalanchego workload is sane
shell: bash
run: go run ./tests/antithesis/avalanchego --avalanchego-path=./build/avalanchego --duration=120s
- name: Check image build for avalanchego test setup
shell: bash
run: bash -x scripts/tests.build_antithesis_images.sh
env:
TEST_SETUP: avalanchego
run: ./scripts/run_task.sh test-build-antithesis-images-avalanchego
test_build_antithesis_xsvm_images:
name: Build Antithesis xsvm images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go-for-project
- name: Build AvalancheGo Binary
shell: bash
run: ./scripts/build.sh -r
- name: Build xsvm binary
shell: bash
run: ./scripts/build_xsvm.sh
- name: Check that the xsvm workload is sane
shell: bash
run: go run ./tests/antithesis/xsvm --avalanchego-path=./build/avalanchego --duration=120s
- name: Check image build for xsvm test setup
shell: bash
run: bash -x scripts/tests.build_antithesis_images.sh
env:
TEST_SETUP: xsvm
run: ./scripts/run_task.sh test-build-antithesis-images-xsvm
e2e_bootstrap_monitor:
name: Run bootstrap monitor e2e tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go-for-project
- uses: ./.github/actions/install-nix
- run: nix develop --command echo "dependencies installed"
- name: Run e2e tests
shell: bash
run: nix develop --command bash -x ./scripts/tests.e2e.bootstrap_monitor.sh
run: nix develop --command ./scripts/run_task.sh test-bootstrap-monitor-e2e
18 changes: 13 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ To start developing on AvalancheGo, you'll need a few things installed.

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).

## Running tasks

This repo uses the [Task](https://taskfile.dev/) task runner to simplify usage and discoverability of development tasks. To list available tasks:

```bash
./scripts/run_task.sh
```

## Issues

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

```sh
./scripts/protobuf_codegen.sh
./scripts/run_task.sh generate-protobuf
```

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

```sh
go generate -run "go.uber.org/mock/mockgen" ./...
./scripts/run_task.sh generate-mocks
```

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

```sh
./scripts/build.sh
./scripts/run_task.sh build
```

- Run unit tests

```sh
./scripts/build_test.sh
./scripts/run_task.sh test-unit
```

- Run the linter

```sh
./scripts/lint.sh
./scipts/run_task.sh lint
```

### Continuous Integration (CI)
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ This will clone and checkout the `master` branch.

#### Building AvalancheGo

Build AvalancheGo by running the build script:
Build AvalancheGo by running the build task:

```sh
./scripts/build.sh
./scripts/run_task.sh build
```

The `avalanchego` binary is now in the `build` directory. To run:
Expand Down Expand Up @@ -93,7 +93,7 @@ Make sure Docker is installed on the machine - so commands like `docker run` etc
Building the Docker image of latest `avalanchego` branch can be done by running:

```sh
./scripts/build_image.sh
./scripts/run-task.sh build-image
```

To check the built image, run:
Expand Down Expand Up @@ -155,7 +155,7 @@ AvalancheGo uses multiple tools to generate efficient and boilerplate code.

### Running protobuf codegen

To regenerate the protobuf go code, run `scripts/protobuf_codegen.sh` from the root of the repo.
To regenerate the protobuf go code, run `scripts/run-task.sh generate-protobuf` from the root of the repo.

This should only be necessary when upgrading protobuf versions or modifying .proto definition files.

Expand All @@ -180,7 +180,7 @@ If you extract buf to ~/software/buf/bin, the following should work:
export PATH=$PATH:~/software/buf/bin/:~/go/bin
go get google.golang.org/protobuf/cmd/protoc-gen-go
go get google.golang.org/protobuf/cmd/protoc-gen-go-grpc
scripts/protobuf_codegen.sh
scripts/run_task.sh generate-protobuf
```

For more information, refer to the [GRPC Golang Quick Start Guide](https://grpc.io/docs/languages/go/quickstart/).
Expand Down
Loading