-
Notifications
You must be signed in to change notification settings - Fork 618
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reusable workflows for CI simplification
Signed-off-by: apostasie <[email protected]>
- Loading branch information
Showing
10 changed files
with
206 additions
and
736 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
name: lint | ||
# "Hide" the name from the github check status line, as it just clutters the display | ||
name: " " | ||
|
||
on: | ||
push: | ||
|
@@ -7,65 +8,51 @@ on: | |
- 'release/**' | ||
pull_request: | ||
|
||
env: | ||
GO_VERSION: 1.23.x | ||
|
||
jobs: | ||
# Source the common environment | ||
environment: | ||
name: " " | ||
uses: ./.github/workflows/reusable_environment.yml | ||
secrets: inherit | ||
|
||
# Golint task | ||
go: | ||
timeout-minutes: 5 | ||
name: "go | ${{ matrix.goos }} | ${{ matrix.canary }}" | ||
runs-on: "${{ matrix.os }}" | ||
defaults: | ||
run: | ||
shell: bash | ||
needs: environment | ||
# If we do not "collapse" the name, it will display all matrix parameters, which we do not want | ||
name: "golint${{ matrix.hack_to_collapse_name }}" | ||
# Define the matrix we want to lint on: every supported OS, with the current go version, and additionally go canary on linux | ||
strategy: | ||
matrix: | ||
# The GOOS-es we run golint for, with no canary (eg: the base supported GO_VERSION) | ||
goos: [linux, freebsd, windows] | ||
# And no canary | ||
canary: [false] | ||
include: | ||
- os: ubuntu-24.04 | ||
goos: linux | ||
- os: ubuntu-24.04 | ||
goos: freebsd | ||
# FIXME: this is currently failing in a non-sensical way, so, running on linux instead... | ||
# - os: windows-2022 | ||
- os: ubuntu-24.04 | ||
goos: windows | ||
- os: ubuntu-24.04 | ||
goos: linux | ||
# This allows the canary script to select any upcoming golang alpha/beta/RC | ||
canary: go-canary | ||
env: | ||
GOOS: "${{ matrix.goos }}" | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
fetch-depth: 1 | ||
- name: Set GO env | ||
run: | | ||
# If canary is specified, get the latest available golang pre-release instead of the major version | ||
if [ "$canary" != "" ]; then | ||
. ./hack/build-integration-canary.sh | ||
canary::golang::latest | ||
fi | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
check-latest: true | ||
cache: true | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
args: --verbose | ||
# Only run canary on linux (note: the canary script will select any upcoming golang alpha/beta/RC when the `canary` param is set to a non-empty string) | ||
- goos: linux | ||
canary: true | ||
# Call the reusable linter... | ||
uses: ./.github/workflows/reusable_lint_go.yml | ||
# Against the matrix and parameters | ||
with: | ||
goos: ${{ matrix.goos }} | ||
canary: ${{ matrix.canary }} | ||
os: ${{ needs.environment.outputs.HOST_UBUNTU_LTS }} | ||
goversion: ${{ needs.environment.outputs.GO_VERSION }} | ||
timeout-minutes: ${{ needs.environment.outputs.SHORT_TIMEOUT }} | ||
|
||
other: | ||
needs: environment | ||
timeout-minutes: 5 | ||
name: yaml | shell | imports order | ||
# name: yaml | shell | imports order | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
fetch-depth: 1 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
go-version: ${{ needs.environment.outputs.GO_VERSION }} | ||
check-latest: true | ||
cache: true | ||
- name: yaml | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: common_environment | ||
|
||
env: | ||
GO_VERSION: 1.23.x | ||
HOST_UBUNTU_LTS: ubuntu-24.04 | ||
SHORT_TIMEOUT: 5 | ||
# LONG_TIMEOUT: 60 | ||
# REGISTRY_SERVER: ghcr.io | ||
# BUSYBOX_VERSION: 5ad83957fa74aafd061afbfb8da14ce3220659a9 | ||
# REGISTRY_VERSION: v2.8.3 | ||
# CURL_VERSION: 8.11.0_4 | ||
|
||
on: | ||
workflow_call: | ||
outputs: | ||
GO_VERSION: | ||
description: "The major golang version we are targeting" | ||
value: ${{ jobs.environment.outputs.output_go }} | ||
HOST_UBUNTU_LTS: | ||
description: "The major LTS ubuntu host runner we run our tasks on" | ||
value: ${{ jobs.environment.outputs.output_ubuntu_lts }} | ||
SHORT_TIMEOUT: | ||
description: "The timeout for tasks that are supposed to run fast (lint, etc)" | ||
value: ${{ jobs.environment.outputs.output_short_timeout }} | ||
# REGISTRY_SERVER: | ||
# description: "The second output string" | ||
# value: ${{ jobs.environment.outputs.output_registry }} | ||
|
||
jobs: | ||
environment: | ||
name: "environ" | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- id: go | ||
run: echo "GO_VERSION=$GO_VERSION" >> $GITHUB_OUTPUT | ||
- id: ubuntu_lts | ||
run: echo "HOST_UBUNTU_LTS=$HOST_UBUNTU_LTS" >> $GITHUB_OUTPUT | ||
- id: short_timeout | ||
run: echo "SHORT_TIMEOUT=$SHORT_TIMEOUT" >> $GITHUB_OUTPUT | ||
# - id: registry_server | ||
# run: echo "REGISTRY_SERVER=$REGISTRY_SERVER" >> $GITHUB_OUTPUT | ||
outputs: | ||
output_go: ${{ steps.go.outputs.GO_VERSION }} | ||
output_ubuntu_lts: ${{ steps.ubuntu_lts.outputs.HOST_UBUNTU_LTS }} | ||
output_short_timeout: ${{ steps.short_timeout.outputs.SHORT_TIMEOUT }} | ||
# output_registry: ${{ steps.registry.outputs.REGISTRY_SERVER }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# This contains a reusable golint job. | ||
# It will run golangci | ||
# See `inputs` for expected parameters | ||
name: tasks_lint_go | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
os: | ||
required: true | ||
type: string | ||
description: "the host runner we are going to use" | ||
goos: | ||
required: true | ||
type: string | ||
description: "the GOOS we want to lint for (linux/windows/freebsd)" | ||
goversion: | ||
required: true | ||
type: string | ||
description: "the golang version we want to use" | ||
canary: | ||
required: false | ||
type: boolean | ||
default: false | ||
description: "whether we want to try and find an alpha/beta/RC version of golang instead of the default version" | ||
timeout-minutes: | ||
required: false | ||
type: number | ||
default: 100 | ||
description: "the timeout in minutes for this task" | ||
|
||
jobs: | ||
golint: | ||
name: "${{ inputs.goos }} ${{ inputs.canary && 'canary' || inputs.goversion }}" | ||
timeout-minutes: ${{ inputs.timeout-minutes }} | ||
runs-on: ${{ inputs.os }} | ||
defaults: | ||
run: | ||
shell: bash | ||
env: | ||
GOOS: "${{ inputs.goos }}" | ||
GO_VERSION: "${{ inputs.goversion }}" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
- name: Set go version | ||
run: | | ||
# If canary is specified, get the latest available golang pre-release instead of the major version | ||
if [ "${{ inputs.canary }}" == true ]; then | ||
. ./hack/build-integration-canary.sh | ||
canary::golang::latest | ||
fi | ||
echo "WHAT GO VERSION" | ||
env | ||
echo "WHAT GO VERSION DONE" | ||
- name: Install go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
check-latest: true | ||
cache: true | ||
- name: Run golangci-lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
args: --verbose | ||
# Go imports ordering applies to all platforms, so, only run it once, for linux / no canary | ||
- name: Verify imports ordering | ||
if: ${{ inputs.goos == 'linux' && ! inputs.canary }} | ||
run: | | ||
go install -v github.com/incu6us/goimports-reviser/v3@latest | ||
make lint-imports |
Oops, something went wrong.