From 4ad46fb80c30acd1f9450e82dbd7b730021c2687 Mon Sep 17 00:00:00 2001 From: Quentin Mc Gaw Date: Mon, 17 Feb 2025 11:33:41 +0100 Subject: [PATCH 1/5] chore(ci): remove step names when it's obvious without - Set up Go -> actions/setup-go - git diff -> `git diff --exit-code` - Run ShellCheck -> `ludeeus/action-shellcheck@` --- .github/workflows/go.yml | 15 +++++---------- .github/workflows/lint.yml | 3 +-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 701fe6b4cd2..6b3fa7e85e4 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -26,8 +26,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 + - uses: actions/setup-go@v5 with: go-version-file: "go.mod" - name: Run flaky tests sequentially @@ -47,8 +46,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 # everything - - name: Set up Go - uses: actions/setup-go@v5 + - uses: actions/setup-go@v5 with: go-version-file: "./libevm/tooling/go.mod" - run: go test ./... @@ -59,16 +57,14 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 + - uses: actions/setup-go@v5 with: go-version-file: "go.mod" - name: Run `go generate` run: go list ./... | grep -Pv "${EXCLUDE_REGEX}" | xargs go generate; - - name: git diff - run: git diff --exit-code + - run: git diff --exit-code go_tidy: runs-on: ubuntu-latest @@ -80,8 +76,7 @@ jobs: working-directory: ${{ matrix.dir }} steps: - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 + - uses: actions/setup-go@v5 with: go-version-file: "${{ matrix.dir }}/go.mod" - run: go mod tidy diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 67428073c80..35cf6f1312b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -59,7 +59,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Run ShellCheck - uses: ludeeus/action-shellcheck@2.0.0 + - uses: ludeeus/action-shellcheck@2.0.0 with: scandir: './libevm' From 57bca306970ca708f74e456b9d42c82dc6b9d336 Mon Sep 17 00:00:00 2001 From: Quentin Mc Gaw Date: Mon, 17 Feb 2025 12:01:51 +0100 Subject: [PATCH 2/5] Split Go jobs in libevm and tooling --- .github/workflows/go.yml | 57 +++++++++++----------------------------- 1 file changed, 16 insertions(+), 41 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 6b3fa7e85e4..b8cbd252f08 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -12,72 +12,47 @@ concurrency: cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} jobs: - # If adding a new job, add it to the `needs` list of the `go` job as this is - # what gates PRs. go: runs-on: ubuntu-latest - needs: [go_test_short, go_test_tooling, go_generate, go_tidy] + needs: [libevm, tooling] steps: - run: echo "Dependencies successful" - go_test_short: + libevm: + runs-on: ubuntu-latest env: FLAKY_REGEX: "ava-labs/libevm/(triedb/pathdb|eth|eth/tracers/js|eth/tracers/logger|accounts/abi/bind|accounts/keystore|eth/downloader|miner|ethclient|ethclient/gethclient|eth/catalyst)$" - runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version-file: "go.mod" + go-version-file: go.mod + + - run: go mod tidy + - name: Run `go generate` + run: go list ./... | grep -Pv "${EXCLUDE_REGEX}" | xargs go generate; + - run: git diff --exit-code + - name: Run flaky tests sequentially run: | # Upstream flakes are race conditions exacerbated by concurrent tests go list ./... | grep -P "${FLAKY_REGEX}" | xargs -n 1 go test -short; - name: Run non-flaky tests concurrently - run: | - go test -short $(go list ./... | grep -Pv "${FLAKY_REGEX}"); + run: go test -short $(go list ./... | grep -Pv "${FLAKY_REGEX}"); - go_test_tooling: + tooling: runs-on: ubuntu-latest defaults: run: working-directory: ./libevm/tooling steps: - uses: actions/checkout@v4 - with: - fetch-depth: 0 # everything - uses: actions/setup-go@v5 with: - go-version-file: "./libevm/tooling/go.mod" - - run: go test ./... + go-version-file: ./libevm/tooling/go.mod - go_generate: - env: - EXCLUDE_REGEX: "ava-labs/libevm/(accounts/usbwallet/trezor)$" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version-file: "go.mod" - - - name: Run `go generate` - run: go list ./... | grep -Pv "${EXCLUDE_REGEX}" | xargs go generate; - - - run: git diff --exit-code - - go_tidy: - runs-on: ubuntu-latest - strategy: - matrix: - dir: ["./", "./libevm/tooling"] - defaults: - run: - working-directory: ${{ matrix.dir }} - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version-file: "${{ matrix.dir }}/go.mod" - run: go mod tidy + - run: go generate ./... - run: git diff --exit-code + + - run: go test ./... From 1007f65b9d90e7d7709b984b2b38cf3fd4b9cbfe Mon Sep 17 00:00:00 2001 From: Quentin Mc Gaw Date: Mon, 17 Feb 2025 12:06:12 +0100 Subject: [PATCH 3/5] Merge lint jobs together --- .github/workflows/lint.yml | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 35cf6f1312b..a582e2ed833 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,18 +18,17 @@ concurrency: cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} jobs: - # If adding a new linter: (a) create a new job; and (b) add it to the `needs` - # list of the `lint` job as this is what gates PRs. lint: - runs-on: ubuntu-latest - needs: [golangci-lint, yamllint, shellcheck] - steps: - - run: echo "Dependencies successful" - - golangci-lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + + - run: yamllint -c .yamllint.yml . + + - uses: ludeeus/action-shellcheck@2.0.0 + with: + scandir: "./libevm" + - uses: actions/setup-go@v5 with: go-version-file: "go.mod" @@ -48,17 +47,3 @@ jobs: uses: golangci/golangci-lint-action@v6 with: version: v1.60 - - yamllint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: yamllint -c .yamllint.yml . - - shellcheck: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: ludeeus/action-shellcheck@2.0.0 - with: - scandir: './libevm' From 9d3b8c53700b52703712bac94ff8849c0fd16361 Mon Sep 17 00:00:00 2001 From: Quentin Mc Gaw Date: Mon, 17 Feb 2025 12:10:33 +0100 Subject: [PATCH 4/5] Merge lint job into Go workflow jobs --- .github/workflows/go.yml | 29 ++++++++++++++++++++++ .github/workflows/lint.yml | 49 -------------------------------------- 2 files changed, 29 insertions(+), 49 deletions(-) delete mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index b8cbd252f08..53bbb1d6b6e 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -11,6 +11,12 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} +permissions: + # Required: allow read access to the content for analysis. + contents: read + # Optional: allow read access to pull request. Use with `only-new-issues` linter option. + pull-requests: read + jobs: go: runs-on: ubuntu-latest @@ -24,6 +30,9 @@ jobs: FLAKY_REGEX: "ava-labs/libevm/(triedb/pathdb|eth|eth/tracers/js|eth/tracers/logger|accounts/abi/bind|accounts/keystore|eth/downloader|miner|ethclient|ethclient/gethclient|eth/catalyst)$" steps: - uses: actions/checkout@v4 + + - run: yamllint -c .yamllint.yml . + - uses: actions/setup-go@v5 with: go-version-file: go.mod @@ -33,6 +42,21 @@ jobs: run: go list ./... | grep -Pv "${EXCLUDE_REGEX}" | xargs go generate; - run: git diff --exit-code + - name: goheader + # The goheader linter is only enabled in the CI so that it runs only on modified or new files + # (see only-new-issues: true). It is disabled in .golangci.yml because + # golangci-lint running locally is not aware of new/modified files compared to the base + # commit of a pull request, and we want to avoid reporting invalid goheader errors. + uses: golangci/golangci-lint-action@ec5d18412c0aeab7936cb16880d708ba2a64e1ae # v6.2.0 since v6.3.1 does not handle `only-new-issues` correctly + with: + version: v1.60 + only-new-issues: true + args: --enable-only goheader + + - uses: golangci/golangci-lint-action@v6 + with: + version: v1.60 + - name: Run flaky tests sequentially run: | # Upstream flakes are race conditions exacerbated by concurrent tests @@ -47,6 +71,11 @@ jobs: working-directory: ./libevm/tooling steps: - uses: actions/checkout@v4 + + - uses: ludeeus/action-shellcheck@2.0.0 + with: + scandir: "./libevm" + - uses: actions/setup-go@v5 with: go-version-file: ./libevm/tooling/go.mod diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index a582e2ed833..00000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: lint - -on: - push: - branches: [main, "release/**"] - pull_request: - branches: [main, "release/**"] - workflow_dispatch: - -permissions: - # Required: allow read access to the content for analysis. - contents: read - # Optional: allow read access to pull request. Use with `only-new-issues` option. - pull-requests: read - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - run: yamllint -c .yamllint.yml . - - - uses: ludeeus/action-shellcheck@2.0.0 - with: - scandir: "./libevm" - - - uses: actions/setup-go@v5 - with: - go-version-file: "go.mod" - - name: goheader - if: ${{ github.event_name == 'pull_request' }} - # The goheader linter is only enabled in the CI so that it runs only on modified or new files - # (see only-new-issues: true). It is disabled in .golangci.yml because - # golangci-lint running locally is not aware of new/modified files compared to the base - # commit of a pull request, and we want to avoid reporting invalid goheader errors. - uses: golangci/golangci-lint-action@v6 - with: - version: v1.60 - only-new-issues: true - args: --enable-only goheader - - name: golangci-lint - uses: golangci/golangci-lint-action@v6 - with: - version: v1.60 From 9669aacb49af2136db397aaa8cd8d089c2ed0f5a Mon Sep 17 00:00:00 2001 From: Quentin Mc Gaw Date: Mon, 17 Feb 2025 12:15:58 +0100 Subject: [PATCH 5/5] Apply goheader fix from default branch --- .github/workflows/go.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 53bbb1d6b6e..6c7b168cca5 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -43,11 +43,12 @@ jobs: - run: git diff --exit-code - name: goheader + if: ${{ github.event_name == 'pull_request' }} # The goheader linter is only enabled in the CI so that it runs only on modified or new files # (see only-new-issues: true). It is disabled in .golangci.yml because # golangci-lint running locally is not aware of new/modified files compared to the base # commit of a pull request, and we want to avoid reporting invalid goheader errors. - uses: golangci/golangci-lint-action@ec5d18412c0aeab7936cb16880d708ba2a64e1ae # v6.2.0 since v6.3.1 does not handle `only-new-issues` correctly + uses: golangci/golangci-lint-action@v6 with: version: v1.60 only-new-issues: true