Skip to content

Commit

Permalink
Remove old go-setup action. Replace all go setup actions with composi…
Browse files Browse the repository at this point in the history
…te action that sets up cache for tools

Signed-off-by: Ivan Pavlovic <pavlovic.ivan.26@gmail.com>
  • Loading branch information
pavlovic-ivan authored Jan 24, 2024
1 parent 133aee4 commit 21336a7
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 143 deletions.
20 changes: 20 additions & 0 deletions .github/actions/setup-go-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ inputs:
description: "Version of Go. Default 1.20"
required: false
default: "1.20"
cache-tools:
description: "True/false flag to cache tools"
required: false
default: "false"
outputs:
go-version:
description: "The installed Go version"
Expand All @@ -21,10 +25,26 @@ runs:
go-version: ${{ inputs.go-version }}
check-latest: true
cache: false

- id: cache-info
shell: bash
run: echo path=$(go env GOCACHE) >> $GITHUB_OUTPUT

- uses: actions/cache@v3
with:
path: ${{ steps.cache-info.outputs.path }}
key: ${{ inputs.cache-prefix }}-go-${{ steps.setup-go.outputs.go-version }}-mod-${{ hashFiles('go.sum') }}

- name: Compute tools cache info
if: ${{ inputs.cache-tools == 'true' }}
id: tools-cache-info
run: echo path=$(go env GOPATH)/bin >> $GITHUB_OUTPUT
shell: bash

- name: Setup tools cache
if: ${{ inputs.cache-tools == 'true' }}
uses: actions/cache@v3
id: tools-cache
with:
path: ${{ steps.tools-cache-info.outputs.path }}
key: tools-go-${{ steps.setup-go.outputs.go-version }}-tools-${{ hashFiles('tools.yaml') }}
8 changes: 4 additions & 4 deletions .github/workflows/airflow-operator-release-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ on:
jobs:
run-python-tests:
runs-on: ubuntu-22.04
strategy:
matrix:
go: [ '1.20' ]
steps:
- uses: actions/checkout@v3.3.0
- uses: ./.github/workflows/go-setup
- name: Setup Go
uses: ./.github/actions/setup-go-cache
with:
cache-prefix: run-python-tests
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
Expand Down
31 changes: 8 additions & 23 deletions .github/workflows/airflow-operator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
go: [ '1.20' ]
python: [ '3.8', '3.9', '3.10' ]
include:
- tox-env: 'py38'
Expand All @@ -56,7 +55,10 @@ jobs:
python: '3.10'
steps:
- uses: actions/checkout@v3.3.0
- uses: ./.github/workflows/go-setup
- name: Setup Go
uses: ./.github/actions/setup-go-cache
with:
cache-prefix: airflow-tox
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
Expand All @@ -71,14 +73,6 @@ jobs:
github-token: ${{secrets.GITHUB_TOKEN}}
airflow-integration-tests:
if: github.repository_owner == 'armadaproject'
strategy:
fail-fast: false
matrix:
# WARN(JayF): If we begin attempting to support >1 golang version,
# we'll have to ensure that we don't use the same artifact name for
# both versions in the matrix -- this will lead to them overwriting
# each other.
go: [ '1.20' ]
# As of December 2022, using 8vcpu runners is slower overall,
# due to longer queue times.
runs-on: ubuntu-22.04
Expand All @@ -92,21 +86,12 @@ jobs:
- uses: actions/checkout@v3.3.0
- run: docker buildx create --name ${DOCKER_BUILDX_BUILDER} --driver docker-container --use
- run: docker buildx install
- uses: actions/setup-go@v4
id: setup-go
with:
go-version: ${{ matrix.go }}

- name: Compute tools cache info
id: tools-cache-info
run: echo path=$(go env GOPATH)/bin >> $GITHUB_OUTPUT

- name: Setup tools cache
uses: actions/cache@v3
id: tools-cache
- name: Setup Go
uses: ./.github/actions/setup-go-cache
with:
path: ${{ steps.tools-cache-info.outputs.path }}
key: tools-go-${{ steps.setup-go.outputs.go-version }}-tools-${{ hashFiles('tools.yaml') }}
cache-prefix: airflow-integration-tests
cache-tools: true

