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

Create separate action to assess code quality #145

Merged
merged 42 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
93bd71b
Split test
MichaelKora Sep 21, 2023
98a89aa
Split test
MichaelKora Sep 21, 2023
73ff8c2
Split test
MichaelKora Sep 21, 2023
504d83a
Split test
MichaelKora Sep 21, 2023
69d4f03
Split test
MichaelKora Sep 21, 2023
b390fc5
Split test
MichaelKora Sep 21, 2023
180e9d3
Split test
MichaelKora Sep 21, 2023
777df37
Group build, test and asses in one workflow
MichaelKora Sep 22, 2023
7e39987
Group build, test and asses in one workflow
MichaelKora Sep 22, 2023
27a25d9
Group build, test and asses in one workflow
MichaelKora Sep 22, 2023
55c6252
Add warning flag
MichaelKora Sep 27, 2023
9637ba0
Add warning flag
MichaelKora Sep 27, 2023
d362b58
Add warning flag
MichaelKora Sep 27, 2023
5e29def
Add warning flag
MichaelKora Sep 27, 2023
9c3920a
Add publish
MichaelKora Sep 27, 2023
0f6f132
Clean code
MichaelKora Sep 28, 2023
27919da
Clean code
MichaelKora Sep 28, 2023
312bfd2
Add secrets
MichaelKora Sep 28, 2023
301a276
Coorecet dependencies
MichaelKora Sep 28, 2023
5bcbd95
Test workflow
MichaelKora Sep 28, 2023
79e0079
Update .github/workflows/java-gradle-docker.yaml
MichaelKora Sep 28, 2023
0f0c21b
Clean code
MichaelKora Sep 28, 2023
2f117e2
Clean code
MichaelKora Sep 29, 2023
9ec24c0
Update .github/workflows/java-gradle-base.yaml
MichaelKora Oct 4, 2023
3b2bc4f
Clean code
MichaelKora Oct 4, 2023
fc64e15
Merge branch 'feat/split-test' of github.com:bakdata/ci-templates int…
MichaelKora Oct 4, 2023
dc1b692
Clean code
MichaelKora Oct 4, 2023
5f1411a
Clean code
MichaelKora Oct 4, 2023
38216bf
Change data type to boolean
MichaelKora Oct 4, 2023
ff6d9ab
Merge branch 'main' into feat/split-test
MichaelKora Oct 4, 2023
c21226a
Revert changelog related changes
MichaelKora Oct 4, 2023
76f035b
Revert changelog related changes
MichaelKora Oct 4, 2023
5c0b875
Clean code
MichaelKora Oct 4, 2023
1dbcf20
Run release only if both ppublish were successful
MichaelKora Oct 9, 2023
642dd1f
Update dependency in java gradl lib workflow
MichaelKora Oct 9, 2023
34ee9cb
Update java gradle base doc
MichaelKora Oct 9, 2023
766b72c
Remove ossrh secret from the java gradle base documentation
MichaelKora Oct 11, 2023
9be1032
Remove ossrh secret from the java gradle base documentation and sort …
MichaelKora Oct 11, 2023
a479fa4
Tag next release
MichaelKora Oct 11, 2023
0ae7c37
Remove unused vars
MichaelKora Oct 11, 2023
cd1f045
Merge remote-tracking branch 'origin/main' into feat/split-test
MichaelKora Oct 11, 2023
fe62c5f
Merge main and clean code
MichaelKora Oct 11, 2023
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
37 changes: 26 additions & 11 deletions .github/workflows/java-gradle-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,41 @@ jobs:
name: Test
runs-on: ubuntu-22.04
needs: build

steps:
- name: Test
uses: bakdata/ci-templates/actions/[email protected]
- name: Run unit tests
uses: bakdata/ci-templates/actions/java-gradle-test@feat/split-test
# uses: bakdata/ci-templates/actions/[email protected]
with:
sonar-token: ${{ secrets.sonar-token }}
sonar-organization: ${{ secrets.sonar-organization }}
signing-secret-key-ring: ${{ secrets.signing-secret-key-ring }}
signing-key-id: ${{ secrets.signing-key-id }}
signing-password: ${{ secrets.signing-password }}
gradle-cache: ${{ inputs.gradle-cache }}
gradle-version: ${{ inputs.gradle-version }}
java-distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
gradle-version: ${{ inputs.gradle-version }}
working-directory: ${{ inputs.working-directory }}

