From 537d3d39b9eb05b892e93221fe013b27bed57db9 Mon Sep 17 00:00:00 2001 From: Paul Latzelsperger Date: Thu, 18 May 2023 11:56:40 +0200 Subject: [PATCH 1/5] build: add verification job to probe for license headers --- .github/workflows/verify.yaml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/verify.yaml b/.github/workflows/verify.yaml index 0eb686260..4c74c07a6 100644 --- a/.github/workflows/verify.yaml +++ b/.github/workflows/verify.yaml @@ -42,7 +42,18 @@ concurrency: cancel-in-progress: true jobs: - + + verify-license-headers: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3.5.2 + - name: "Check for files without a license header" + run: |- + # checks all java, yaml, kts and sql files for an Apache 2.0 license header + if grep -riL "SPDX-License-Identifier: Apache-2.0" --include=\*.{java,yaml,yml,kts,sql} --exclude-dir={.gradle,\*\openapi} . ; then + echo "Files without headers were found"; exit 1 + fi + verify-formatting: runs-on: ubuntu-latest steps: From 405dbca40cbf3ab0779d36505add07cdca5ec6ee Mon Sep 17 00:00:00 2001 From: Paul Latzelsperger Date: Thu, 18 May 2023 12:23:41 +0200 Subject: [PATCH 2/5] remove unneeded classes --- .github/workflows/verify.yaml | 2 +- .../tractusx/edc/lifecycle/provider/ProviderEdcController.java | 2 -- .../edc/lifecycle/provider/ProviderServicesExtension.java | 2 -- 3 files changed, 1 insertion(+), 5 deletions(-) delete mode 100644 edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/lifecycle/provider/ProviderEdcController.java delete mode 100644 edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/lifecycle/provider/ProviderServicesExtension.java diff --git a/.github/workflows/verify.yaml b/.github/workflows/verify.yaml index 4c74c07a6..32481cfa2 100644 --- a/.github/workflows/verify.yaml +++ b/.github/workflows/verify.yaml @@ -50,7 +50,7 @@ jobs: - name: "Check for files without a license header" run: |- # checks all java, yaml, kts and sql files for an Apache 2.0 license header - if grep -riL "SPDX-License-Identifier: Apache-2.0" --include=\*.{java,yaml,yml,kts,sql} --exclude-dir={.gradle,\*\openapi} . ; then + if [[ $(grep -riL "SPDX-License-Identifier: Apache-2.0" --include=\*.{java,yaml,yml,kts,sql} --exclude-dir={.gradle,\*\openapi} .) -ne 0 ]] ; then echo "Files without headers were found"; exit 1 fi diff --git a/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/lifecycle/provider/ProviderEdcController.java b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/lifecycle/provider/ProviderEdcController.java deleted file mode 100644 index 8ea80e745..000000000 --- a/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/lifecycle/provider/ProviderEdcController.java +++ /dev/null @@ -1,2 +0,0 @@ -package org.eclipse.tractusx.edc.lifecycle.provider;public class ProviderEdcController { -} diff --git a/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/lifecycle/provider/ProviderServicesExtension.java b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/lifecycle/provider/ProviderServicesExtension.java deleted file mode 100644 index 526ff6872..000000000 --- a/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/lifecycle/provider/ProviderServicesExtension.java +++ /dev/null @@ -1,2 +0,0 @@ -package org.eclipse.tractusx.edc.lifecycle.provider;public class ProviderServicesExtension { -} From a108b0f45b2ef8f0483b3cc7e4d86dca41c2d4d0 Mon Sep 17 00:00:00 2001 From: Paul Latzelsperger Date: Thu, 18 May 2023 12:36:16 +0200 Subject: [PATCH 3/5] improved the command --- .github/workflows/verify.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/verify.yaml b/.github/workflows/verify.yaml index 32481cfa2..03185e453 100644 --- a/.github/workflows/verify.yaml +++ b/.github/workflows/verify.yaml @@ -50,8 +50,12 @@ jobs: - name: "Check for files without a license header" run: |- # checks all java, yaml, kts and sql files for an Apache 2.0 license header - if [[ $(grep -riL "SPDX-License-Identifier: Apache-2.0" --include=\*.{java,yaml,yml,kts,sql} --exclude-dir={.gradle,\*\openapi} .) -ne 0 ]] ; then - echo "Files without headers were found"; exit 1 + result=$(grep -riL "SPDX-License-Identifier: Apache-2.0" --include=\*.{java,yaml,yml,kts,sql} --exclude-dir={.gradle,\*\openapi} .) + violations=$(echo $result | wc -l) + if [[ $violations -ne 0 ]] ; then + echo "$violations files without license headers were found:"; + echo $result; + exit 1; fi verify-formatting: From e9b3da7b83c3e94927dcf1eb55a2b12602aa1a58 Mon Sep 17 00:00:00 2001 From: Paul Latzelsperger Date: Thu, 18 May 2023 12:40:41 +0200 Subject: [PATCH 4/5] make tests dependent on lic-header check --- .github/workflows/verify.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/verify.yaml b/.github/workflows/verify.yaml index 03185e453..9dcb8a4d0 100644 --- a/.github/workflows/verify.yaml +++ b/.github/workflows/verify.yaml @@ -86,7 +86,7 @@ jobs: unit-tests: runs-on: ubuntu-latest - needs: [ verify-formatting ] + needs: [ verify-formatting, verify-license-headers ] steps: - uses: actions/checkout@v3.5.2 @@ -97,7 +97,7 @@ jobs: integration-tests: runs-on: ubuntu-latest - needs: [ verify-formatting ] + needs: [ verify-formatting, verify-license-headers ] steps: - uses: actions/checkout@v3.5.2 @@ -108,7 +108,7 @@ jobs: api-tests: runs-on: ubuntu-latest - needs: [ verify-formatting ] + needs: [ verify-formatting, verify-license-headers ] steps: - uses: actions/checkout@v3.5.2 @@ -119,7 +119,7 @@ jobs: end-to-end-tests: runs-on: ubuntu-latest - needs: [ verify-formatting ] + needs: [ verify-formatting, verify-license-headers ] steps: - uses: actions/checkout@v3.5.2 From 7ba817e62d68aacd2f39142ff07f2c23d0f7498f Mon Sep 17 00:00:00 2001 From: Paul Latzelsperger Date: Thu, 18 May 2023 12:47:34 +0200 Subject: [PATCH 5/5] fix CI --- .github/workflows/verify.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/verify.yaml b/.github/workflows/verify.yaml index 9dcb8a4d0..310c78527 100644 --- a/.github/workflows/verify.yaml +++ b/.github/workflows/verify.yaml @@ -50,11 +50,11 @@ jobs: - name: "Check for files without a license header" run: |- # checks all java, yaml, kts and sql files for an Apache 2.0 license header - result=$(grep -riL "SPDX-License-Identifier: Apache-2.0" --include=\*.{java,yaml,yml,kts,sql} --exclude-dir={.gradle,\*\openapi} .) - violations=$(echo $result | wc -l) + cmd="grep -riL \"SPDX-License-Identifier: Apache-2.0\" --include=\*.{java,yaml,yml,kts,sql} --exclude-dir={.gradle,\*\openapi} ." + violations=$(eval $cmd | wc -l) if [[ $violations -ne 0 ]] ; then echo "$violations files without license headers were found:"; - echo $result; + eval $cmd; exit 1; fi