- name: Setup and run integration tests
run: |
Expand Down
27 changes: 7 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ jobs:
with:
fetch-depth: 0

- name: Set up Go (no caching)
uses: actions/setup-go@v4
- name: Setup Go
uses: ./.github/actions/setup-go-cache
with:
go-version: '1.20'
cache: false
cache-prefix: prepare

- name: Set up Docker Buildx
id: buildx
Expand Down Expand Up @@ -65,23 +64,11 @@ jobs:
with:
dotnet-version: 7.0.x

- name: Set up Go (no caching)
id: setup-go
uses: actions/setup-go@v4
- name: Setup Go
uses: ./.github/actions/setup-go-cache
with:
go-version: '1.20'
cache: false

- name: Compute tools cache info
id: tools-cache-info
run: echo path=$(go env GOPATH)/bin >> $GITHUB_OUTPUT

- name: Setup tools cache
uses: actions/cache@v3
id: tools-cache
with:
path: ${{ steps.tools-cache-info.outputs.path }}
key: tools-go-${{ steps.setup-go.outputs.go-version }}-tools-${{ hashFiles('tools.yaml') }}
cache-prefix: pack-nuget
cache-tools: true

- name: Install Protoc
uses: arduino/setup-protoc@v2
Expand Down
17 changes: 4 additions & 13 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
fail-fast: false
matrix:
language: [ 'csharp', 'go', 'javascript' ]
go: [ '1.20' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
Expand All @@ -47,19 +46,11 @@ jobs:
version: '23.3'
repo-token: ${{ secrets.GITHUB_TOKEN }}

- uses: ./.github/workflows/go-setup
id: setup-go

- name: Compute tools cache info
id: tools-cache-info
run: echo path=$(go env GOPATH)/bin >> $GITHUB_OUTPUT

- name: Setup tools cache
uses: actions/cache@v3
id: tools-cache
- name: Setup Go
uses: ./.github/actions/setup-go-cache
with:
path: ${{ steps.tools-cache-info.outputs.path }}
key: tools-go-${{ steps.setup-go.outputs.go-version }}-tools-${{ hashFiles('tools.yaml') }}
cache-prefix: analyze
cache-tools: true

- name: Mage Proto
run: go run github.com/magefile/mage@v1.14.0 -v proto
Expand Down
14 changes: 0 additions & 14 deletions .github/workflows/go-setup/action.yml

This file was deleted.

7 changes: 3 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v3.3.0

- name: Set up Go (no caching)
uses: actions/setup-go@v4
- name: Setup Go
uses: ./.github/actions/setup-go-cache
with:
go-version: '1.20'
cache: false
cache-prefix: go-lint

- name: Lint using golangci-lint
uses: golangci/golangci-lint-action@v3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/python-client-release-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ on:
jobs:
run-python-tests:
runs-on: ubuntu-22.04
strategy:
matrix:
go: [ '1.20' ]
steps:
- uses: actions/checkout@v3.3.0
- uses: ./.github/workflows/go-setup
- name: Setup Go
uses: ./.github/actions/setup-go-cache
with:
cache-prefix: run-python-tests
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
Expand Down
31 changes: 8 additions & 23 deletions .github/workflows/python-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
go: [ '1.20' ]
python: [ '3.8', '3.9', '3.10' ]
include:
- tox-env: 'py38'
Expand All @@ -44,7 +43,10 @@ jobs:
python: '3.10'
steps:
- uses: actions/checkout@v3.3.0
- uses: ./.github/workflows/go-setup
- name: Setup Go
uses: ./.github/actions/setup-go-cache
with:
cache-prefix: python-client-tox
- uses: ./.github/workflows/python-tests
with:
python-version: ${{ matrix.python }}
Expand All @@ -54,14 +56,6 @@ jobs:

python-client-integration-tests:
if: github.repository_owner == 'armadaproject'
strategy:
fail-fast: false
matrix:
# WARN(JayF): If we begin attempting to support >1 golang version,
# we'll have to ensure that we don't use the same artifact name for
# both versions in the matrix -- this will lead to them overwriting
# each other.
go: [ '1.20' ]
# As of December 2022, using 8vcpu runners is slower overall,
# due to longer queue times.
runs-on: ubuntu-22.04
Expand All @@ -75,21 +69,12 @@ jobs:
- uses: actions/checkout@v3.3.0
- run: docker buildx create --name ${DOCKER_BUILDX_BUILDER} --driver docker-container --use
- run: docker buildx install
- uses: actions/setup-go@v4
id: setup-go
with:
go-version: ${{ matrix.go }}

- name: Compute tools cache info
id: tools-cache-info
run: echo path=$(go env GOPATH)/bin >> $GITHUB_OUTPUT

- name: Setup tools cache
uses: actions/cache@v3
id: tools-cache
- name: Setup Go
uses: ./.github/actions/setup-go-cache
with:
path: ${{ steps.tools-cache-info.outputs.path }}
key: tools-go-${{ steps.setup-go.outputs.go-version }}-tools-${{ hashFiles('tools.yaml') }}
cache-prefix: python-client-integration-tests
cache-tools: true

- name: Setup and run integration tests
run: |
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@ jobs:
- name: Fetch Git tags
run: git fetch --force --tags

- name: Set up Go (no caching)
uses: actions/setup-go@v4
- name: Setup Go
uses: ./.github/actions/setup-go-cache
with:
go-version: '1.20'
cache: false
cache-prefix: release

- name: Set up Docker Buildx
id: buildx
Expand Down Expand Up @@ -122,4 +121,4 @@ jobs:
TAG: ${{ github.event.workflow_run.head_branch }}
run: |
VERSION=${TAG#v}
dotnet nuget push ./bin/client/DotNet/G-Research.Armada.Client.$VERSION.nupkg ./bin/client/DotNet/ArmadaProject.Io.Client.$VERSION.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
dotnet nuget push ./bin/client/DotNet/G-Research.Armada.Client.$VERSION.nupkg ./bin/client/DotNet/ArmadaProject.Io.Client.$VERSION.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
41 changes: 8 additions & 33 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ jobs:
uses: actions/checkout@v3.3.0

- name: Setup Go
id: setup-go
uses: ./.github/actions/setup-go-cache
with:
cache-prefix: go-unit-tests
Expand Down Expand Up @@ -111,21 +110,10 @@ jobs:
run: docker image prune -af

- name: Setup Go
id: setup-go
uses: ./.github/actions/setup-go-cache
with:
cache-prefix: go-integration-tests

- name: Compute tools cache info
id: tools-cache-info
run: echo path=$(go env GOPATH)/bin >> $GITHUB_OUTPUT

- name: Setup tools cache
uses: actions/cache@v3
id: tools-cache
with:
path: ${{ steps.tools-cache-info.outputs.path }}
key: tools-go-${{ steps.setup-go.outputs.go-version }}-make-${{ hashFiles('tools.yaml') }}
cache-tools: true

- name: Setup Integration Tests
run: go run github.com/magefile/mage@v1.14.0 -v localdev minimal-pulsar
Expand Down Expand Up @@ -174,11 +162,10 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3.3.0

- name: Set up Go (no caching)
uses: actions/setup-go@v4
- name: Setup Go
uses: ./.github/actions/setup-go-cache
with:
go-version: '1.20'
cache: false
cache-prefix: go-mod-up-to-date

- name: Download all Go modules
run: go mod download
Expand Down Expand Up @@ -220,23 +207,11 @@ jobs:
version: '23.3'
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Go (no caching)
uses: actions/setup-go@v4
id: setup-go
with:
go-version: ${{ matrix.go }}
cache: false

- name: Compute tools cache info
id: tools-cache-info
run: echo path=$(go env GOPATH)/bin >> $GITHUB_OUTPUT

- name: Setup tools cache
uses: actions/cache@v3
id: tools-cache
- name: Setup Go
uses: ./.github/actions/setup-go-cache
with:
path: ${{ steps.tools-cache-info.outputs.path }}
key: tools-go-${{ steps.setup-go.outputs.go-version }}-make-${{ hashFiles('tools.yaml') }}
cache-prefix: proto-up-to-date
cache-tools: true

# TODO(JayF): Consider moving this into its own job, that runs under a larger set of circumstances
# since it's possible for this to fail without any go changes being made.
Expand Down

0 comments on commit 21336a7

Please sign in to comment.