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

refactor: Extract the setup-java action into a re-usable action #246

Merged
Show file tree
Hide file tree
Changes from 4 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
34 changes: 34 additions & 0 deletions .github/actions/checkout/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
# Copyright (c) 2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

---
name: "Checkout"
description: "Checks out the repository"
inputs:
fetch-depth:
required: false
description: "Fetch-depth"
runs:
using: "composite"
steps:
- uses: ./.github/actions/checkout
with:
fetch-depth: ${{ inputs.fetch-depth }}

10 changes: 2 additions & 8 deletions .github/actions/publish-docker-image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ inputs:
runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: ./.github/actions/checkout
paullatzelsperger marked this conversation as resolved.
Show resolved Hide resolved

#####################
# Login to DockerHub
Expand All @@ -56,12 +55,7 @@ runs:
#####################
# Build JAR file
#####################
- name: Set up JDK 11
uses: actions/setup-java@v3.11.0
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- uses: ./.github/actions/setup-java
- name: Build Controlplane
shell: bash
run: |-
Expand Down
10 changes: 2 additions & 8 deletions .github/actions/run-deployment-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,15 @@ inputs:
runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v3.3.0
- uses: ./.github/actions/checkout

- name: Cache ContainerD Image Layers
uses: actions/cache@v3
with:
path: /var/lib/containerd/io.containerd.snapshotter.v1.overlayfs
key: ${{ runner.os }}-io.containerd.snapshotter.v1.overlayfs

- name: Set up JDK 11
uses: actions/setup-java@v3.11.0
with:
java-version: '11'
distribution: 'temurin'
cache: 'gradle'
- uses: ./.github/actions/setup-java

- name: Build docker images
shell: bash
Expand Down
32 changes: 32 additions & 0 deletions .github/actions/setup-java/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
# Copyright (c) 2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

---
name: "Setup JDK 17"
description: "Setup JDK 17"
runs:
using: "composite"
steps:
- name: Setup JDK 17
paullatzelsperger marked this conversation as resolved.
Show resolved Hide resolved
uses: actions/setup-java@v3.11.0
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
26 changes: 6 additions & 20 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,8 @@ jobs:
needs: [ secret-presence ]
steps:
# Set-Up
- name: Checkout
uses: actions/checkout@v3.3.0
- name: Set up JDK 11
uses: actions/setup-java@v3.11.0
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- uses: ./.github/actions/checkout
- uses: ./.github/actions/setup-java
paullatzelsperger marked this conversation as resolved.
Show resolved Hide resolved
# Build
- name: Build Extensions
run: |-
Expand All @@ -104,8 +98,7 @@ jobs:
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: ./.github/actions/checkout
- uses: ./.github/actions/publish-docker-image
with:
rootDir: edc-controlplane/${{ matrix.name }}
Expand All @@ -128,8 +121,7 @@ jobs:
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: ./.github/actions/checkout
- uses: ./.github/actions/publish-docker-image
with:
rootDir: edc-dataplane/${{ matrix.name }}
Expand All @@ -149,15 +141,9 @@ jobs:
needs.secret-presence.outputs.GPG_PASSPHRASE && needs.secret-presence.outputs.GPG_PRIVATE_KEY && github.event_name != 'pull_request' && github.ref != 'refs/heads/releases'
steps:
# Set-Up
- name: Checkout
uses: actions/checkout@v3.3.0
- uses: ./.github/actions/checkout

- name: Set up JDK 11
uses: actions/setup-java@v3.11.0
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- uses: ./.github/actions/setup-java
- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@v5
with:
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/business-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,9 @@ jobs:
### Set-Up ###
##############
-
name: Checkout
uses: actions/checkout@v3.3.0
uses: ./.github/actions/checkout
-
name: Set-Up JDK 11
uses: actions/setup-java@v3.11.0
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
uses: ./.github/actions/setup-java
-
name: Cache ContainerD Image Layers
uses: actions/cache@v3
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/deployment-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ jobs:
deployment-test-memory:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3.3.0
- uses: ./.github/actions/checkout
- uses: ./.github/actions/run-deployment-test
name: "Run deployment test using KinD and Helm"
with:
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/draft-new-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
pages: write
pull-requests: write
steps:
- uses: actions/checkout@v3.3.0
- uses: ./.github/actions/checkout
-
name: Create release branch
run: git checkout -b release/${{ github.event.inputs.version }}
Expand All @@ -33,12 +33,7 @@ jobs:
git config user.name "GitHub actions"
git config user.email noreply@github.com
-
name: Set up JDK 11
uses: actions/setup-java@v3.11.0
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
uses: ./.github/actions/setup-java
-
name: Bump version in gradle.properties
run: |-
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/helm-chart-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ jobs:

