From 1be884f2706b52170c329bd7f308451ce38b20d3 Mon Sep 17 00:00:00 2001 From: Anthony Dahanne Date: Thu, 21 Sep 2023 16:49:18 -0400 Subject: [PATCH] Make Java Smoke Test PR workflow generic * so that it can be used for every Java samples --- .../workflows/test-pull-request-java-akka.yml | 29 ------ .github/workflows/test-pull-request-java.yml | 94 +++++++++---------- 2 files changed, 43 insertions(+), 80 deletions(-) delete mode 100644 .github/workflows/test-pull-request-java-akka.yml diff --git a/.github/workflows/test-pull-request-java-akka.yml b/.github/workflows/test-pull-request-java-akka.yml deleted file mode 100644 index e97c201b..00000000 --- a/.github/workflows/test-pull-request-java-akka.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Test Pull Request (Akka) - -on: - merge_group: - pull_request: - branches: - - main - paths: - - java/akka/** - -jobs: - smoke: - name: Smoke Tests - runs-on: ubuntu-latest - steps: - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version: 1.18.x - - - name: Checkout - uses: actions/checkout@v4 - - - name: Test Java Samples - run: | - ./scripts/smoke.sh --suite java/akka/smoke_test \ - --builder paketobuildpacks/builder:full \ - --builder paketobuildpacks/builder:base \ - --builder paketobuildpacks/builder:tiny diff --git a/.github/workflows/test-pull-request-java.yml b/.github/workflows/test-pull-request-java.yml index 5c180c4f..ec9d3570 100644 --- a/.github/workflows/test-pull-request-java.yml +++ b/.github/workflows/test-pull-request-java.yml @@ -1,63 +1,55 @@ -name: Test Pull Request (Java) +name: Smoke Test Pull Request (Java) on: merge_group: pull_request: branches: - - main + - main paths: - - 'java/**' - - '!java/native-image/**' - - '!java/java-node/**' + - 'java/**' jobs: - smoke: - name: Smoke Tests + prepare: + name: Prepare runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.paths.outputs.matrix }} steps: - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version: 1.18.x - - - name: Checkout - uses: actions/checkout@v4 - - - name: Cache local Gradle repository - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('java/**/*.gradle*', 'java/**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: Cache local Maven repository - uses: actions/cache@v3 - with: - path: | - ~/.m2/repository - ~/.m2/wrapper - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', 'java/**/maven-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-maven- + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Discover changed paths + id: paths + run: | + env + # see: https://stackoverflow.com/a/8721550/24069 for usage of paste + changed_java_folders=$( git diff --name-only --merge-base origin/$GITHUB_BASE_REF $GITHUB_SHA | xargs -n 1 dirname | uniq | grep -v "^\." | sed "s/^/\"/;s/$/\"/" | paste -s -d, - ) + echo "These are the Java folders where we found changes for this PR : $changed_java_folders" >> $GITHUB_STEP_SUMMARY + echo "matrix={\"java_sample_folder\":[$changed_java_folders]}" >> $GITHUB_OUTPUT + echo "This is how the matrix will look like: $(cat $GITHUB_OUTPUT)" - - name: Setup Directories - run: | - #!/usr/bin/env bash - set -euo pipefail - - mkdir -p ~/.m2/repository - mkdir -p ~/.m2/repository/wrapper/dists - mkdir -p ~/.gradle/caches - mkdir -p ~/.gradle/wrapper/dists - chmod -R 775 ~/.m2 - chmod -R 775 ~/.gradle + smoke: + needs: prepare + name: Smoke Tests + runs-on: ubuntu-latest + strategy: + matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }} + # java_sample_folder: - - name: Test Java Samples - run: | - ./scripts/smoke.sh --suite java \ - --builder paketobuildpacks/builder:full \ - --builder paketobuildpacks/builder:base \ - --builder paketobuildpacks/builder:tiny + steps: + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: 1.18.x + + - name: Checkout + uses: actions/checkout@v4 + + - name: Smoke Test Java samples + run: | + echo "About to run the smoke test script against this suite folder: ${{ matrix.java_sample_folder }}/smoke_test" + ./scripts/smoke.sh --suite ${{ matrix.java_sample_folder }}/smoke_test \ + --builder paketobuildpacks/builder:full \ + --builder paketobuildpacks/builder:base \ + --builder paketobuildpacks/builder:tiny