diff --git a/.github/actions/setup-go-cache/action.yml b/.github/actions/setup-go-cache/action.yml index eac4e24b526..0b614faa322 100644 --- a/.github/actions/setup-go-cache/action.yml +++ b/.github/actions/setup-go-cache/action.yml @@ -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" @@ -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') }} diff --git a/.github/workflows/airflow-operator-release-to-pypi.yml b/.github/workflows/airflow-operator-release-to-pypi.yml index 03883b9d62a..3360a2657c2 100644 --- a/.github/workflows/airflow-operator-release-to-pypi.yml +++ b/.github/workflows/airflow-operator-release-to-pypi.yml @@ -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: diff --git a/.github/workflows/airflow-operator.yml b/.github/workflows/airflow-operator.yml index 7cd1b838d11..b7901a4ff3d 100644 --- a/.github/workflows/airflow-operator.yml +++ b/.github/workflows/airflow-operator.yml @@ -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' @@ -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: @@ -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 @@ -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: | diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 639558dde00..9d90b648438 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -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 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 32e5c1fd7b7..32d60e4712a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -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 @@ -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 diff --git a/.github/workflows/go-setup/action.yml b/.github/workflows/go-setup/action.yml deleted file mode 100644 index 875a1c964fd..00000000000 --- a/.github/workflows/go-setup/action.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: "Go environment setup" -description: "Sets up go environment and installs deps for go testing of armada" - -outputs: - go-version: - description: "The installed Go version" - value: ${{ steps.setup-go.outputs.go-version }} -runs: - using: "composite" - steps: - - uses: actions/setup-go@v4 - id: setup-go - with: - go-version: ${{ matrix.go }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c9840c65ba1..3920f3b2301 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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 diff --git a/.github/workflows/python-client-release-to-pypi.yml b/.github/workflows/python-client-release-to-pypi.yml index fe5c265ca10..8f6bed06af3 100644 --- a/.github/workflows/python-client-release-to-pypi.yml +++ b/.github/workflows/python-client-release-to-pypi.yml @@ -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: diff --git a/.github/workflows/python-client.yml b/.github/workflows/python-client.yml index 3f56b0b4b2e..0896bbaf6f9 100644 --- a/.github/workflows/python-client.yml +++ b/.github/workflows/python-client.yml @@ -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' @@ -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 }} @@ -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 @@ -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: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b790df70a68..2ce2ad9b2d9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 @@ -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 \ No newline at end of file + 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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9948e6c6be0..970375e3f0b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -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 @@ -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 @@ -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.