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

feat: use gradle-build-action #11

Merged
merged 1 commit into from
Nov 14, 2023
Merged
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
43 changes: 25 additions & 18 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ description: |
This actions will also annotate the PR or commit with the failed tests.

inputs:
execution-only-caches:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enlever un input, ça ne cause pas d'erreur (donc un breaking change)?

Copy link
Contributor Author

@meriouma meriouma Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je vais faire une majeure et gérer ça dans tous les workflows qui utilisent l'action. equisoft-actions/kotlin-workflows#25

description: |
Activates only the caches that are relevant for executing gradle command.
This is helpful when build job executes multiple gradle commands sequentially.
Then the caching is implemented in the very first one, and the subsequent should be marked
with execution-only-caches: true
required: false
default: 'false'
gradle-properties:
description: Content of a gradle.properties file that will be passed to the gradle runner.
required: false
Expand All @@ -23,12 +15,10 @@ inputs:
Defaults to the root project.
required: true
default: "."
gradle-dependencies-cache-key:
description: Extra files to take into account for ~/.gradle/caches dependencies
read-only-cache:
description: If set to true, the action will only read from the cache and will not write to it.
required: true
default: |
buildSrc/**/Dependencies.kt
gradle/libs.versions.toml
default: "true"
report-retention-days:
description: Duration in days to preserve reports.
required: true
Expand Down Expand Up @@ -66,15 +56,32 @@ runs:
fi
echo "artifact-path=$ARTIFACT_PATH" >> $GITHUB_OUTPUT

- name: Process gradle properties
id: gradle-properties
shell: python
env:
GRADLE_PROPERTIES: ${{ inputs.gradle-properties }}
run: |
import os

properties_list: list[str] = [line for line in (line.strip() for line in os.environ.get('GRADLE_PROPERTIES').splitlines()) if line]
properties = list(map(lambda x: f'-P{x}' if not x.startswith('-P') else x, properties_list))

with open(os.environ.get('GITHUB_OUTPUT'), 'a') as output_file:
output_file.write('gradle-properties=')
output_file.write(' '.join(properties))
output_file.write('\n')

- name: Run tests
uses: burrunan/gradle-cache-action@v1
uses: gradle/gradle-build-action@v2
with:
gradle-version: wrapper
build-root-directory: ${{ inputs.working-directory }}
gradle-dependencies-cache-key: ${{ inputs.gradle-dependencies-cache-key }}
arguments: -p ${{ inputs.gradle-project-path }} ci-${{ inputs.task-name }}
properties: ${{ inputs.gradle-properties }}
execution-only-caches: ${{ inputs.execution-only-caches }}
cache-read-only: ${{ inputs.read-only-cache }}
arguments: |
-p ${{ inputs.gradle-project-path }}
ci-${{ inputs.task-name }}
${{ steps.gradle-properties.outputs.gradle-properties }}

- name: Upload report
uses: actions/upload-artifact@v3
Expand Down