Skip to content

Commit

Permalink
(ci) update github actions ci to use a single GO_VERSION variable (#2806
Browse files Browse the repository at this point in the history
)

This sets a single variable (`GO_VERSION`) in the main `ci.yml`
workflow, which will be the single place we set the current go version.
We then run a `setup` job that sets an required output for subsequent
jobs to use, adding:

```
with:
  go-version: ${{ needs.setup.outputs.go-version }}
```

Where we had previously either:

1) duplicated the GO_VERSION env var in that workflow
2) passed in `1.21` or whatever go version explicitly

When the rpc openrpc.json workflow check changes are merged, this will
also prevent another duplication of the go version appearing.

refs #2698
  • Loading branch information
ramin committed Oct 30, 2023
1 parent 8e2aaa4 commit 1552e9e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/ci_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:
- "v*"
pull_request:
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
version:
# Friendly description to be shown in the UI instead of 'name'
Expand All @@ -23,6 +22,20 @@ on:
- major

jobs:
# set up go version for use through pipelines, setting
# variable one time and setting outputs to access passing it
# to other jobs
setup:
runs-on: ubuntu-latest
env:
# upgrade go version throughout pipeline here
GO_VERSION: "1.21"
outputs:
go-version: ${{ steps.set-vars.outputs.go-version }}
steps:
- id: set-vars
run: echo "go-version=${{env.GO_VERSION}}" >> "$GITHUB_OUTPUT"

# Dockerfile Linting
hadolint:
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_lint.yml@v0.2.8 # yamllint disable-line rule:line-length
Expand All @@ -48,7 +61,10 @@ jobs:
markdownlint --config .markdownlint.yaml '**/*.md'
go-ci:
needs: setup
uses: ./.github/workflows/go-ci.yml
with:
go-version: ${{ needs.setup.outputs.go-version }}

# If this was a workflow dispatch event, we need to generate and push a tag
# for goreleaser to grab
Expand Down Expand Up @@ -86,7 +102,7 @@ jobs:
- run: git fetch --force --tags
- uses: actions/setup-go@v4
with:
go-version: 1.21
go-version: ${{ needs.setup.outputs.go-version }}
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v4
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/go-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ name: Go CI

on:
workflow_call:

env:
GO_VERSION: '1.21'
inputs:
go-version:
description: 'Go version'
required: true
type: string

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand All @@ -20,7 +22,7 @@ jobs:

- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
go-version: ${{ inputs.go-version }}

- name: golangci-lint
uses: golangci/golangci-lint-action@v3.7.0
Expand All @@ -38,7 +40,7 @@ jobs:

- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
go-version: ${{ inputs.go-version }}

- run: go mod tidy

Expand All @@ -61,7 +63,7 @@ jobs:
- name: set up go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
go-version: ${{ inputs.go-version }}

- name: run unit tests
run: make test-unit
Expand All @@ -85,7 +87,7 @@ jobs:
- name: set up go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
go-version: ${{ inputs.go-version }}

- name: execute test run
run: make test-unit-race
Expand All @@ -101,7 +103,7 @@ jobs:
- name: set up go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
go-version: ${{ inputs.go-version }}

- name: Swamp Tests
run: make test-swamp
Expand Down

0 comments on commit 1552e9e

Please sign in to comment.