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 15 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
87 changes: 80 additions & 7 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The following workflows can be found here:
- [Python Poetry Release](#python-poetry-release)
- [Python Poetry Publish PyPI](#python-poetry-publish-pypi)
- [Python Poetry Publish Snapshot](#python-poetry-publish-snapshot)
- [Java Gradle Base](#java-gradle-base)
- [Java Gradle Docker](#java-gradle-docker)
- [Java Gradle Library](#java-gradle-library)
- [Java Gradle Plugin](#java-gradle-plugin)
Expand Down Expand Up @@ -679,6 +680,8 @@ These secrets define the TestPyPI token that allow the GitHub action to release
| ---------- | :------: | ---------------------------------------------- |
| pypi-token | ✅ | The TestPyPI API token for publishing packages |

<!-- -->ƒ
MichaelKora marked this conversation as resolved.
Show resolved Hide resolved

### Calling the workflow

```yaml
Expand All @@ -698,7 +701,7 @@ jobs:
pypi-token: ${{ secrets.TEST_PYPI_TOKEN }}
```

## Java Gradle Docker
## Java Gradle Base

This workflow will build, test and publish a Java Gradle project including a tarball image. Additionally,
the workflow creates a GitHub Release when running on a tag branch.
MichaelKora marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -714,6 +717,78 @@ This workflow is built from multiple composite actions listed below:

- [java-gradle-build](https://github.com/bakdata/ci-templates/tree/main/actions/java-gradle-build)
- [java-gradle-test](https://github.com/bakdata/ci-templates/tree/main/actions/java-gradle-test)
- [java-gradle-assess-code-quality](https://github.com/bakdata/ci-templates/tree/main/actions/java-gradle-assess-code-quality)

### Input Parameters

| Name | Required | Default Value | Type | Description |
| ------------------ | :------: | :-----------: | :-----: | ------------------------------------------------------------------------------------------------------------- |
| 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" | string | Whether the Git checkout action should resolve LFS files or not |

### Secret Parameters

For Sonarcloud you need to provide a `sonar-token` and a `sonar-organization` to publish code quality results. In case of Sonatype, the action
requires you to have a `signing-secret-key-ring` (base64 encoded), a `signing-key-id` and a `signing-password` to sign
your build artifacts and additionally an `ossrh-username` and an `ossrh-password` to publish the signed artifacts to
Nexus.
MichaelKora marked this conversation as resolved.
Show resolved Hide resolved

| Name | Required | Description |
| ----------------------- | :------: | -------------------------------------------------------------- |
| sonar-token | ✅ | Token for Sonarcloud |
| sonar-organization | ✅ | Organization for Sonarcloud |
| signing-secret-key-ring | ✅ | Key ring (base64 encoded) for signing the Sonatype publication |
| signing-key-id | ✅ | Key id for signing the Sonatype publication |
| signing-password | ✅ | Password for signing the Sonatype publication |
| ossrh-username | ✅ | Username for signing into Sonatype repository |
| ossrh-password | ✅ | Password for signing into Sonatype repository |
MichaelKora marked this conversation as resolved.
Show resolved Hide resolved

### Calling the workflow

```yaml
name: Call this reusable workflow

on:
push:
branches: [main]

jobs:
call-workflow-passing-data:
name: Java Gradle Docker
uses: bakdata/ci-templates/.github/workflows/java-gradle-base.yaml@main
with:
java-distribution: "microsoft" # (Optional) Default is microsoft
java-version: "11" # (Optional) Default is 11
gradle-version: "wrapper" # (Optional) Default is wrapper
gradle-cache: false # (Optional) Default is true
working-directory: "." # (Optional) Default is .
secrets:
sonar-token: ${{ secrets.SONARCLOUD_TOKEN }}
sonar-organization: ${{ secrets.SONARCLOUD_ORGANIZATION }}
signing-secret-key-ring: ${{ secrets.SIGNING_SECRET_KEY_RING }}
signing-key-id: ${{ secrets.SIGNING_KEY_ID }}
signing-password: ${{ secrets.SIGNING_PASSWORD }}
```

## Java Gradle Docker

This workflow will build, test and publish a Java Gradle project including a tarball image. Additionally,
the workflow creates a GitHub Release when running on a tag branch.

### Prerequisites

Your Java project needs to be set up with Gradle and either needs to contain a `build.gradle` or a `build.gradle.kts`
file that uses the [Sonar](https://github.com/bakdata/gradle-plugins/tree/master/sonar), [Sonatype](https://github.com/bakdata/gradle-plugins/tree/master/sonatype) and [Jib](https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin) plugins. Moreover, prepare credentials for Sonarcloud, Sonatype, GitHub and Docker.

### Dependencies

This workflow is built from multiple composite actions and workflows listed below:

- [java-gradle-base](https://github.com/bakdata/ci-templates/tree/main/.github/workflows/java-gradle-base.yaml)
- [java-gradle-build-jib](https://github.com/bakdata/ci-templates/tree/main/actions/java-gradle-build-jib)
- [java-gradle-publish](https://github.com/bakdata/ci-templates/tree/main/actions/java-gradle-publish)
- [docker-publish](https://github.com/bakdata/ci-templates/tree/main/actions/docker-publish)
Expand Down Expand Up @@ -799,10 +874,9 @@ file that uses the [Sonar](https://github.com/bakdata/gradle-plugins/tree/master

### Dependencies

This workflow is built from multiple composite actions listed below:
This workflow is built from multiple composite actions and workflows listed below:

- [java-gradle-build](https://github.com/bakdata/ci-templates/tree/main/actions/java-gradle-build)
- [java-gradle-test](https://github.com/bakdata/ci-templates/tree/main/actions/java-gradle-test)
- [java-gradle-base](https://github.com/bakdata/ci-templates/tree/main/.github/workflows/java-gradle-base.yaml)
- [java-gradle-publish](https://github.com/bakdata/ci-templates/tree/main/actions/java-gradle-publish)
- [java-gradle-release-github](https://github.com/bakdata/ci-templates/tree/main/actions/java-gradle-release-github)

Expand Down Expand Up @@ -880,10 +954,9 @@ and Gradle Plugin Portal.

### Dependencies

This workflow is built from multiple composite actions listed below:
This workflow is built from multiple composite actions and workflows listed below:

- [java-gradle-build](https://github.com/bakdata/ci-templates/tree/main/actions/java-gradle-build)
- [java-gradle-test](https://github.com/bakdata/ci-templates/tree/main/actions/java-gradle-test)
- [java-gradle-base](https://github.com/bakdata/ci-templates/tree/main/.github/workflows/java-gradle-base.yaml)
- [java-gradle-publish](https://github.com/bakdata/ci-templates/tree/main/actions/java-gradle-publish)
- [java-gradle-publish-plugin](https://github.com/bakdata/ci-templates/tree/main/actions/java-gradle-publish-plugin)
- [java-gradle-release-github](https://github.com/bakdata/ci-templates/tree/main/actions/java-gradle-release-github)
Expand Down
103 changes: 103 additions & 0 deletions .github/workflows/java-gradle-base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Java Gradle Base
# Reusable workflow for building testing and assessing code quality

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

jobs:
build:
name: Build
runs-on: ubuntu-22.04

steps:
- name: Build
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 }}
working-directory: ${{ inputs.working-directory }}

test:
name: Test
runs-on: ubuntu-22.04
needs: build
steps:
- name: Run unit tests
uses: bakdata/ci-templates/actions/java-gradle-test@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 }}
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
MichaelKora marked this conversation as resolved.
Show resolved Hide resolved
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 }}
download-lfs-files: ${{ inputs.download-lfs-files }}
MichaelKora marked this conversation as resolved.
Show resolved Hide resolved
49 changes: 16 additions & 33 deletions .github/workflows/java-gradle-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,44 +69,27 @@
required: true

jobs:
build:
name: Build
runs-on: ubuntu-22.04

steps:
- name: Build
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 }}
working-directory: ${{ inputs.working-directory }}
java-gradle-base:
MichaelKora marked this conversation as resolved.
Show resolved Hide resolved
name: Build, Test and Assess code quality
uses: bakdata/ci-templates/.github/workflows/java-gradle-base.yaml@feat/split-test
# uses: bakdata/ci-templates/.github/workflows/[email protected]

test:
name: Test
runs-on: ubuntu-22.04
needs: build
with:
java-distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
gradle-version: ${{ inputs.gradle-version }}
gradle-cache: ${{ inputs.gradle-cache }}
working-directory: ${{ inputs.working-directory }}
signing-key-id: ${{ secrets.signing-key-id }}

Check failure on line 83 in .github/workflows/java-gradle-docker.yaml

View workflow job for this annotation

GitHub Actions / actionlint

context "secrets" is not allowed here. available contexts are "github", "inputs", "matrix", "needs", "strategy". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details
signing-password: ${{ secrets.signing-password }}
signing-secret-key-ring: ${{ secrets.signing-secret-key-ring }}
sonar-organization: ${{ secrets.sonar-organization }}
sonar-token: ${{ secrets.sonar-token }}
MichaelKora marked this conversation as resolved.
Show resolved Hide resolved

steps:
- name: 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 }}
java-distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
gradle-version: ${{ inputs.gradle-version }}
gradle-cache: ${{ inputs.gradle-cache }}
working-directory: ${{ inputs.working-directory }}

build-jib:
name: Build tarball image
runs-on: ubuntu-22.04
needs: test
needs: java-gradle-base
MichaelKora marked this conversation as resolved.
Show resolved Hide resolved

steps:
- name: Build tarball image
MichaelKora marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
52 changes: 19 additions & 33 deletions .github/workflows/java-gradle-library.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,44 +59,29 @@ on:
required: true

jobs:
build:
name: Build
runs-on: ubuntu-22.04
java-gradle-base:
MichaelKora marked this conversation as resolved.
Show resolved Hide resolved
name: Build, Test and Assess code quality
uses: bakdata/ci-templates/.github/workflows/java-gradle-base.yaml@feat/split-test
with:
# uses: bakdata/ci-templates/.github/workflows/[email protected]
java-distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
gradle-version: ${{ inputs.gradle-version }}
gradle-cache: ${{ inputs.gradle-cache }}
working-directory: ${{ inputs.working-directory }}

steps:
- name: Build
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 }}
working-directory: ${{ inputs.working-directory }}

test:
name: Test
runs-on: ubuntu-22.04
needs: build
secrets:
signing-key-id: ${{ secrets.signing-key-id }}
signing-password: ${{ secrets.signing-password }}
signing-secret-key-ring: ${{ secrets.signing-secret-key-ring }}
sonar-token: ${{ secrets.sonar-token }}
sonar-organization: ${{ secrets.sonar-organization }}

steps:
- name: 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 }}
java-distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
gradle-version: ${{ inputs.gradle-version }}
gradle-cache: ${{ inputs.gradle-cache }}
working-directory: ${{ inputs.working-directory }}

publish:
name: Publish
runs-on: ubuntu-22.04
needs: test
needs: java-gradle-base

steps:
- name: Publish
Expand All @@ -117,7 +102,8 @@ jobs:
name: Create Github release
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-22.04
needs: publish
# needs: publish
MichaelKora marked this conversation as resolved.
Show resolved Hide resolved
needs: java-gradle-base

steps:
- name: Release on Github
Expand Down
Loading
Loading