Skip to content
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

add ci-lint gha for chaincli #10732

Merged
merged 36 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
61cf1e8
add ci-lint gha for chaincli
momentmaker Sep 20, 2023
c4b5102
remove composite setup-go action
momentmaker Sep 20, 2023
a866f5c
fix go build path
momentmaker Sep 20, 2023
9387047
use GITHUB_WORKSPACE for absolute path
momentmaker Sep 20, 2023
cf11b3c
use cd instead direct build
momentmaker Sep 20, 2023
4d378c1
fix build bug
momentmaker Sep 20, 2023
8289f0d
golangci-lint target only core/scripts/chaincli
momentmaker Sep 20, 2023
918fee2
fix args
momentmaker Sep 20, 2023
43c59b0
use working-directory flag
momentmaker Sep 20, 2023
f81431b
add back remove flags
momentmaker Sep 20, 2023
d8f7709
change job name
momentmaker Sep 20, 2023
d94172d
fix report stored path
momentmaker Sep 20, 2023
922a42d
Merge branch 'develop' into feature/re-1696-add-ci-lint-chaincli
momentmaker Sep 21, 2023
3b80c2c
revert removal of asset change
momentmaker Sep 21, 2023
35e5281
add core/web/assets/index.html to workflow step
momentmaker Sep 22, 2023
821833a
Merge branch 'develop' into feature/re-1696-add-ci-lint-chaincli
momentmaker Sep 22, 2023
90d1344
Merge branch 'develop' into feature/re-1696-add-ci-lint-chaincli
momentmaker Sep 22, 2023
28c9eb0
refactor: update setup-go@v4 and cleaner implementation
momentmaker Sep 22, 2023
87da816
Merge branch 'develop' into feature/re-1696-add-ci-lint-chaincli
momentmaker Sep 22, 2023
f400682
name match
momentmaker Sep 22, 2023
832b007
Merge branch 'develop' into feature/re-1696-add-ci-lint-chaincli
momentmaker Sep 22, 2023
2a0b83f
refactor golangci-lint into a composite action
momentmaker Sep 22, 2023
0f2c330
add actions/checkout
momentmaker Sep 22, 2023
10ac31f
add shell: bash
momentmaker Sep 22, 2023
0a3f685
add shell: bash
momentmaker Sep 22, 2023
a0f767f
fix bugs
momentmaker Sep 22, 2023
cb76f8c
more fixes
momentmaker Sep 22, 2023
35337dd
fix key
momentmaker Sep 22, 2023
3aa9ed8
fix key
momentmaker Sep 22, 2023
95d3de4
add working-directory
momentmaker Sep 22, 2023
f9dbd75
correct place
momentmaker Sep 22, 2023
7fb2d9b
remove go-directory in setup-go
momentmaker Sep 22, 2023
d14bc21
refactor core-ci to use ci-golang-lint composite action
momentmaker Sep 22, 2023
ce530aa
rename composite gha ci-golang-lint to golangci-lint
momentmaker Sep 25, 2023
5bb5966
Merge branch 'develop' into feature/re-1696-add-ci-lint-chaincli
momentmaker Sep 25, 2023
ad85da9
Merge branch 'develop' into feature/re-1696-add-ci-lint-chaincli
momentmaker Oct 10, 2023
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
77 changes: 77 additions & 0 deletions .github/actions/golangci-lint/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: CI lint for Golang
description: Runs CI lint for Golang
inputs:
# general inputs
name:
description: Name of the lint action
default: lint
go-directory:
description: Go 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:
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
shell: bash
run: mkdir -p core/web/assets && touch core/web/assets/index.html
- name: Build binary
if: ${{ inputs.go-directory == '.' }}
shell: bash
run: go build ./...
- name: Build binary
if: ${{ inputs.go-directory != '.' }}
working-directory: ${{ inputs.go-directory }}
shell: bash
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
working-directory: ${{ inputs.go-directory }}
- name: Store lint report artifact
if: always()
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with:
name: golangci-lint-report
path: ${{ inputs.go-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
87 changes: 49 additions & 38 deletions .github/actions/setup-go/action.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,64 @@
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"
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:
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
shell: bash
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-path.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-path.output.path) }}-${{ steps.branch-name.outputs.current_branch }}
restore-keys: |
${{ runner.os }}-gobuild-${{ inputs.cache-version }}-${{ hashFiles(steps.go-module-path.output.path) }}-
${{ runner.os }}-gobuild-${{ inputs.cache-version }}-
26 changes: 26 additions & 0 deletions .github/workflows/ci-chaincli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: chaincli CI

on:
push:
paths:
- "core/scripts/chaincli/**"
pull_request:
paths:
- "core/scripts/chaincli/**"

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: Golang Lint
uses: ./.github/actions/golangci-lint
with:
name: chaincli-lint
go-directory: core/scripts/chaincli
momentmaker marked this conversation as resolved.
Show resolved Hide resolved
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 }}
33 changes: 4 additions & 29 deletions .github/workflows/ci-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/golangci-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:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
5 changes: 2 additions & 3 deletions core/scripts/chaincli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
```
```
Loading