assess-code:
name: Asses code quality
runs-on: ubuntu-22.04
needs: test
steps:
- name: Assess code quality
uses: bakdata/ci-templates/actions/java-gradle-assess-code-quality@feat/split-test
# uses: bakdata/ci-templates/actions/[email protected]
with:
gradle-cache: ${{ inputs.gradle-cache }}
gradle-version: ${{ inputs.gradle-version }}
java-distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
signing-key-id: ${{ secrets.signing-key-id }}
signing-password: ${{ secrets.signing-password }}
signing-secret-key-ring: ${{ secrets.signing-secret-key-ring }}
sonar-organization: ${{ secrets.sonar-organization }}
sonar-token: ${{ secrets.sonar-token }}
working-directory: ${{ inputs.working-directory }}

build-jib:
name: Build tarball image
runs-on: ubuntu-22.04
needs: test
needs: assess-code

steps:
- name: Build tarball image
MichaelKora marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
35 changes: 25 additions & 10 deletions .github/workflows/java-gradle-library.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,41 @@ jobs:
name: Test
runs-on: ubuntu-22.04
needs: build

steps:
- name: Test
uses: bakdata/ci-templates/actions/[email protected]
- name: Run unit tests
uses: bakdata/ci-templates/actions/java-gradle-test@feat/split-test
# uses: bakdata/ci-templates/actions/[email protected]
with:
sonar-token: ${{ secrets.sonar-token }}
sonar-organization: ${{ secrets.sonar-organization }}
signing-secret-key-ring: ${{ secrets.signing-secret-key-ring }}
signing-key-id: ${{ secrets.signing-key-id }}
signing-password: ${{ secrets.signing-password }}
gradle-cache: ${{ inputs.gradle-cache }}
gradle-version: ${{ inputs.gradle-version }}
java-distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
gradle-version: ${{ inputs.gradle-version }}
working-directory: ${{ inputs.working-directory }}

assess-code:
name: Asses code quality
runs-on: ubuntu-22.04
needs: test
steps:
- name: Assess code quality
uses: bakdata/ci-templates/actions/java-gradle-assess-code-quality@feat/split-test
# uses: bakdata/ci-templates/actions/[email protected]
with:
gradle-cache: ${{ inputs.gradle-cache }}
gradle-version: ${{ inputs.gradle-version }}
java-distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
signing-key-id: ${{ secrets.signing-key-id }}
signing-password: ${{ secrets.signing-password }}
signing-secret-key-ring: ${{ secrets.signing-secret-key-ring }}
sonar-organization: ${{ secrets.sonar-organization }}
sonar-token: ${{ secrets.sonar-token }}
working-directory: ${{ inputs.working-directory }}

publish:
name: Publish
runs-on: ubuntu-22.04
needs: test
needs: assess-code

steps:
- name: Publish
Expand Down
35 changes: 25 additions & 10 deletions .github/workflows/java-gradle-plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,26 +83,41 @@ jobs:
name: Test
runs-on: ubuntu-22.04
needs: build

steps:
- name: Test
uses: bakdata/ci-templates/actions/[email protected]
- name: Run unit tests
uses: bakdata/ci-templates/actions/java-gradle-test@feat/split-test
# uses: bakdata/ci-templates/actions/[email protected]
with:
sonar-token: ${{ secrets.sonar-token }}
sonar-organization: ${{ secrets.sonar-organization }}
signing-secret-key-ring: ${{ secrets.signing-secret-key-ring }}
signing-key-id: ${{ secrets.signing-key-id }}
signing-password: ${{ secrets.signing-password }}
gradle-cache: ${{ inputs.gradle-cache }}
gradle-version: ${{ inputs.gradle-version }}
java-distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
gradle-version: ${{ inputs.gradle-version }}
working-directory: ${{ inputs.working-directory }}

assess-code:
MichaelKora marked this conversation as resolved.
Show resolved Hide resolved
name: Asses code quality
runs-on: ubuntu-22.04
needs: test
steps:
- name: Assess code quality
uses: bakdata/ci-templates/actions/java-gradle-assess-code-quality@feat/split-test
# uses: bakdata/ci-templates/actions/[email protected]
with:
gradle-cache: ${{ inputs.gradle-cache }}
gradle-version: ${{ inputs.gradle-version }}
java-distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
signing-key-id: ${{ secrets.signing-key-id }}
signing-password: ${{ secrets.signing-password }}
signing-secret-key-ring: ${{ secrets.signing-secret-key-ring }}
sonar-organization: ${{ secrets.sonar-organization }}
sonar-token: ${{ secrets.sonar-token }}
working-directory: ${{ inputs.working-directory }}

