Skip to content

Commit

Permalink
use a setup job to set a go-version output and use throughout CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ramin committed Nov 3, 2023
1 parent 652a881 commit a7fd301
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/ci_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,29 @@ on:
- major

jobs:
setup:
runs-on: ubuntu-latest
env:
# use consistent go version throughout pipeline here
GO_VERSION: "1.21"
outputs:
go-version: ${{ steps.set-vars.outputs.go-version }}
steps:
- name: Set go version
id: set-vars
run: echo "go-version=${{env.GO_VERSION}}" >> "$GITHUB_OUTPUT"

lint:
needs: [setup]
uses: ./.github/workflows/lint.yml
with:
GO_VERSION: "1.21"
go-version: ${{ needs.setup.outputs.go-version }}

test:
needs: [setup]
uses: ./.github/workflows/test.yml
with:
GO_VERSION: "1.21"
go-version: ${{ needs.setup.outputs.go-version }}

# Make a release if this is a manually trigger job, i.e. workflow_dispatch
release:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: lint
on:
workflow_call:
inputs:
GO_VERSION:
go-version:
description: 'Go version to use'
type: string
required: true
Expand All @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: ${{ inputs.GO_VERSION }}
go-version: ${{ inputs.go-version }}
# This steps sets the GIT_DIFF environment variable to true
# if files defined in PATTERS changed
- uses: technote-space/get-diff-action@v6.1.2
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Tests / Code Coverage
on:
workflow_call:
inputs:
GO_VERSION:
go-version:
description: "Go version to use"
type: string
required: true
Expand All @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: ${{ inputs.GO_VERSION }}
go-version: ${{ inputs.go-version }}
- run: go mod tidy
- name: check for diff
run: git diff --exit-code
Expand All @@ -30,7 +30,7 @@ jobs:
- name: set up go
uses: actions/setup-go@v4
with:
go-version: ${{ inputs.GO_VERSION }}
go-version: ${{ inputs.go-version }}
- name: Run unit test
run: make test
- name: upload coverage report
Expand All @@ -47,6 +47,6 @@ jobs:
- name: set up go
uses: actions/setup-go@v4
with:
go-version: ${{ inputs.GO_VERSION }}
go-version: ${{ inputs.go-version }}
- name: Integration Tests
run: echo "No integration tests yet"

0 comments on commit a7fd301

Please sign in to comment.