diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 701fe6b4cd2..6c7b168cca5 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -11,78 +11,78 @@ 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: - # 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 - - name: Set up Go - uses: actions/setup-go@v5 + + - run: yamllint -c .yamllint.yml . + + - 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: 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 + + - 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 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 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version-file: "./libevm/tooling/go.mod" - - run: go test ./... - go_generate: - env: - EXCLUDE_REGEX: "ava-labs/libevm/(accounts/usbwallet/trezor)$" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 + - uses: ludeeus/action-shellcheck@2.0.0 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 + scandir: "./libevm" - go_tidy: - runs-on: ubuntu-latest - strategy: - matrix: - dir: ["./", "./libevm/tooling"] - defaults: - run: - 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" + go-version-file: ./libevm/tooling/go.mod + - run: go mod tidy + - run: go generate ./... - run: git diff --exit-code + + - run: go test ./... diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 67428073c80..00000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,65 +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: - # 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 - - 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 - - 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 - - name: Run ShellCheck - uses: ludeeus/action-shellcheck@2.0.0 - with: - scandir: './libevm'