diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a2e2fb9af6..cf511fd600 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,22 +17,11 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v3.0.2 - - name: Install Go + - name: Setup Go uses: actions/setup-go@v3.2.0 with: - go-version: 1.18.0 - - name: Get Go cache paths - id: go-env - run: | - echo "::set-output name=cache::$(go env GOCACHE)" - echo "::set-output name=modcache::$(go env GOMODCACHE)" - - name: Set up Go cache - uses: actions/cache@v3.0.2 - with: - key: test-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: test-${{ runner.os }}-go- - path: | - ${{ steps.go-env.outputs.cache }} - ${{ steps.go-env.outputs.modcache }} + go-version-file: .go-version + cache: true + cache-dependency-path: '**/go.sum' - name: Run tests run: go test -race go.pact.im/x/... diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a912b6e2c5..ebbbbc302a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,22 +13,11 @@ jobs: - name: Install Go uses: actions/setup-go@v3.2.0 with: - go-version: 1.18.0 - - name: Get Go cache paths - id: go-env - run: | - echo "::set-output name=cache::$(go env GOCACHE)" - echo "::set-output name=modcache::$(go env GOMODCACHE)" - - name: Set up Go cache - uses: actions/cache@v3.0.2 - with: - key: golangci-lint-${{ runner.os }}-go-${{ hashFiles('**/go.mod') }} - restore-keys: golangci-lint-${{ runner.os }}-go- - path: | - ${{ steps.go-env.outputs.cache }} - ${{ steps.go-env.outputs.modcache }} + go-version-file: .go-version + cache: true + cache-dependency-path: '**/go.sum' - name: Install golangci-lint - run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.2 + run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.46.2 - name: Get golangci-lint cache path id: golangci-lint-cache-status run: | @@ -40,44 +29,12 @@ jobs: restore-keys: golangci-lint-${{ runner.os }}-golangci-lint- path: ${{ steps.golangci-lint-cache-status.outputs.dir }} - name: Run golangci-lint - # Note that we filter some packages since they use type parameters and - # currently they are not supported in Go SSA analysis tooling. See also - # https://github.com/golangci/golangci-lint/issues/2649 run: | golangci-lint run --out-format=github-actions -- \ - $(go work edit -json | jq -c -r '[.Use[].DiskPath | select(. != "syncx" and . != "process")] | map_values(. + "/...")[]') - - go-mod-tidy: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3.0.2 - - name: Install Go - uses: actions/setup-go@v3.2.0 - with: - go-version: 1.18.0 - - name: Get Go cache paths - id: go-env - run: | - echo "::set-output name=cache::$(go env GOCACHE)" - echo "::set-output name=modcache::$(go env GOMODCACHE)" - - name: Set up Go cache - uses: actions/cache@v3.0.2 - with: - key: go-mod-tidy-${{ runner.os }}-go-${{ hashFiles('**/go.mod') }} - restore-keys: | - go-mod-tidy-${{ runner.os }}-go- - path: | - ${{ steps.go-env.outputs.cache }} - ${{ steps.go-env.outputs.modcache }} - - name: Run go mod tidy - run: eval "$(go list -m -f '(cd {{printf "%q" .Dir}} && go mod tidy)')" - - name: Check git diff - run: git diff --exit-code + $(go work edit -json | jq -c -r '[.Use[].DiskPath] | map_values(. + "/...")[]') commitlint: runs-on: ubuntu-latest - if: github.actor != 'dependabot[bot]' steps: - name: Checkout code uses: actions/checkout@v3.0.2 diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 742a9a3d66..8f72a1b1b1 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -17,27 +17,13 @@ jobs: - name: Install Go uses: actions/setup-go@v3.2.0 with: - go-version: 1.18.0 - - name: Get Go cache paths - id: go-env - run: | - echo "::set-output name=cache::$(go env GOCACHE)" - echo "::set-output name=modcache::$(go env GOMODCACHE)" - - name: Set up Go cache - uses: actions/cache@v3.0.2 - with: - key: gocache-${{ runner.os }} - restore-keys: gocache- - path: | - ${{ steps.go-env.outputs.cache }} - ${{ steps.go-env.outputs.modcache }} + go-version-file: .go-version + cache: true + cache-dependency-path: '**/go.sum' - name: Install vangen run: go install 4d63.com/vangen@v1.2.0 - name: Install golds - run: go install go101.org/golds@v0.4.8 - # See https://github.com/go101/golds/issues/28 - - name: Warm up Go modules cache - run: go work sync + run: go install go101.org/golds@v0.4.9 - name: Build pages run: | vangen -out build diff --git a/.github/workflows/tidy.yml b/.github/workflows/tidy.yml new file mode 100644 index 0000000000..b6cd1274ca --- /dev/null +++ b/.github/workflows/tidy.yml @@ -0,0 +1,24 @@ +name: Tidy +on: + push: + pull_request: + workflow_dispatch: + +jobs: + check: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3.0.2 + - name: Install Go + uses: actions/setup-go@v3.2.0 + with: + go-version-file: .go-version + cache: true + cache-dependency-path: '**/go.sum' + - name: Update go.sum + run: eval "$(go list -m -f '(cd {{printf "%q" .Dir}} && go mod tidy)')" + - name: Update go.work.sum + run: go work sync + - name: Check git diff + run: git diff --exit-code diff --git a/.go-version b/.go-version new file mode 100644 index 0000000000..b57fc7228b --- /dev/null +++ b/.go-version @@ -0,0 +1 @@ +1.18.2