From 61cf1e898b0512d9e145e033867858b2ae6a284a Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Wed, 20 Sep 2023 11:37:53 -0500 Subject: [PATCH 01/29] add ci-lint gha for chaincli --- .github/workflows/ci-chaincli.yml | 44 +++++++++++++++++++++++++++++++ core/scripts/chaincli/README.md | 5 ++-- 2 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci-chaincli.yml diff --git a/.github/workflows/ci-chaincli.yml b/.github/workflows/ci-chaincli.yml new file mode 100644 index 00000000000..5b1bfd58dc5 --- /dev/null +++ b/.github/workflows/ci-chaincli.yml @@ -0,0 +1,44 @@ +name: chaincli CI + +on: + push: + paths: + - "core/scripts/chaincli/**" + pull_request: + paths: + - "core/scripts/chaincli/**" + +jobs: + ci-lint: + name: ci-lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: ./.github/actions/setup-go + - name: Build binary for chaincli + run: go build ./core/scripts/chaincli + - name: golangci-lint + uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 + with: + version: v1.54.2 + # We already cache these directories in setup-go + skip-pkg-cache: true + skip-build-cache: true + # only-new-issues is only applicable to PRs, otherwise it is always set to false + only-new-issues: true + args: --out-format colored-line-number,checkstyle:golangci-lint-report.xml + - name: Store lint report artifact + if: always() + uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 + with: + name: golangci-lint-report + path: golangci-lint-report.xml + - name: Collect Metrics + if: always() + uses: smartcontractkit/push-gha-metrics-action@d2c2b7bdc9012651230b2608a1bcb0c48538b6ec + with: + basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }} + hostname: ${{ secrets.GRAFANA_CLOUD_HOST }} + this-job-name: lint + continue-on-error: true diff --git a/core/scripts/chaincli/README.md b/core/scripts/chaincli/README.md index c4c48c899da..348153b057e 100644 --- a/core/scripts/chaincli/README.md +++ b/core/scripts/chaincli/README.md @@ -14,8 +14,7 @@ Before starting, you will need: The example .env in this repo is for the Polygon Mumbai testnet. You can use [this faucet](https://faucets.chain.link/mumbai) to send testnet LINK to your wallet ahead of executing the next steps ->Note: Be careful with your key. When using testnets, it's best to use a separate ->account that does not hold real funds. +>Note: Be careful with your key. When using testnets, it's best to use a separate account that does not hold real funds. ## Run OCR2Keepers locally @@ -121,4 +120,4 @@ You can use the `grep` and `grepv` flags to filter log lines, e.g. to only show ```shell ./chaincli keeper logs --grep keepers-plugin -``` \ No newline at end of file +``` From c4b51025dee23ad46e02077587328cd76f43f872 Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Wed, 20 Sep 2023 11:54:16 -0500 Subject: [PATCH 02/29] remove composite setup-go action --- .github/workflows/ci-chaincli.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-chaincli.yml b/.github/workflows/ci-chaincli.yml index 5b1bfd58dc5..3d1143149e0 100644 --- a/.github/workflows/ci-chaincli.yml +++ b/.github/workflows/ci-chaincli.yml @@ -15,7 +15,10 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Go - uses: ./.github/actions/setup-go + uses: actions/setup-go@v3 + with: + go-version-file: "core/scripts/go.mod" + cache: true - name: Build binary for chaincli run: go build ./core/scripts/chaincli - name: golangci-lint From a866f5c18ce16628296b9a902a7e61b29a62d87d Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Wed, 20 Sep 2023 12:02:24 -0500 Subject: [PATCH 03/29] fix go build path --- .github/workflows/ci-chaincli.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-chaincli.yml b/.github/workflows/ci-chaincli.yml index 3d1143149e0..dd47e1c388b 100644 --- a/.github/workflows/ci-chaincli.yml +++ b/.github/workflows/ci-chaincli.yml @@ -20,7 +20,7 @@ jobs: go-version-file: "core/scripts/go.mod" cache: true - name: Build binary for chaincli - run: go build ./core/scripts/chaincli + run: go build ../core/scripts/chaincli - name: golangci-lint uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 with: From 9387047f7563766398f5b5d2ca9d978f2a90ebdd Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Wed, 20 Sep 2023 12:46:01 -0500 Subject: [PATCH 04/29] use GITHUB_WORKSPACE for absolute path --- .github/workflows/ci-chaincli.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-chaincli.yml b/.github/workflows/ci-chaincli.yml index dd47e1c388b..1325068a671 100644 --- a/.github/workflows/ci-chaincli.yml +++ b/.github/workflows/ci-chaincli.yml @@ -20,7 +20,7 @@ jobs: go-version-file: "core/scripts/go.mod" cache: true - name: Build binary for chaincli - run: go build ../core/scripts/chaincli + run: go build $GITHUB_WORKSPACE/core/scripts/chaincli - name: golangci-lint uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 with: From cf11b3c33f26e2850767daa763ffbba1976840dc Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Wed, 20 Sep 2023 13:12:46 -0500 Subject: [PATCH 05/29] use cd instead direct build --- .github/workflows/ci-chaincli.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-chaincli.yml b/.github/workflows/ci-chaincli.yml index 1325068a671..b7f3c740ba6 100644 --- a/.github/workflows/ci-chaincli.yml +++ b/.github/workflows/ci-chaincli.yml @@ -20,7 +20,9 @@ jobs: go-version-file: "core/scripts/go.mod" cache: true - name: Build binary for chaincli - run: go build $GITHUB_WORKSPACE/core/scripts/chaincli + run: | + cd core/scripts/chaincli + go build - name: golangci-lint uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 with: From 4d378c1ebc5282fa3216e56e9a504b4bdcf151f9 Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Wed, 20 Sep 2023 13:15:03 -0500 Subject: [PATCH 06/29] fix build bug --- core/web/middleware.go | 1 - 1 file changed, 1 deletion(-) diff --git a/core/web/middleware.go b/core/web/middleware.go index 91c618cecbd..3041b417600 100644 --- a/core/web/middleware.go +++ b/core/web/middleware.go @@ -21,7 +21,6 @@ import ( // inside this module. To achieve this, we direct webpack to output all of the compiled assets // in this module's folder under the "assets" directory. -//go:embed "assets" var uiEmbedFs embed.FS // assetFs is the singleton file system instance that is used to serve the static From 8289f0d3f73a5dde262592c69cb999f5a94add01 Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Wed, 20 Sep 2023 13:28:59 -0500 Subject: [PATCH 07/29] golangci-lint target only core/scripts/chaincli --- .github/workflows/ci-chaincli.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/ci-chaincli.yml b/.github/workflows/ci-chaincli.yml index b7f3c740ba6..4e6b8aa9325 100644 --- a/.github/workflows/ci-chaincli.yml +++ b/.github/workflows/ci-chaincli.yml @@ -27,12 +27,7 @@ jobs: uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 with: version: v1.54.2 - # We already cache these directories in setup-go - skip-pkg-cache: true - skip-build-cache: true - # only-new-issues is only applicable to PRs, otherwise it is always set to false - only-new-issues: true - args: --out-format colored-line-number,checkstyle:golangci-lint-report.xml + args: --config ./core/scripts/chaincli --out-format colored-line-number,checkstyle:golangci-lint-report.xml - name: Store lint report artifact if: always() uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 From 918fee29addc2d4c11a3a31902d606aff44c5e87 Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Wed, 20 Sep 2023 15:42:44 -0500 Subject: [PATCH 08/29] fix args --- .github/workflows/ci-chaincli.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-chaincli.yml b/.github/workflows/ci-chaincli.yml index 4e6b8aa9325..5d9dcb2343f 100644 --- a/.github/workflows/ci-chaincli.yml +++ b/.github/workflows/ci-chaincli.yml @@ -27,7 +27,7 @@ jobs: uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 with: version: v1.54.2 - args: --config ./core/scripts/chaincli --out-format colored-line-number,checkstyle:golangci-lint-report.xml + args: --out-format colored-line-number,checkstyle:golangci-lint-report.xml ./core/scripts/chaincli - name: Store lint report artifact if: always() uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 From 43c59b0101b1822162fb5394d5b1b1d64799b231 Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Wed, 20 Sep 2023 15:59:17 -0500 Subject: [PATCH 09/29] use working-directory flag --- .github/workflows/ci-chaincli.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-chaincli.yml b/.github/workflows/ci-chaincli.yml index 5d9dcb2343f..803841b6ffb 100644 --- a/.github/workflows/ci-chaincli.yml +++ b/.github/workflows/ci-chaincli.yml @@ -27,7 +27,8 @@ jobs: uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 with: version: v1.54.2 - args: --out-format colored-line-number,checkstyle:golangci-lint-report.xml ./core/scripts/chaincli + working-directory: core/scripts/chaincli + args: --out-format colored-line-number,checkstyle:golangci-lint-report.xml - name: Store lint report artifact if: always() uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 From f81431b7f56368c2cb7d06e83f8b7a494bff12fd Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Wed, 20 Sep 2023 16:13:39 -0500 Subject: [PATCH 10/29] add back remove flags --- .github/workflows/ci-chaincli.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci-chaincli.yml b/.github/workflows/ci-chaincli.yml index 803841b6ffb..14e19788bfc 100644 --- a/.github/workflows/ci-chaincli.yml +++ b/.github/workflows/ci-chaincli.yml @@ -28,6 +28,11 @@ jobs: with: version: v1.54.2 working-directory: core/scripts/chaincli + # We already cache these directories in setup-go + skip-pkg-cache: true + skip-build-cache: true + # only-new-issues is only applicable to PRs, otherwise it is always set to false + only-new-issues: true args: --out-format colored-line-number,checkstyle:golangci-lint-report.xml - name: Store lint report artifact if: always() From d8f77095b66e9f561a3aefa5e62325ffdecfd987 Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Wed, 20 Sep 2023 16:40:45 -0500 Subject: [PATCH 11/29] change job name --- .github/workflows/ci-chaincli.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-chaincli.yml b/.github/workflows/ci-chaincli.yml index 14e19788bfc..fa65839d948 100644 --- a/.github/workflows/ci-chaincli.yml +++ b/.github/workflows/ci-chaincli.yml @@ -9,8 +9,8 @@ on: - "core/scripts/chaincli/**" jobs: - ci-lint: - name: ci-lint + golangci: + name: lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From d94172db670d07dbe4cb19dce981a8244bba2127 Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Wed, 20 Sep 2023 17:23:35 -0500 Subject: [PATCH 12/29] fix report stored path --- .github/workflows/ci-chaincli.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-chaincli.yml b/.github/workflows/ci-chaincli.yml index fa65839d948..ef01210c6a4 100644 --- a/.github/workflows/ci-chaincli.yml +++ b/.github/workflows/ci-chaincli.yml @@ -39,7 +39,7 @@ jobs: uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 with: name: golangci-lint-report - path: golangci-lint-report.xml + path: core/scripts/chaincli/golangci-lint-report.xml - name: Collect Metrics if: always() uses: smartcontractkit/push-gha-metrics-action@d2c2b7bdc9012651230b2608a1bcb0c48538b6ec From 3b80c2c76d663097e0b1326c958f4f6e38c47705 Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Thu, 21 Sep 2023 17:26:33 -0500 Subject: [PATCH 13/29] revert removal of asset change --- core/web/middleware.go | 1 + 1 file changed, 1 insertion(+) diff --git a/core/web/middleware.go b/core/web/middleware.go index 3041b417600..91c618cecbd 100644 --- a/core/web/middleware.go +++ b/core/web/middleware.go @@ -21,6 +21,7 @@ import ( // inside this module. To achieve this, we direct webpack to output all of the compiled assets // in this module's folder under the "assets" directory. +//go:embed "assets" var uiEmbedFs embed.FS // assetFs is the singleton file system instance that is used to serve the static From 35e5281d684adce20e490f2c3802425afa0dc05c Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Fri, 22 Sep 2023 00:42:15 -0500 Subject: [PATCH 14/29] add core/web/assets/index.html to workflow step --- .github/workflows/ci-chaincli.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci-chaincli.yml b/.github/workflows/ci-chaincli.yml index ef01210c6a4..a2b27886c3c 100644 --- a/.github/workflows/ci-chaincli.yml +++ b/.github/workflows/ci-chaincli.yml @@ -19,6 +19,8 @@ jobs: with: go-version-file: "core/scripts/go.mod" cache: true + - name: Touching core/web/assets/index.html + run: mkdir -p core/web/assets && touch core/web/assets/index.html - name: Build binary for chaincli run: | cd core/scripts/chaincli From 28c9eb092e8a20b2f1a88b6bb46f45a1ec9ad996 Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Fri, 22 Sep 2023 08:23:38 -0500 Subject: [PATCH 15/29] refactor: update setup-go@v4 and cleaner implementation --- .github/workflows/ci-chaincli.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-chaincli.yml b/.github/workflows/ci-chaincli.yml index a2b27886c3c..37658d40873 100644 --- a/.github/workflows/ci-chaincli.yml +++ b/.github/workflows/ci-chaincli.yml @@ -15,16 +15,15 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: go-version-file: "core/scripts/go.mod" cache: true - name: Touching core/web/assets/index.html run: mkdir -p core/web/assets && touch core/web/assets/index.html - name: Build binary for chaincli - run: | - cd core/scripts/chaincli - go build + working-directory: core/scripts/chaincli + run: go build - name: golangci-lint uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 with: @@ -48,5 +47,5 @@ jobs: with: basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }} hostname: ${{ secrets.GRAFANA_CLOUD_HOST }} - this-job-name: lint + this-job-name: chaincli-lint continue-on-error: true From f400682038d1fc3e6bae292d4a0a0968ea3d1e0d Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Fri, 22 Sep 2023 09:27:50 -0500 Subject: [PATCH 16/29] name match --- .github/workflows/ci-chaincli.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-chaincli.yml b/.github/workflows/ci-chaincli.yml index 37658d40873..2d03ed4104f 100644 --- a/.github/workflows/ci-chaincli.yml +++ b/.github/workflows/ci-chaincli.yml @@ -10,7 +10,7 @@ on: jobs: golangci: - name: lint + name: chaincli-lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 2a0b83fca8df8bf4e7b00014dd5823cfd56922a1 Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Fri, 22 Sep 2023 15:55:05 -0500 Subject: [PATCH 17/29] refactor golangci-lint into a composite action --- .github/actions/ci-golang-lint/action.yml | 74 +++++++++++++++++++ .github/actions/setup-go/action.yml | 90 +++++++++++++---------- .github/workflows/ci-chaincli.yml | 42 ++--------- 3 files changed, 134 insertions(+), 72 deletions(-) create mode 100644 .github/actions/ci-golang-lint/action.yml diff --git a/.github/actions/ci-golang-lint/action.yml b/.github/actions/ci-golang-lint/action.yml new file mode 100644 index 00000000000..95913fdf462 --- /dev/null +++ b/.github/actions/ci-golang-lint/action.yml @@ -0,0 +1,74 @@ +name: CI lint for Golang +description: Runs CI lint for Golang +inputs: + # general inputs + name: + description: Name of the lint action + default: lint + working-directory: + description: Directory to run commands from + default: "." + # setup-go inputs + only-modules: + description: Set to 'true' to only cache modules + default: "false" + cache-version: + description: Set this to cache bust + default: "1" + go-version-file: + description: Set where the go version file is located at + default: "go.mod" + go-module-file: + description: Set where the go module file is located at + default: "go.sum" + # grafana cloud inputs + gc-host: + description: "grafana cloud hostname" + gc-basic-auth: + description: "grafana cloud basic auth" + +runs: + using: composite + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: ./.github/actions/setup-go + with: + working-directory: ${{ inputs.working-directory }} + only-modules: ${{ inputs.only-modules }} + cache-version: ${{ inputs.cache-version }} + go-version-file: ${{ inputs.go-version-file }} + go-module-file: ${{ inputs.go-module-file }} + - name: Touching core/web/assets/index.html + run: mkdir -p core/web/assets && touch core/web/assets/index.html + - name: Build binary + if: ${{ inputs.working-directory == '.' }} + run: go build ./... + - name: Build binary + if: ${{ inputs.working-directory != '.' }} + working-directory: ${{ inputs.working-directory }} + run: go build + - name: golangci-lint + uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 + with: + version: v1.54.2 + # We already cache these directories in setup-go + skip-pkg-cache: true + skip-build-cache: true + # only-new-issues is only applicable to PRs, otherwise it is always set to false + only-new-issues: true + args: --out-format colored-line-number,checkstyle:golangci-lint-report.xml + - name: Store lint report artifact + if: always() + uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 + with: + name: golangci-lint-report + path: ${{ inputs.working-directory }}/golangci-lint-report.xml + - name: Collect Metrics + if: always() + uses: smartcontractkit/push-gha-metrics-action@d2c2b7bdc9012651230b2608a1bcb0c48538b6ec + with: + basic-auth: ${{ inputs.gc-basic-auth }} + hostname: ${{ inputs.gc-host }} + this-job-name: ${{ inputs.name }} + continue-on-error: true diff --git a/.github/actions/setup-go/action.yml b/.github/actions/setup-go/action.yml index 996fb4ac507..d14eaaec6b9 100644 --- a/.github/actions/setup-go/action.yml +++ b/.github/actions/setup-go/action.yml @@ -1,53 +1,67 @@ name: Setup Go -description: Setup Golang with efficient caching +description: Setup Golang with efficient caching inputs: only-modules: description: Set to 'true' to only cache modules - default: 'false' + default: "false" cache-version: description: Set this to cache bust default: "1" + working-directory: + description: Set the working directory to run commands from + default: "." + go-version-file: + description: Set where the go version file is located at + default: "go.mod" + go-module-file: + description: Set where the go module file is located at + default: "go.sum" runs: using: composite steps: - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version-file: "go.mod" - cache: false + - name: Set up Go + uses: actions/setup-go@v4 + with: + working-directory: ${{ inputs.working-directory }} + go-version-file: ${{ inputs.go-version-file }} + cache: false - - name: Get branch name - if: ${{ inputs.only-modules == 'false' }} - id: branch-name - uses: tj-actions/branch-names@2e5354c6733793113f416314375826df030ada23 #v6.5 + - name: Get branch name + if: ${{ inputs.only-modules == 'false' }} + id: branch-name + uses: tj-actions/branch-names@2e5354c6733793113f416314375826df030ada23 #v6.5 - - name: Set go cache keys - shell: bash - id: go-cache-dir - run: | - echo "gomodcache=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT - echo "gobuildcache=$(go env GOCACHE)" >> $GITHUB_OUTPUT + - name: Set go cache keys + shell: bash + id: go-cache-dir + run: | + echo "gomodcache=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT + echo "gobuildcache=$(go env GOCACHE)" >> $GITHUB_OUTPUT - - uses: actions/cache@v3 - name: Cache Go Modules - with: - path: | - ${{ steps.go-cache-dir.outputs.gomodcache }} - # The lifetime of go modules is much higher than the build outputs, so we increase cache efficiency - # here by not having the primary key contain the branch name - key: ${{ runner.os }}-gomod-${{ inputs.cache-version }}-${{ hashFiles('./go.sum') }} - restore-keys: | - ${{ runner.os }}-gomod-${{ inputs.cache-version }}- + - name: Set go module path + id: go-module-path + run: echo "path=./${{ inputs.go-module-file }}" >> $GITHUB_OUTPUT - - uses: actions/cache@v3 - if: ${{ inputs.only-modules == 'false' }} - name: Cache Go Build Outputs - with: - path: | - ${{ steps.go-cache-dir.outputs.gobuildcache }} - # The lifetime of go build outputs is pretty short, so we make our primary cache key be the branch name - key: ${{ runner.os }}-gobuild-${{ inputs.cache-version }}-${{ hashFiles('./go.sum') }}-${{ steps.branch-name.outputs.current_branch }} - restore-keys: | - ${{ runner.os }}-gobuild-${{ inputs.cache-version }}-${{ hashFiles('./go.sum') }}- - ${{ runner.os }}-gobuild-${{ inputs.cache-version }}- + - uses: actions/cache@v3 + name: Cache Go Modules + with: + path: | + ${{ steps.go-cache-dir.outputs.gomodcache }} + # The lifetime of go modules is much higher than the build outputs, so we increase cache efficiency + # here by not having the primary key contain the branch name + key: ${{ runner.os }}-gomod-${{ inputs.cache-version }}-${{ hashFiles(steps.go-module-file.output.path) }} + restore-keys: | + ${{ runner.os }}-gomod-${{ inputs.cache-version }}- + + - uses: actions/cache@v3 + if: ${{ inputs.only-modules == 'false' }} + name: Cache Go Build Outputs + with: + path: | + ${{ steps.go-cache-dir.outputs.gobuildcache }} + # The lifetime of go build outputs is pretty short, so we make our primary cache key be the branch name + key: ${{ runner.os }}-gobuild-${{ inputs.cache-version }}-${{ hashFiles(steps.go-module-file.output.path) }}-${{ steps.branch-name.outputs.current_branch }} + restore-keys: | + ${{ runner.os }}-gobuild-${{ inputs.cache-version }}-${{ hashFiles(steps.go-module-file.output.path) }}- + ${{ runner.os }}-gobuild-${{ inputs.cache-version }}- diff --git a/.github/workflows/ci-chaincli.yml b/.github/workflows/ci-chaincli.yml index 2d03ed4104f..7c526893118 100644 --- a/.github/workflows/ci-chaincli.yml +++ b/.github/workflows/ci-chaincli.yml @@ -10,42 +10,16 @@ on: jobs: golangci: + if: ${{ github.event_name == 'pull_request' || github.event_name == 'schedule' }} name: chaincli-lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Setup Go - uses: actions/setup-go@v4 + - name: Golang Lint + uses: ./.github/actions/ci-golang-lint with: - go-version-file: "core/scripts/go.mod" - cache: true - - name: Touching core/web/assets/index.html - run: mkdir -p core/web/assets && touch core/web/assets/index.html - - name: Build binary for chaincli - working-directory: core/scripts/chaincli - run: go build - - name: golangci-lint - uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 - with: - version: v1.54.2 + name: chaincli-lint working-directory: core/scripts/chaincli - # We already cache these directories in setup-go - skip-pkg-cache: true - skip-build-cache: true - # only-new-issues is only applicable to PRs, otherwise it is always set to false - only-new-issues: true - args: --out-format colored-line-number,checkstyle:golangci-lint-report.xml - - name: Store lint report artifact - if: always() - uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 - with: - name: golangci-lint-report - path: core/scripts/chaincli/golangci-lint-report.xml - - name: Collect Metrics - if: always() - uses: smartcontractkit/push-gha-metrics-action@d2c2b7bdc9012651230b2608a1bcb0c48538b6ec - with: - basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }} - hostname: ${{ secrets.GRAFANA_CLOUD_HOST }} - this-job-name: chaincli-lint - continue-on-error: true + go-version-file: core/scripts/go.mod + go-module-file: core/scripts/go.sum + gc-basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }} + gc-host: ${{ secrets.GRAFANA_CLOUD_HOST }} From 0f2c330003a76e7f3722eed3a4985eb471f89683 Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Fri, 22 Sep 2023 15:56:44 -0500 Subject: [PATCH 18/29] add actions/checkout --- .github/workflows/ci-chaincli.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-chaincli.yml b/.github/workflows/ci-chaincli.yml index 7c526893118..d68c0038fc3 100644 --- a/.github/workflows/ci-chaincli.yml +++ b/.github/workflows/ci-chaincli.yml @@ -14,6 +14,7 @@ jobs: name: chaincli-lint runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 - name: Golang Lint uses: ./.github/actions/ci-golang-lint with: From 10ac31fa339399a12a0910239684c87987341c9c Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Fri, 22 Sep 2023 16:00:35 -0500 Subject: [PATCH 19/29] add shell: bash --- .github/actions/ci-golang-lint/action.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/actions/ci-golang-lint/action.yml b/.github/actions/ci-golang-lint/action.yml index 95913fdf462..7e68a838e17 100644 --- a/.github/actions/ci-golang-lint/action.yml +++ b/.github/actions/ci-golang-lint/action.yml @@ -40,13 +40,16 @@ runs: go-version-file: ${{ inputs.go-version-file }} go-module-file: ${{ inputs.go-module-file }} - name: Touching core/web/assets/index.html + shell: bash run: mkdir -p core/web/assets && touch core/web/assets/index.html - name: Build binary if: ${{ inputs.working-directory == '.' }} + shell: bash run: go build ./... - name: Build binary if: ${{ inputs.working-directory != '.' }} working-directory: ${{ inputs.working-directory }} + shell: bash run: go build - name: golangci-lint uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 From 0a3f6853b5554c34dfbff77bc2b94328a94db0ef Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Fri, 22 Sep 2023 16:02:34 -0500 Subject: [PATCH 20/29] add shell: bash --- .github/actions/setup-go/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/setup-go/action.yml b/.github/actions/setup-go/action.yml index d14eaaec6b9..a60f17c53a3 100644 --- a/.github/actions/setup-go/action.yml +++ b/.github/actions/setup-go/action.yml @@ -41,6 +41,7 @@ runs: - name: Set go module path id: go-module-path + shell: bash run: echo "path=./${{ inputs.go-module-file }}" >> $GITHUB_OUTPUT - uses: actions/cache@v3 From a0f767ff3c082faba333ae8b619d455a11b3de7a Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Fri, 22 Sep 2023 16:15:35 -0500 Subject: [PATCH 21/29] fix bugs --- .github/actions/setup-go/action.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/actions/setup-go/action.yml b/.github/actions/setup-go/action.yml index a60f17c53a3..f5ea07bb899 100644 --- a/.github/actions/setup-go/action.yml +++ b/.github/actions/setup-go/action.yml @@ -7,8 +7,8 @@ inputs: cache-version: description: Set this to cache bust default: "1" - working-directory: - description: Set the working directory to run commands from + go-directory: + description: Set the go directory default: "." go-version-file: description: Set where the go version file is located at @@ -23,7 +23,7 @@ runs: - name: Set up Go uses: actions/setup-go@v4 with: - working-directory: ${{ inputs.working-directory }} + working-directory: ${{ inputs.go-directory }} go-version-file: ${{ inputs.go-version-file }} cache: false @@ -51,7 +51,7 @@ runs: ${{ steps.go-cache-dir.outputs.gomodcache }} # The lifetime of go modules is much higher than the build outputs, so we increase cache efficiency # here by not having the primary key contain the branch name - key: ${{ runner.os }}-gomod-${{ inputs.cache-version }}-${{ hashFiles(steps.go-module-file.output.path) }} + key: ${{ runner.os }}-gomod-${{ inputs.cache-version }}-${{ hashFiles(steps.go-module-path.output.path) }} restore-keys: | ${{ runner.os }}-gomod-${{ inputs.cache-version }}- @@ -62,7 +62,7 @@ runs: path: | ${{ steps.go-cache-dir.outputs.gobuildcache }} # The lifetime of go build outputs is pretty short, so we make our primary cache key be the branch name - key: ${{ runner.os }}-gobuild-${{ inputs.cache-version }}-${{ hashFiles(steps.go-module-file.output.path) }}-${{ steps.branch-name.outputs.current_branch }} + key: ${{ runner.os }}-gobuild-${{ inputs.cache-version }}-${{ hashFiles(steps.go-module-path.output.path) }}-${{ steps.branch-name.outputs.current_branch }} restore-keys: | - ${{ runner.os }}-gobuild-${{ inputs.cache-version }}-${{ hashFiles(steps.go-module-file.output.path) }}- + ${{ runner.os }}-gobuild-${{ inputs.cache-version }}-${{ hashFiles(steps.go-module-path.output.path) }}- ${{ runner.os }}-gobuild-${{ inputs.cache-version }}- From cb76f8cdc6ff1e087a01f803b680e860068eb721 Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Fri, 22 Sep 2023 16:23:27 -0500 Subject: [PATCH 22/29] more fixes --- .github/actions/ci-golang-lint/action.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/actions/ci-golang-lint/action.yml b/.github/actions/ci-golang-lint/action.yml index 7e68a838e17..349649d7d49 100644 --- a/.github/actions/ci-golang-lint/action.yml +++ b/.github/actions/ci-golang-lint/action.yml @@ -5,8 +5,8 @@ inputs: name: description: Name of the lint action default: lint - working-directory: - description: Directory to run commands from + go-directory: + description: Go directory to run commands from default: "." # setup-go inputs only-modules: @@ -34,7 +34,7 @@ runs: - name: Setup Go uses: ./.github/actions/setup-go with: - working-directory: ${{ inputs.working-directory }} + go-directory: ${{ inputs.go-directory }} only-modules: ${{ inputs.only-modules }} cache-version: ${{ inputs.cache-version }} go-version-file: ${{ inputs.go-version-file }} @@ -43,12 +43,12 @@ runs: shell: bash run: mkdir -p core/web/assets && touch core/web/assets/index.html - name: Build binary - if: ${{ inputs.working-directory == '.' }} + if: ${{ inputs.go-directory == '.' }} shell: bash run: go build ./... - name: Build binary - if: ${{ inputs.working-directory != '.' }} - working-directory: ${{ inputs.working-directory }} + if: ${{ inputs.go-directory != '.' }} + go-directory: ${{ inputs.go-directory }} shell: bash run: go build - name: golangci-lint @@ -66,7 +66,7 @@ runs: uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 with: name: golangci-lint-report - path: ${{ inputs.working-directory }}/golangci-lint-report.xml + path: ${{ inputs.go-directory }}/golangci-lint-report.xml - name: Collect Metrics if: always() uses: smartcontractkit/push-gha-metrics-action@d2c2b7bdc9012651230b2608a1bcb0c48538b6ec From 35337ddd0fdb3cee8d75878dd9df58db141d7b2b Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Fri, 22 Sep 2023 16:28:07 -0500 Subject: [PATCH 23/29] fix key --- .github/actions/ci-golang-lint/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/ci-golang-lint/action.yml b/.github/actions/ci-golang-lint/action.yml index 349649d7d49..315c8afdc1a 100644 --- a/.github/actions/ci-golang-lint/action.yml +++ b/.github/actions/ci-golang-lint/action.yml @@ -48,7 +48,7 @@ runs: run: go build ./... - name: Build binary if: ${{ inputs.go-directory != '.' }} - go-directory: ${{ inputs.go-directory }} + working-directory: ${{ inputs.go-directory }} shell: bash run: go build - name: golangci-lint From 3aa9ed84f83d5a1de329a0ebb6a354a73392ceac Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Fri, 22 Sep 2023 16:32:49 -0500 Subject: [PATCH 24/29] fix key --- .github/workflows/ci-chaincli.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-chaincli.yml b/.github/workflows/ci-chaincli.yml index d68c0038fc3..54781e09352 100644 --- a/.github/workflows/ci-chaincli.yml +++ b/.github/workflows/ci-chaincli.yml @@ -19,7 +19,7 @@ jobs: uses: ./.github/actions/ci-golang-lint with: name: chaincli-lint - working-directory: core/scripts/chaincli + go-directory: core/scripts/chaincli go-version-file: core/scripts/go.mod go-module-file: core/scripts/go.sum gc-basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }} From 95d3de4ffe8cdc3fa450ee36f3bb138a94f86022 Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Fri, 22 Sep 2023 16:50:01 -0500 Subject: [PATCH 25/29] add working-directory --- .github/actions/ci-golang-lint/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/ci-golang-lint/action.yml b/.github/actions/ci-golang-lint/action.yml index 315c8afdc1a..ca3a9dbb0f8 100644 --- a/.github/actions/ci-golang-lint/action.yml +++ b/.github/actions/ci-golang-lint/action.yml @@ -53,6 +53,7 @@ runs: run: go build - name: golangci-lint uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 + working-directory: ${{ inputs.go-directory }} with: version: v1.54.2 # We already cache these directories in setup-go From f9dbd75075fee5d672aa8a7c02f60ed00deafe49 Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Fri, 22 Sep 2023 16:53:38 -0500 Subject: [PATCH 26/29] correct place --- .github/actions/ci-golang-lint/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/ci-golang-lint/action.yml b/.github/actions/ci-golang-lint/action.yml index ca3a9dbb0f8..906e4b2bc9d 100644 --- a/.github/actions/ci-golang-lint/action.yml +++ b/.github/actions/ci-golang-lint/action.yml @@ -53,7 +53,6 @@ runs: run: go build - name: golangci-lint uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 - working-directory: ${{ inputs.go-directory }} with: version: v1.54.2 # We already cache these directories in setup-go @@ -62,6 +61,7 @@ runs: # only-new-issues is only applicable to PRs, otherwise it is always set to false only-new-issues: true args: --out-format colored-line-number,checkstyle:golangci-lint-report.xml + working-directory: ${{ inputs.go-directory }} - name: Store lint report artifact if: always() uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 From 7fb2d9bcb9e9eb9a0d4ddf9ca4f1e1d334abae3e Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Fri, 22 Sep 2023 17:00:14 -0500 Subject: [PATCH 27/29] remove go-directory in setup-go --- .github/actions/ci-golang-lint/action.yml | 1 - .github/actions/setup-go/action.yml | 4 ---- 2 files changed, 5 deletions(-) diff --git a/.github/actions/ci-golang-lint/action.yml b/.github/actions/ci-golang-lint/action.yml index 906e4b2bc9d..c8c44262594 100644 --- a/.github/actions/ci-golang-lint/action.yml +++ b/.github/actions/ci-golang-lint/action.yml @@ -34,7 +34,6 @@ runs: - name: Setup Go uses: ./.github/actions/setup-go with: - go-directory: ${{ inputs.go-directory }} only-modules: ${{ inputs.only-modules }} cache-version: ${{ inputs.cache-version }} go-version-file: ${{ inputs.go-version-file }} diff --git a/.github/actions/setup-go/action.yml b/.github/actions/setup-go/action.yml index f5ea07bb899..eba01521068 100644 --- a/.github/actions/setup-go/action.yml +++ b/.github/actions/setup-go/action.yml @@ -7,9 +7,6 @@ inputs: cache-version: description: Set this to cache bust default: "1" - go-directory: - description: Set the go directory - default: "." go-version-file: description: Set where the go version file is located at default: "go.mod" @@ -23,7 +20,6 @@ runs: - name: Set up Go uses: actions/setup-go@v4 with: - working-directory: ${{ inputs.go-directory }} go-version-file: ${{ inputs.go-version-file }} cache: false From d14bc21b7e52f6acb7020ed107b1006c76a1f86f Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Fri, 22 Sep 2023 17:07:29 -0500 Subject: [PATCH 28/29] refactor core-ci to use ci-golang-lint composite action --- .github/workflows/ci-core.yml | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci-core.yml b/.github/workflows/ci-core.yml index 245b282f2da..cfcfc99b07e 100644 --- a/.github/workflows/ci-core.yml +++ b/.github/workflows/ci-core.yml @@ -23,36 +23,11 @@ jobs: runs-on: ubuntu20.04-8cores-32GB steps: - uses: actions/checkout@v4 - - name: Setup Go - uses: ./.github/actions/setup-go - - name: Touching core/web/assets/index.html - run: mkdir -p core/web/assets && touch core/web/assets/index.html - - name: Build binary - run: go build ./... - - name: golangci-lint - uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 - with: - version: v1.54.2 - # We already cache these directories in setup-go - skip-pkg-cache: true - skip-build-cache: true - # only-new-issues is only applicable to PRs, otherwise it is always set to false - only-new-issues: true - args: --out-format colored-line-number,checkstyle:golangci-lint-report.xml - - name: Store lint report artifact - if: always() - uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 + - name: Golang Lint + uses: ./.github/actions/ci-golang-lint with: - name: golangci-lint-report - path: golangci-lint-report.xml - - name: Collect Metrics - if: always() - uses: smartcontractkit/push-gha-metrics-action@d2c2b7bdc9012651230b2608a1bcb0c48538b6ec - with: - basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }} - hostname: ${{ secrets.GRAFANA_CLOUD_HOST }} - this-job-name: lint - continue-on-error: true + gc-basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }} + gc-host: ${{ secrets.GRAFANA_CLOUD_HOST }} core: strategy: From ce530aa08c37f86d05a2fe3c115a0f2365069fc0 Mon Sep 17 00:00:00 2001 From: Frank Zhu Date: Mon, 25 Sep 2023 14:49:28 -0500 Subject: [PATCH 29/29] rename composite gha ci-golang-lint to golangci-lint --- .github/actions/{ci-golang-lint => golangci-lint}/action.yml | 0 .github/workflows/ci-chaincli.yml | 2 +- .github/workflows/ci-core.yml | 2 +- .gitignore | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename .github/actions/{ci-golang-lint => golangci-lint}/action.yml (100%) diff --git a/.github/actions/ci-golang-lint/action.yml b/.github/actions/golangci-lint/action.yml similarity index 100% rename from .github/actions/ci-golang-lint/action.yml rename to .github/actions/golangci-lint/action.yml diff --git a/.github/workflows/ci-chaincli.yml b/.github/workflows/ci-chaincli.yml index 54781e09352..97225e46557 100644 --- a/.github/workflows/ci-chaincli.yml +++ b/.github/workflows/ci-chaincli.yml @@ -16,7 +16,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Golang Lint - uses: ./.github/actions/ci-golang-lint + uses: ./.github/actions/golangci-lint with: name: chaincli-lint go-directory: core/scripts/chaincli diff --git a/.github/workflows/ci-core.yml b/.github/workflows/ci-core.yml index cfcfc99b07e..c9b85648aaf 100644 --- a/.github/workflows/ci-core.yml +++ b/.github/workflows/ci-core.yml @@ -24,7 +24,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Golang Lint - uses: ./.github/actions/ci-golang-lint + uses: ./.github/actions/golangci-lint with: gc-basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }} gc-host: ${{ secrets.GRAFANA_CLOUD_HOST }} diff --git a/.gitignore b/.gitignore index 4d65eb32a1e..decea4a68a7 100644 --- a/.gitignore +++ b/.gitignore @@ -45,7 +45,7 @@ core/cmd/TestClient_ImportExportP2PKeyBundle_test_key.json output.txt race.* golangci-lint-output.txt -golangci-lint/ +/golangci-lint/ # DB state ./db/