Skip to content

Commit

Permalink
feat: Use GCP bucket instead of S3.
Browse files Browse the repository at this point in the history
Include OIDC provisioned by google and GCS bucket.
  • Loading branch information
Matovidlo committed Nov 19, 2024
1 parent e375dc2 commit 00c15b7
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 27 deletions.
40 changes: 19 additions & 21 deletions .github/actions/go-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,24 @@ inputs:
description: Cache workflow version
required: false
default: "004"
cache-s3-bucket:
description: S3 bucket for various caches.
cache-gcs-bucket:
description: GCS bucket for various caches.
required: true
build-type:
description: Build type, for example "default", "linter", ...
required: true
runs:
using: "composite"
steps:
- name: Assume AWS S3 caching role
uses: aws-actions/configure-aws-credentials@v4
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2.1.7
with:
role-to-assume: arn:aws:iam::831559560923:role/S3-gh-actions-caching
role-session-name: ghactionscaching
aws-region: us-east-1
workload_identity_provider: projects/183593139398/locations/global/workloadIdentityPools/kac-ci-github-pool/providers/kac-repo
project_id: "go-team-dev"

- name: Install Zstd
shell: bash
run: zstd --version

- name: Extract GO_VERSION from go.mod file
shell: bash
Expand Down Expand Up @@ -83,15 +86,13 @@ runs:
- name: Load Go tools cache
id: go-cache-tools
if: inputs.without-cache != 'true'
uses: runs-on/cache@v4 # replacement for actions/cache@v4
uses: mansagroup/gcs-cache-action@v1.0.3 # replacement for runs-on/cache@v4
with:
bucket: ${{ inputs.cache-gcs-bucket }}
path: |
${{ env.GODIRS }}/bin
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ inputs.cache-version }}-tools-${{ hashFiles('scripts/tools.sh') }}

env:
RUNS_ON_S3_BUCKET_CACHE: ${{ inputs.cache-s3-bucket }}

# Install missing tools
- name: Install tools
shell: bash
Expand All @@ -108,41 +109,38 @@ runs:
- name: Load Go modules cache
id: go-cache-mod
if: inputs.without-cache != 'true'
uses: runs-on/cache@v4 # replacement for actions/cache@v4
uses: mansagroup/gcs-cache-action@v1.0.3 # replacement for runs-on/cache@v4
with:
bucket: ${{ inputs.cache-gcs-bucket }}
path: |
${{ env.GODIRS }}/modcache
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ inputs.cache-version }}-mod-${{ hashFiles('**/go.mod') }}
restore-keys: |
${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ inputs.cache-version }}-mod-
env:
RUNS_ON_S3_BUCKET_CACHE: ${{ inputs.cache-s3-bucket }}
- name: Load Go build and test cache
id: go-cache-build
if: inputs.without-cache != 'true'
uses: runs-on/cache@v4 # replacement for actions/cache@v4
uses: mansagroup/gcs-cache-action@v1.0.3 # replacement for runs-on/cache@v4
with:
bucket: ${{ inputs.cache-gcs-bucket }}
path: |
${{ env.GODIRS }}/cache
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ inputs.cache-version }}-build-${{ inputs.build-type }}-${{ hashFiles('**/go.mod') }}
restore-keys: |
${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ inputs.cache-version }}-build-${{ inputs.build-type }}-
env:
RUNS_ON_S3_BUCKET_CACHE: ${{ inputs.cache-s3-bucket }}
- name: Load Linter cache
id: go-cache-linter
if: inputs.build-type == 'lint' && inputs.without-cache != 'true'
uses: runs-on/cache@v4 # replacement for actions/cache@v4
uses: mansagroup/gcs-cache-action@v1.0.3 # replacement for runs-on/cache@v4
with:
bucket: ${{ inputs.cache-gcs-bucket }}
path: |
${{ env.GODIRS }}/lintcache
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ inputs.cache-version }}-linter-${{ hashFiles('**/go.mod') }}
restore-keys: |
${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ inputs.cache-version }}-linter-
env:
RUNS_ON_S3_BUCKET_CACHE: ${{ inputs.cache-s3-bucket }}
- name: Download Go modules
shell: bash
Expand Down Expand Up @@ -187,6 +185,6 @@ runs:
# To find problematic dir/file: Run the workflow twice, download tests logs, sort lines and make a diff.
# https://pkg.go.dev/cmd/go#hdr-Build_and_test_caching
- name: Enable debugging of the Go test cache
if: false # disabled, enable for debugging
if: "false" # disabled, enable for debugging
shell: bash
run: echo "GODEBUG=gocachehash=1" >> $GITHUB_ENV
2 changes: 1 addition & 1 deletion .github/workflows/check-licenses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: ./.github/actions/go-setup
with:
build-type: check-licenses
cache-s3-bucket: ${{ vars.CACHE_S3_BUCKET }}
cache-gcs-bucket: ${{ vars.CACHE_GCS_BUCKET }}

#####################
### License Types ###
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-e2e-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
with:
build-type: e2e-tests-cli
without-cache: ${{ inputs.without-cache }}
cache-s3-bucket: ${{ vars.CACHE_S3_BUCKET }}
cache-gcs-bucket: ${{ vars.CACHE_GCS_BUCKET }}

- name: Set TEST_KBC_PROJECTS_FILE entries
uses: ./.github/actions/export-kbc-projects
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-e2e-service-stream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
with:
build-type: e2e-tests-stream
without-cache: ${{ inputs.without-cache }}
cache-s3-bucket: ${{ vars.CACHE_S3_BUCKET }}
cache-gcs-bucket: ${{ vars.CACHE_GCS_BUCKET }}

- name: Set TEST_KBC_PROJECTS_FILE entries
uses: ./.github/actions/export-kbc-projects
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-e2e-service-templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
with:
build-type: e2e-tests-templates
without-cache: ${{ inputs.without-cache }}
cache-s3-bucket: ${{ vars.CACHE_S3_BUCKET }}
cache-gcs-bucket: ${{ vars.CACHE_GCS_BUCKET }}

- name: Set TEST_KBC_PROJECTS_FILE entries
uses: ./.github/actions/export-kbc-projects
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: ./.github/actions/go-setup
with:
build-type: lint
cache-s3-bucket: ${{ vars.CACHE_S3_BUCKET }}
cache-gcs-bucket: ${{ vars.CACHE_GCS_BUCKET }}

- name: Check links in Markdown files
uses: lycheeverse/lychee-action@v2.0.2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
with:
build-type: unit-tests
without-cache: ${{ inputs.without-cache }}
cache-s3-bucket: ${{ vars.CACHE_S3_BUCKET }}
cache-gcs-bucket: ${{ vars.CACHE_GCS_BUCKET }}

- name: Set TEST_KBC_PROJECTS_FILE entries
uses: ./.github/actions/export-kbc-projects
Expand Down

0 comments on commit 00c15b7

Please sign in to comment.