Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PI-2624 Prevent version from invalidating config cache #4404

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/analyse/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ runs:
shell: bash
run: |
version=$(date '+%Y-%m-%d').${{ github.run_number }}.$(echo ${{ github.sha }} | cut -c1-7)
echo "ORG_GRADLE_PROJECT_version=$version" | tee -a "$GITHUB_ENV"
echo "VERSION=$version" | tee -a "$GITHUB_ENV"
echo "version=$version" | tee -a "$GITHUB_OUTPUT"

- uses: ./.github/actions/setup-gradle
Expand Down
4 changes: 3 additions & 1 deletion .github/actions/get-build-info/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ runs:
with:
cache-encryption-key: ${{ inputs.gradle-encryption-key }}
cache-read-only: true
remove-git-config: false

- name: Get build info
if: ${{ steps.gradle_file.outputs.files_exists == 'true' }}
run: |
echo '::group::Generate build info'
./gradlew ${{ inputs.project }}:buildInfo ${{ inputs.project }}:gitInfo
sed -i "s/build.version=.*/build.version=$VERSION/" projects/${{ inputs.project }}/build-info.properties
echo '::endgroup::'
shell: bash
env:
ORG_GRADLE_PROJECT_version: ${{ inputs.version }}
VERSION: ${{ inputs.version }}
12 changes: 12 additions & 0 deletions .github/actions/setup-gradle/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ inputs:
A suitable key can be generated with `openssl rand -base64 16`.
Configuration-cache data will not be saved/restored without an encryption key being provided.
required: false
remove-git-config:
description: Whether to remove the git config file to prevent configuration cache invalidation.
required: false
default: 'true'

runs:
using: "composite"
Expand All @@ -26,3 +30,11 @@ runs:
with:
cache-encryption-key: ${{ inputs.cache-encryption-key }}
cache-read-only: ${{ inputs.cache-read-only }}
- name: Manually cache buildSrc output # workaround for https://github.com/gradle/actions/issues/21
uses: actions/cache@v4
with:
path: buildSrc/build
key: gradle-buildSrc-${{ hashFiles('buildSrc/src/**', 'buildSrc/build.gradle.kts') }}
- if: inputs.remove-git-config == 'true'
run: rm -f .git/config
shell: bash
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ updates:
schedule:
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/.github/actions/setup-gradle"
schedule:
interval: "weekly"

- package-ecosystem: "terraform"
directory: "/templates"
schedule:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
id: version
run: |
version=$(date '+%Y-%m-%d').${{ github.run_number }}.$(echo ${{ github.sha }} | cut -c1-7)
echo "ORG_GRADLE_PROJECT_version=$version" | tee -a "$GITHUB_ENV"
echo "VERSION=$version" | tee -a "$GITHUB_ENV"
echo "version=$version" | tee -a "$GITHUB_OUTPUT"

- name: Build and test
Expand All @@ -115,7 +115,8 @@ jobs:
with:
max_attempts: 3 # Pushing lots of new image versions at once can result in GitHub rate-limiting so we retry this step
timeout_minutes: 15
command: ./gradlew ${{ matrix.project }}:jib
# Configuration cache is not yet supported for Jib - see: https://github.com/GoogleContainerTools/jib/issues/3132
command: ./gradlew ${{ matrix.project }}:jib --no-configuration-cache
env:
GITHUB_USERNAME: ${{ github.actor }}
GITHUB_PASSWORD: ${{ github.token }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ class JibConfigPlugin : Plugin<Project> {
project.tasks.withType<BuildImageTask>().named("jib") {
doFirst {
jib!!.to {
tags = setOf("${project.version}")
tags = setOf("${System.getenv("VERSION") ?: "dev"}")
auth {
username = System.getenv("GITHUB_USERNAME")
password = System.getenv("GITHUB_PASSWORD")
}
}
}
if (System.getenv("FORCE_DEPLOY") == "true") {
jib!!.to.tags = setOf("${project.version}")
jib!!.to.tags = setOf("${System.getenv("VERSION") ?: "dev"}")
}
doLast {
val dir = File("${project.rootDir}/changed")
Expand Down
Loading