publish:
name: Publish
runs-on: ubuntu-22.04
needs: test
needs: assess-code

steps:
- name: Publish
Expand Down
40 changes: 40 additions & 0 deletions actions/java-gradle-assess-code-quality/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# assess-code-quality

This action assess code quality and tests signing for Sonatype.

## Input Parameters

If you do not set input parameters for publishing code quality test results on Sonarcloud or for testing the signing for
Sonatype, then these steps are skipped.

| Name | Required | Default Value | Type | Description |
| ----------------------- | :------: | :-----------: | :-----: | ------------------------------------------------------------------------------------------------------------- |
| download-lfs-files | ❌ | false | boolean | Whether the Git checkout action should resolve LFS files or not |
| gradle-cache | ❌ | true | boolean | Whether Gradle caching is enabled or not |
| gradle-version | ❌ | wrapper | string | [Gradle version](https://github.com/gradle/gradle-build-action#use-a-specific-gradle-version) to be installed |
| java-distribution | ❌ | microsoft | string | [Java distribution](https://github.com/actions/setup-java#supported-distributions) to be installed |
| java-version | ❌ | 11 | string | Java version to be installed |
| sonar-organization | ❌ | - | string | Organization for Sonarcloud |
| sonar-token | ❌ | - | string | Token for Sonarcloud |
| signing-key-id | ❌ | - | string | Key id for signing the Sonatype publication |
| signing-password | ❌ | - | string | Password for signing the Sonatype publication |
| signing-secret-key-ring | ❌ | - | string | Key ring (base64 encoded) for signing the Sonatype publication |
| working-directory | ❌ | "." | string | Working directory of your Gradle artifacts |

## Usage

```yaml
steps:
- name: Test
uses: bakdata/ci-templates/actions/java-gradle-test@main
with:
sonar-token: ${{ secrets.sonar-token }} # (Optional) If not set, code quality tests are skipped
sonar-organization: ${{ secrets.sonar-organization }} # (Optional) If not set, code quality tests are skipped
signing-secret-key-ring: ${{ secrets.signing-secret-key-ring }} # (Optional) If not set, signing for Sonatype is not tested
signing-key-id: ${{ secrets.signing-key-id }} # (Optional) If not set, signing for Sonatype is not tested
signing-password: ${{ secrets.signing-password }} # (Optional) If not set, signing for Sonatype is not tested
java-distribution: "microsoft" # (Optional)
java-version: "11" # (Optional)
gradle-version: "wrapper" # (Optional)
working-directory: "." # (Optional)
```
82 changes: 82 additions & 0 deletions actions/java-gradle-assess-code-quality/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: "Assess code quality"
description: "Assess code quality and optionally test signing for Sonatype"

inputs:
download-lfs-files:
description: "Whether the Git checkout action should resolve LFS files or not. (Default is false)"
required: false
default: false
gradle-cache:
description: "Whether Gradle caching is enabled or not. (Default is true)"
required: false
default: true
gradle-version:
description: "Gradle version to be installed. (Default is wrapper)"
required: false
default: "wrapper"
java-distribution:
description: "Java distribution to be installed. (Default is microsoft)"
required: false
default: "microsoft"
java-version:
description: "Java version to be installed. (Default is 11)"
required: false
default: "11"
signing-key-id:
description: "Key id for signing the Sonatype publication."
required: false
signing-password:
description: "Password for signing the Sonatype publication."
required: false
signing-secret-key-ring:
description: "Key ring (base64 encoded) for signing the Sonatype publication."
required: false
sonar-organization:
description: "Organization for Sonarcloud."
required: false
sonar-token:
description: "Token for Sonarcloud."
required: false
working-directory:
description: "Working directory of your Gradle artifacts. (Default is .)"
required: false
default: "."

runs:
using: "composite"
steps:
- name: Check out repository
uses: bakdata/ci-templates/actions/[email protected]
with:
fetch-depth: 0
lfs: ${{ inputs.download-lfs-files }}

- name: Set up Gradle with version ${{ inputs.gradle-version }}
uses: bakdata/ci-templates/actions/[email protected]
with:
java-distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
gradle-version: ${{ inputs.gradle-version }}
gradle-cache: ${{ inputs.gradle-cache }}

# sonar.branch.autoconfig.disabled is necessary for autocreation of projects on Sonarcloud to work
- name: Assess code quality
if: ${{ inputs.sonar-token != '' && inputs.sonar-organization != '' }}
run: ./gradlew -Dsonar.branch.autoconfig.disabled=true -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=${{ inputs.sonar-organization }} --info --stacktrace sonarqube
shell: bash
working-directory: ${{ inputs.working-directory }}
env:
SONAR_TOKEN: ${{ inputs.sonar-token }}

- name: Check if everything builds (incl. javadoc) for snapshot/release and signing works
if: ${{ inputs.signing-secret-key-ring != '' && inputs.signing-key-id != '' && inputs.signing-password != '' }}
run: |
export SIGNING_SECRET_KEY_RING_FILE="$(mktemp -d)/secring.gpg"
echo '${{ inputs.signing-secret-key-ring }}' | base64 -d > $SIGNING_SECRET_KEY_RING_FILE
./gradlew --info --stacktrace signSonatypePublication
shell: bash
working-directory: ${{ inputs.working-directory }}
env:
SIGNING_KEY_ID: ${{ inputs.signing-key-id }}
SIGNING_PASSWORD: ${{ inputs.signing-password }}
CI: true
29 changes: 8 additions & 21 deletions actions/java-gradle-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,14 @@ This action runs Junit tests, publishes the test results and tests signing for S

## Input Parameters

If you do not set input parameters for publishing code quality test results on Sonarcloud or for testing the signing for
Sonatype, then these steps are skipped.

| Name | Required | Default Value | Type | Description |
| ----------------------- | :------: | :-----------: | :-----: | ------------------------------------------------------------------------------------------------------------- |
| sonar-token | ❌ | - | string | Token for Sonarcloud |
| sonar-organization | ❌ | - | string | Organization for Sonarcloud |
| signing-secret-key-ring | ❌ | - | string | Key ring (base64 encoded) for signing the Sonatype publication |
| signing-key-id | ❌ | - | string | Key id for signing the Sonatype publication |
| signing-password | ❌ | - | string | Password for signing the Sonatype publication |
| java-distribution | ❌ | microsoft | string | [Java distribution](https://github.com/actions/setup-java#supported-distributions) to be installed |
| java-version | ❌ | 11 | string | Java version to be installed |
| gradle-version | ❌ | wrapper | string | [Gradle version](https://github.com/gradle/gradle-build-action#use-a-specific-gradle-version) to be installed |
| gradle-cache | ❌ | true | boolean | Whether Gradle caching is enabled or not |
| working-directory | ❌ | "." | string | Working directory of your Gradle artifacts |
| download-lfs-files | ❌ | false | boolean | Whether the Git checkout action should resolve LFS files or not |
| Name | Required | Default Value | Type | Description |
| ------------------ | :------: | :-----------: | :-----: | ------------------------------------------------------------------------------------------------------------- |
| download-lfs-files | ❌ | false | boolean | Whether the Git checkout action should resolve LFS files or not |
| java-distribution | ❌ | microsoft | string | [Java distribution](https://github.com/actions/setup-java#supported-distributions) to be installed |
| java-version | ❌ | 11 | string | Java version to be installed |
| gradle-cache | ❌ | true | boolean | Whether Gradle caching is enabled or not |
| gradle-version | ❌ | wrapper | string | [Gradle version](https://github.com/gradle/gradle-build-action#use-a-specific-gradle-version) to be installed |
| working-directory | ❌ | "." | string | Working directory of your Gradle artifacts |

## Usage

Expand All @@ -28,11 +20,6 @@ steps:
- name: Test
uses: bakdata/ci-templates/actions/java-gradle-test@main
with:
sonar-token: ${{ secrets.sonar-token }} # (Optional) If not set, code quality tests are skipped
sonar-organization: ${{ secrets.sonar-organization }} # (Optional) If not set, code quality tests are skipped
signing-secret-key-ring: ${{ secrets.signing-secret-key-ring }} # (Optional) If not set, signing for Sonatype is not tested
signing-key-id: ${{ secrets.signing-key-id }} # (Optional) If not set, signing for Sonatype is not tested
signing-password: ${{ secrets.signing-password }} # (Optional) If not set, signing for Sonatype is not tested
java-distribution: "microsoft" # (Optional)
java-version: "11" # (Optional)
gradle-version: "wrapper" # (Optional)
Expand Down
Loading