Skip to content

Commit

Permalink
build: enable caching for artifact tests
Browse files Browse the repository at this point in the history
  • Loading branch information
monosoul committed Apr 11, 2024
1 parent 7c030e1 commit 6396015
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 5 deletions.
32 changes: 31 additions & 1 deletion .github/workflows/build-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
with:
arguments: |
--stacktrace
check jacocoTestReport
check jacocoTestReport -x :artifact-tests:test
- name: Test publishing
uses: gradle/actions/setup-gradle@v3
with:
Expand All @@ -42,6 +42,36 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true

artifact_tests:
runs-on: ubuntu-latest
env:
ENABLE_JAR_CACHING: true
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Run artifact tests
uses: gradle/actions/setup-gradle@v3
with:
arguments: |
--stacktrace
:artifact-tests:check
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: always() # always run even if the previous step fails
with:
check_name: JUnit Test Report
report_paths: '**/build/test-results/**/TEST-*.xml'
annotate_notice: false

publish-snapshot:
name: Publish snapshot
needs: build
Expand Down
36 changes: 34 additions & 2 deletions .github/workflows/build-on-push-to-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
branches: [ main ]

concurrency:
group: ${{ github.ref }}

jobs:
build:
name: Build
Expand All @@ -21,7 +24,7 @@ jobs:
with:
arguments: |
--stacktrace
check jacocoTestReport
check jacocoTestReport -x :artifact-tests:test
- name: Test publishing
uses: gradle/actions/setup-gradle@v3
with:
Expand All @@ -40,9 +43,38 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true

artifact_tests:
runs-on: ubuntu-latest
env:
ENABLE_JAR_CACHING: true
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Run artifact tests
uses: gradle/actions/setup-gradle@v3
with:
arguments: |
--stacktrace
:artifact-tests:check
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: always() # always run even if the previous step fails
with:
check_name: JUnit Test Report
report_paths: '**/build/test-results/**/TEST-*.xml'
annotate_notice: false

trigger-release:
name: Trigger release
needs: build
needs:
- build
- artifact_tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand Down
68 changes: 66 additions & 2 deletions .github/workflows/publish-on-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
types: [published]

jobs:
release:
build:
runs-on: ubuntu-latest
environment: release
steps:
Expand All @@ -21,7 +21,7 @@ jobs:
with:
arguments: |
--stacktrace
check
check -x :artifact-tests:test
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: always() # always run even if the previous step fails
Expand Down Expand Up @@ -52,3 +52,67 @@ jobs:
file: 'build/libs/jooq-gradle-plugin-*[0-9].*[0-9].*[0-9]{-javadoc,-sources,}.jar'
file_glob: true
tag: ${{ github.ref }}

artifact_tests:
runs-on: ubuntu-latest
env:
ENABLE_JAR_CACHING: true
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Run artifact tests
uses: gradle/actions/setup-gradle@v3
with:
arguments: |
--stacktrace
:artifact-tests:check
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: always() # always run even if the previous step fails
with:
check_name: JUnit Test Report
report_paths: '**/build/test-results/**/TEST-*.xml'
annotate_notice: false

release:
needs:
- build
- artifact_tests
runs-on: ubuntu-latest
environment: release
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Publish plugin
uses: gradle/actions/setup-gradle@v3
env:
ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.OSSRH_GPG_SECRET_KEY_ID }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_withSigning: true
with:
arguments: |
-Pversion=${{ github.event.release.tag_name }}
-Pgradle.publish.key=${{ secrets.GRADLE_PUBLISH_KEY }}
-Pgradle.publish.secret=${{ secrets.GRADLE_PUBLISH_SECRET }}
--stacktrace
assemble publishPlugins publishToSonatype closeAndReleaseSonatypeStagingRepository
- name: Attach artifacts to the release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: 'build/libs/jooq-gradle-plugin-*[0-9].*[0-9].*[0-9]{-javadoc,-sources,}.jar'
file_glob: true
tag: ${{ github.ref }}
10 changes: 10 additions & 0 deletions artifact-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ tasks {
dependsOn(publishAllPublicationsToLocalBuildRepository)

from(rootProject.layout.buildDirectory.dir(localRepositoryDirName))
exclude(
"**/*.module",
"**/maven-metadata.xml",
"**/*-javadoc.jar",
"**/*-sources.jar",
"**/*.md5",
"**/*.sha1",
"**/*.sha256",
"**/*.sha512",
)
into(layout.buildDirectory.dir(localRepositoryDirName))
}

Expand Down
7 changes: 7 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ tasks {
)
}

withType<Jar> {
outputs.cacheIf { System.getenv("ENABLE_JAR_CACHING")?.lowercase() == "true" }
if (System.getenv("ENABLE_JAR_CACHING")?.lowercase() == "true") {
outputs.doNotCacheIfSpecs.clear()
}
}

assemble {
dependsOn(shadowJar)
}
Expand Down

0 comments on commit 6396015

Please sign in to comment.