steps:
# fetch-depth: 0 is required to determine differences in chart(s)
- name: Checkout
uses: actions/checkout@v3
- uses: ./.github/actions/checkout
with:
fetch-depth: 0

Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/helm-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ jobs:
### Set-Up ###
##############
-
name: Checkout
uses: actions/checkout@v3.3.0
uses: ./.github/actions/checkout
with:
fetch-depth: 0
-
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/kics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
security-events: write

steps:
- uses: actions/checkout@v3.3.0
- uses: ./.github/actions/checkout

- name: KICS scan
uses: checkmarx/kics-github-action@v1.5
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/publish-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ jobs:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: ./.github/actions/checkout
- uses: ./.github/actions/publish-docker-image
with:
rootDir: edc-controlplane/${{ matrix.name }}
Expand All @@ -74,8 +73,7 @@ jobs:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: ./.github/actions/checkout
- uses: ./.github/actions/publish-docker-image
with:
rootDir: edc-dataplane/${{ matrix.name }}
Expand Down
23 changes: 5 additions & 18 deletions .github/workflows/publish-new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,9 @@ jobs:
run: |
echo "RELEASE_VERSION=${{ needs.release-version.outputs.RELEASE_VERSION }}" >> $GITHUB_ENV
-
name: Checkout
uses: actions/checkout@v3.3.0
uses: ./.github/actions/checkout
-
name: Set up JDK 11
uses: actions/setup-java@v3.11.0
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
uses: ./.github/actions/setup-java

- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@v5
Expand Down Expand Up @@ -96,8 +90,7 @@ jobs:
run: |
echo "RELEASE_VERSION=${{ needs.release-version.outputs.RELEASE_VERSION }}" >> $GITHUB_ENV
-
name: Checkout
uses: actions/checkout@v3.3.0
uses: ./.github/actions/checkout
with:
fetch-depth: 0
-
Expand Down Expand Up @@ -144,8 +137,7 @@ jobs:
run: |
echo "RELEASE_VERSION=${{ needs.release-version.outputs.RELEASE_VERSION }}" >> $GITHUB_ENV
-
name: Checkout
uses: actions/checkout@v3.3.0
uses: ./.github/actions/checkout
with:
# 0 to fetch the full history due to upcoming merge of releases into main branch
fetch-depth: 0
Expand Down Expand Up @@ -177,12 +169,7 @@ jobs:
draft: false
prerelease: false
-
name: Set up JDK 11
uses: actions/setup-java@v3.11.0
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
uses: ./.github/actions/setup-java
-
name: Merge releases back into main and set new snapshot version
if: github.event.pull_request.base.ref == 'releases'
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ jobs:
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v3.3.0
- uses: ./.github/actions/checkout
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@master
with:
Expand Down Expand Up @@ -72,8 +71,7 @@ jobs:
- edc-dataplane-azure-vault
- edc-dataplane-hashicorp-vault
steps:
- name: Checkout
uses: actions/checkout@v3.3.0
- uses: ./.github/actions/checkout

## This step will fail if the docker images is not found
- name: "Check if image exists"
Expand Down
30 changes: 6 additions & 24 deletions .github/workflows/veracode.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,10 @@ jobs:
verify-formatting:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3.3.0
- uses: ./.github/actions/checkout
with:
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v3.11.0
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- uses: ./.github/actions/setup-java
- name: Verify proper formatting
run: ./gradlew spotlessCheck

Expand All @@ -51,14 +45,8 @@ jobs:
- edc-controlplane-postgresql-hashicorp-vault
steps:
# Set-Up
- name: Checkout
uses: actions/checkout@v3.3.0
- name: Set up JDK 11
uses: actions/setup-java@v3.11.0
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- uses: ./.github/actions/checkout
- uses: ./.github/actions/setup-java
# Build
- name: Build Controlplane
run: |-
Expand Down Expand Up @@ -95,14 +83,8 @@ jobs:
- edc-dataplane-hashicorp-vault
steps:
# Set-Up
- name: Checkout
uses: actions/checkout@v3.3.0
- name: Set up JDK 11
uses: actions/setup-java@v3.11.0
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- uses: ./.github/actions/checkout
- uses: ./.github/actions/setup-java
# Build
- name: Build Dataplane
run: |-
Expand Down
Loading