From de9f59ec4707e58508a0384f00e1679d86c9092f Mon Sep 17 00:00:00 2001 From: Peter Palaga Date: Thu, 14 Mar 2024 18:27:55 +0100 Subject: [PATCH] Put the build-and-run-jvm-tests into a composite action --- .../build-and-run-jvm-tests/action.yml | 80 +++++++++++++ .github/actions/run-native-test/action.yml | 49 ++++++++ .github/workflows/build.yml | 106 ++---------------- 3 files changed, 138 insertions(+), 97 deletions(-) create mode 100644 .github/actions/build-and-run-jvm-tests/action.yml create mode 100644 .github/actions/run-native-test/action.yml diff --git a/.github/actions/build-and-run-jvm-tests/action.yml b/.github/actions/build-and-run-jvm-tests/action.yml new file mode 100644 index 000000000..dde1382af --- /dev/null +++ b/.github/actions/build-and-run-jvm-tests/action.yml @@ -0,0 +1,80 @@ +name: build-and-run-jvm-tests +description: 'Build the project and run JVM tests' + +inputs: + java-version: + description: 'Java version' + required: true + +runs: + using: 'composite' + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK ${{ inputs.java-version }} + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: ${{ inputs.java-version }} + + - name: Cache local Maven repository + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Build CXF + if: github.ref == 'refs/heads/cxf-main' || github.base_ref == 'cxf-main' || github.head_ref == 'cxf-main' + shell: bash + run: | + cd ~ + [[ -d "cxf" ]] || git clone --depth 1 --branch main https://github.com/apache/cxf.git + cd cxf \ + && echo "Current CXF commit:" $(git rev-parse HEAD) \ + && mvn clean install -DskipTests -Dcheckstyle.skip -ntp + - name: Build Quarkus + if: github.ref == 'refs/heads/quarkus-main' || github.base_ref == 'quarkus-main' || github.head_ref == 'quarkus-main' + shell: bash + run: | + cd ~ + [[ -d "quarkus" ]] || git clone --depth 1 --branch main https://github.com/quarkusio/quarkus.git + cd quarkus \ + && echo "Current Quarkus commit:" $(git rev-parse HEAD) \ + && sed -i '/integration-tests<\/module>/d' pom.xml \ + && ./mvnw clean install -Dquickly -ntp + + - name: Ensure mvn cq:sync-versions -N causes no changes + shell: bash + run: | + ./mvnw cq:sync-versions -Dcq.simpleElementWhitespace=AUTODETECT_PREFER_SPACE -N + [[ -z $(git status --porcelain | grep -v antora.yml) ]] || { echo 'There are uncommitted changes'; git status; git diff; exit 1; } + + - name: mvn -B formatter:validate install + shell: bash + run: ./mvnw -B formatter:validate install -fae + + - name: 'Upload generated Antora docs site' + uses: actions/upload-artifact@v4 + with: + name: docs + path: docs/target/site + + - name: Fail if there are uncommitted changes + shell: bash + run: | + [[ -z $(git status --porcelain | grep -v antora.yml) ]] || { echo 'There are uncommitted changes'; git status; git diff; exit 1; } + + - name: Tar Maven Repo + shell: bash + run: | + tar -czf ${{ runner.temp }}/maven-repo.tgz -C ~ .m2/repository + # Avoid caching our own artifacts + rm -Rf ~/.m2/repository/io/quarkiverse/cxf + - name: Persist Maven Repo + uses: actions/upload-artifact@v4 + with: + name: maven-repo + path: ${{ runner.temp }}/maven-repo.tgz + retention-days: 1 diff --git a/.github/actions/run-native-test/action.yml b/.github/actions/run-native-test/action.yml new file mode 100644 index 000000000..f6ac6f5d6 --- /dev/null +++ b/.github/actions/run-native-test/action.yml @@ -0,0 +1,49 @@ +name: run-native-test +description: 'Run a specific native test' + +inputs: + java-version: + description: 'Java version' + required: true + test-module-spec: + description: 'Name of the test module to run optionally followed by some build arguments' + required: true + +runs: + using: 'composite' + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK ${{ inputs.java-version }} + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: ${{ inputs.java-version }} + + - name: Download Maven Repo + uses: actions/download-artifact@v4 + with: + name: maven-repo + path: .. + - name: Extract Maven Repo + shell: bash + run: | + tar -xzf ../maven-repo.tgz -C ~ + + - name: Run integration test ${{ inputs.test-module-spec }} + shell: bash + # Skip native tests for CodeQL Security Scans + if: "${{ env.SKIP_NATIVE_TESTS != 'true' }}" + run: | + array=(${{ inputs.test-module-spec }}) + if [ "${array[0]}" == "ws-rm-client" ]; then + # ws-rm-client requires test-ws-rm-server-native executable + cd test-util-parent/test-ws-rm-server-native && ../../mvnw -B clean install -Pnative + cd ../.. + fi + if [ "${#array[@]}" -gt "1" ]; then + additionalArgs=("${array[@]:1}") + cd integration-tests/${array[0]} && ../../mvnw -B verify -Pnative -Dquarkus.native.container-build=true "${additionalArgs[@]}" + else + cd integration-tests/${array[0]} && ../../mvnw -B verify -Pnative -Dquarkus.native.container-build=true + fi diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 56ac5a6a3..0ffa3dc47 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,7 @@ on: env: QUARKUS_CXF_MTOM_LARGE_ATTACHMENT_INCREMENT_KB: 512 + JAVA_VERSION: 17 concurrency: group: ${{ github.ref }}-${{ github.workflow }} @@ -16,73 +17,12 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 17 - - - name: Cache local Maven repository - uses: actions/cache@v4 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - - name: Build CXF - if: github.ref == 'refs/heads/cxf-main' || github.base_ref == 'cxf-main' || github.head_ref == 'cxf-main' - run: | - cd ~ - git clone --depth 1 --branch main https://github.com/apache/cxf.git \ - && cd cxf \ - && echo "Current CXF commit:" $(git rev-parse HEAD) \ - && sed -i 's|3.0.3-SNAPSHOT|3.0.3|' rt/ws/security/pom.xml \ - && mvn clean install -DskipTests -Dcheckstyle.skip -ntp - - name: Build Quarkus - if: github.ref == 'refs/heads/quarkus-main' || github.base_ref == 'quarkus-main' || github.head_ref == 'quarkus-main' - run: | - cd ~ - git clone --depth 1 --branch main https://github.com/quarkusio/quarkus.git \ - && cd quarkus \ - && echo "Current Quarkus commit:" $(git rev-parse HEAD) \ - && sed -i '/integration-tests<\/module>/d' pom.xml \ - && ./mvnw ${CQ_MAVEN_ARGS} clean install -Dquickly -ntp - - - name: Ensure mvn cq:sync-versions -N causes no changes - shell: bash - run: | - ./mvnw cq:sync-versions -Dcq.simpleElementWhitespace=AUTODETECT_PREFER_SPACE -N - [[ -z $(git status --porcelain | grep -v antora.yml) ]] || { echo 'There are uncommitted changes'; git status; git diff; exit 1; } - - - name: mvn -B formatter:validate install - run: ./mvnw -B formatter:validate install -fae + - uses: actions/checkout@v2 - - name: 'Upload generated Antora docs site' - uses: actions/upload-artifact@v4 + - name: build-and-run-jvm-tests + uses: ./.github/actions/build-and-run-jvm-tests with: - name: docs - path: docs/target/site - - - name: Fail if there are uncommitted changes - shell: bash - run: | - [[ -z $(git status --porcelain | grep -v antora.yml) ]] || { echo 'There are uncommitted changes'; git status; git diff; exit 1; } - - - name: Tar Maven Repo - shell: bash - run: | - tar -czf ${{ runner.temp }}/maven-repo.tgz -C ~ .m2/repository - # Avoid caching our own artifacts - rm -Rf ~/.m2/repository/io/quarkiverse/cxf - - name: Persist Maven Repo - uses: actions/upload-artifact@v4 - with: - name: maven-repo - path: ${{ runner.temp }}/maven-repo.tgz - retention-days: 1 + java-version: ${{ env.JAVA_VERSION }} native-tests: strategy: @@ -94,36 +34,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - - name: Set up JDK 17 - uses: actions/setup-java@v4 + - name: run-native-test + uses: ./.github/actions/run-native-test with: - distribution: temurin - java-version: 17 - - - name: Download Maven Repo - uses: actions/download-artifact@v4 - with: - name: maven-repo - path: .. - - name: Extract Maven Repo - shell: bash - run: | - tar -xzf ../maven-repo.tgz -C ~ - - - name: Run integration test ${{matrix.testModule}} - # Skip native tests for CodeQL Security Scans - if: "${{ env.SKIP_NATIVE_TESTS != 'true' }}" - run: | - array=(${{matrix.testModule}}) - if [ "${array[0]}" == "ws-rm-client" ]; then - # ws-rm-client requires test-ws-rm-server-native executable - cd test-util-parent/test-ws-rm-server-native && ../../mvnw -B clean install -Pnative - cd ../.. - fi - if [ "${#array[@]}" -gt "1" ]; then - additionalArgs=("${array[@]:1}") - cd integration-tests/${array[0]} && ../../mvnw -B verify -Pnative -Dquarkus.native.container-build=true "${additionalArgs[@]}" - else - cd integration-tests/${array[0]} && ../../mvnw -B verify -Pnative -Dquarkus.native.container-build=true - fi + java-version: ${{ env.JAVA_VERSION }} + test-module-spec: ${{matrix.testModule}}