From b712c1f249f9251b2871cd7d2d9666113a1514ef Mon Sep 17 00:00:00 2001 From: appiepollo14 Date: Tue, 7 Nov 2023 16:09:51 +0100 Subject: [PATCH] Updates GitHub Actions (#298) Co-authored-by: Kyle Aure --- .github/workflows/microshed-ci.yml | 113 +++++++----------- sample-apps/everything-app/Dockerfile | 1 - sample-apps/jaxrs-basicauth/Dockerfile | 16 +-- sample-apps/jaxrs-json/Dockerfile | 16 +-- .../java/org/example/app/JaxrsJsonIT.java | 34 +++--- sample-apps/jaxrs-mpjwt/Dockerfile | 16 +-- sample-apps/kafka-app/Dockerfile | 1 - sample-apps/maven-app/Dockerfile | 13 -- .../test/java/org/example/app/PayaraIT.java} | 10 +- .../test/java/org/example/app/WildFlyIT.java} | 2 +- 10 files changed, 69 insertions(+), 153 deletions(-) rename sample-apps/{wildfly-app/src/test/java/org/example/app/JaxrsJsonIT.java => payara-app/src/test/java/org/example/app/PayaraIT.java} (99%) rename sample-apps/{payara-app/src/test/java/org/example/app/JaxrsJsonIT.java => wildfly-app/src/test/java/org/example/app/WildFlyIT.java} (99%) diff --git a/.github/workflows/microshed-ci.yml b/.github/workflows/microshed-ci.yml index a2f93097..08d3d0c9 100644 --- a/.github/workflows/microshed-ci.yml +++ b/.github/workflows/microshed-ci.yml @@ -1,6 +1,7 @@ name: MicroShed CI on: + push: pull_request: branches: - main @@ -17,26 +18,23 @@ env: LANG: en_US.UTF-8 jobs: build: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest ] + java: [ 11 ] + fail-fast: false + max-parallel: 4 + name: Build ${{ matrix.java }}, ${{ matrix.os }} + steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Set up Java - uses: joschi/setup-jdk@v2 - with: - java-version: 11 - openjdk_impl: openj9 - - name: Apply repository caches - uses: actions/cache@v2 + uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0 with: - path: | - ~/.gradle/caches/modules-2 - !~/.gradle/caches/modules-2/org.microshed* - ~/.gradle/wrapper - ~/.m2/repository/ - !~/.m2/repository/org/microshed/ - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-gradle- + java-version: ${{ matrix.java }} + distribution: 'temurin' + cache: gradle - name: Build with Gradle run: | chmod +x gradlew @@ -44,6 +42,7 @@ jobs: integration_tests: name: Tests - ${{matrix.category}} runs-on: ubuntu-latest + needs: build timeout-minutes: 20 strategy: fail-fast: false @@ -71,54 +70,32 @@ jobs: quarkus-app wildfly-app steps: - - uses: actions/checkout@v2 - - name: Set up Java - uses: joschi/setup-jdk@v2 - with: - java-version: 11 - openjdk_impl: openj9 - - uses: testspace-com/setup-testspace@v1 - with: - domain: ${{ github.repository_owner }} - - name: Apply repository caches - uses: actions/cache@v2 - with: - path: | - ~/.gradle/caches/modules-2 - !~/.gradle/caches/modules-2/org.microshed* - ~/.gradle/wrapper - ~/.m2/repository/ - !~/.m2/repository/org/microshed/ - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-gradle- - - name: Run integration tests - shell: bash - env: - TEST_PROJECTS: ${{matrix.projects}} - CATEGORY: ${{matrix.category}} - run: | - chmod +x gradlew - echo "org.gradle.daemon=false" >> gradle.properties - - echo "Will be running projects $TEST_PROJECTS" - for TEST_PROJECT in $TEST_PROJECTS - do - if [[ ! -d "sample-apps/$TEST_PROJECT" ]]; then - echo "::error::Test project $TEST_PROJECT does not exist."; - exit 1; - fi - done - - for TEST_PROJECT in $TEST_PROJECTS - do - echo "### BEGIN running test project $TEST_PROJECT" - ./gradlew :microshed-testing-$TEST_PROJECT:test - echo "### END running test project $TEST_PROJECT"; - done - - echo "Done running all tests." - - name: Upload test results - if: always() - run: | - testspace [${{matrix.category}}]sample-apps/*/build/test-results/**/*.xml + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: Set up Java + uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0 + with: + java-version: 11 + distribution: 'temurin' + cache: gradle + - name: Run integration tests + shell: bash + env: + TEST_PROJECTS: ${{matrix.projects}} + CATEGORY: ${{matrix.category}} + run: | + chmod +x gradlew + echo "org.gradle.daemon=false" >> gradle.properties + + echo "Will be running projects $TEST_PROJECTS" + for TEST_PROJECT in $TEST_PROJECTS + do + if [[ ! -d "sample-apps/$TEST_PROJECT" ]]; then + echo "::error::Test project $TEST_PROJECT does not exist."; + exit 1; + fi + echo "### BEGIN running test project $TEST_PROJECT" + ./gradlew :microshed-testing-$TEST_PROJECT:test + echo "### END running test project $TEST_PROJECT"; + done + + echo "Done running all tests." diff --git a/sample-apps/everything-app/Dockerfile b/sample-apps/everything-app/Dockerfile index 1cab519a..b4723e47 100644 --- a/sample-apps/everything-app/Dockerfile +++ b/sample-apps/everything-app/Dockerfile @@ -1,4 +1,3 @@ -# OpenLiberty FROM openliberty/open-liberty:full-java8-openj9-ubi COPY src/main/liberty/config /config/ ADD build/libs/myservice.war /config/dropins/ diff --git a/sample-apps/jaxrs-basicauth/Dockerfile b/sample-apps/jaxrs-basicauth/Dockerfile index 50c27c39..c5175648 100644 --- a/sample-apps/jaxrs-basicauth/Dockerfile +++ b/sample-apps/jaxrs-basicauth/Dockerfile @@ -1,17 +1,3 @@ -# OpenLiberty FROM openliberty/open-liberty:full-java8-openj9-ubi COPY src/main/liberty/config /config/ -ADD build/libs/myservice.war /config/apps/ - -# Wildfly -#FROM jboss/wildfly -#ADD build/libs/myservice.war /opt/jboss/wildfly/standalone/deployments/ - -# Payara -#FROM payara/micro:5.193 -#CMD ["--deploymentDir", "/opt/payara/deployments", "--noCluster"] -#ADD build/libs/myservice.war /opt/payara/deployments - -# TomEE -#FROM tomee:8-jre-8.0.0-M2-microprofile -#COPY build/libs/myservice.war /usr/local/tomee/webapps/ +ADD build/libs/myservice.war /config/apps/ \ No newline at end of file diff --git a/sample-apps/jaxrs-json/Dockerfile b/sample-apps/jaxrs-json/Dockerfile index 16562cae..92c77ac4 100644 --- a/sample-apps/jaxrs-json/Dockerfile +++ b/sample-apps/jaxrs-json/Dockerfile @@ -1,17 +1,3 @@ -# OpenLiberty FROM openliberty/open-liberty:full-java8-openj9-ubi COPY src/main/liberty/config /config/ -ADD build/libs/myservice.war /config/dropins/ - -# Wildfly -#FROM jboss/wildfly -#ADD build/libs/myservice.war /opt/jboss/wildfly/standalone/deployments/ - -# Payara -#FROM payara/micro:5.193 -#CMD ["--deploymentDir", "/opt/payara/deployments", "--noCluster"] -#ADD build/libs/myservice.war /opt/payara/deployments - -# TomEE -#FROM tomee:8-jre-8.0.0-M2-microprofile -#COPY build/libs/myservice.war /usr/local/tomee/webapps/ +ADD build/libs/myservice.war /config/dropins/ \ No newline at end of file diff --git a/sample-apps/jaxrs-json/src/test/java/org/example/app/JaxrsJsonIT.java b/sample-apps/jaxrs-json/src/test/java/org/example/app/JaxrsJsonIT.java index 789ef4cb..091b86be 100644 --- a/sample-apps/jaxrs-json/src/test/java/org/example/app/JaxrsJsonIT.java +++ b/sample-apps/jaxrs-json/src/test/java/org/example/app/JaxrsJsonIT.java @@ -18,34 +18,30 @@ */ package org.example.app; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.util.Collection; - -import javax.ws.rs.BadRequestException; -import javax.ws.rs.NotFoundException; -import javax.ws.rs.ProcessingException; - import org.junit.jupiter.api.Test; import org.microshed.testing.jaxrs.RESTClient; import org.microshed.testing.jupiter.MicroShedTest; import org.microshed.testing.testcontainers.ApplicationContainer; import org.testcontainers.junit.jupiter.Container; +import javax.ws.rs.BadRequestException; +import javax.ws.rs.NotFoundException; +import javax.ws.rs.ProcessingException; +import java.util.Collection; + +import static org.junit.jupiter.api.Assertions.*; + @MicroShedTest public class JaxrsJsonIT { - + @Container public static ApplicationContainer app = new ApplicationContainer() - .withAppContextRoot("/myservice") - .withReadinessPath("/myservice/app/people"); - + .withAppContextRoot("/myservice") + .withReadinessPath("/myservice/app/people"); + @RESTClient public static PersonService personSvc; - + @Test public void testCreatePerson() { Long createId = personSvc.createPerson("Hank", 42); @@ -56,14 +52,14 @@ public void testCreatePerson() { public void testMinSizeName() { Long minSizeNameId = personSvc.createPerson("Ha", 42); assertEquals(new Person("Ha", 42, minSizeNameId), - personSvc.getPerson(minSizeNameId)); + personSvc.getPerson(minSizeNameId)); } @Test public void testMinAge() { Long minAgeId = personSvc.createPerson("Newborn", 0); assertEquals(new Person("Newborn", 0, minAgeId), - personSvc.getPerson(minAgeId)); + personSvc.getPerson(minAgeId)); } @Test @@ -127,7 +123,7 @@ public void testCreateBadPersonNegativeAge() { public void testCreateBadPersonNameTooLong() { assertThrows(BadRequestException.class, () -> personSvc.createPerson("NameTooLongPersonNameTooLongPersonNameTooLongPerson", 5)); } - + @Test public void testNonJaxrsMethod() { assertThrows(ProcessingException.class, () -> personSvc.nonJaxrsMethod()); diff --git a/sample-apps/jaxrs-mpjwt/Dockerfile b/sample-apps/jaxrs-mpjwt/Dockerfile index 16562cae..92c77ac4 100644 --- a/sample-apps/jaxrs-mpjwt/Dockerfile +++ b/sample-apps/jaxrs-mpjwt/Dockerfile @@ -1,17 +1,3 @@ -# OpenLiberty FROM openliberty/open-liberty:full-java8-openj9-ubi COPY src/main/liberty/config /config/ -ADD build/libs/myservice.war /config/dropins/ - -# Wildfly -#FROM jboss/wildfly -#ADD build/libs/myservice.war /opt/jboss/wildfly/standalone/deployments/ - -# Payara -#FROM payara/micro:5.193 -#CMD ["--deploymentDir", "/opt/payara/deployments", "--noCluster"] -#ADD build/libs/myservice.war /opt/payara/deployments - -# TomEE -#FROM tomee:8-jre-8.0.0-M2-microprofile -#COPY build/libs/myservice.war /usr/local/tomee/webapps/ +ADD build/libs/myservice.war /config/dropins/ \ No newline at end of file diff --git a/sample-apps/kafka-app/Dockerfile b/sample-apps/kafka-app/Dockerfile index 46972571..64fce451 100644 --- a/sample-apps/kafka-app/Dockerfile +++ b/sample-apps/kafka-app/Dockerfile @@ -1,4 +1,3 @@ -# OpenLiberty FROM openliberty/open-liberty:full-java8-openj9-ubi COPY src/main/liberty/config /config/ ADD build/libs/myservice.war /config/apps/ diff --git a/sample-apps/maven-app/Dockerfile b/sample-apps/maven-app/Dockerfile index 016967c1..860d1b43 100644 --- a/sample-apps/maven-app/Dockerfile +++ b/sample-apps/maven-app/Dockerfile @@ -1,16 +1,3 @@ FROM openliberty/open-liberty:full-java8-openj9-ubi COPY src/main/liberty/config /config/ ADD target/myservice.war /config/dropins/ - -# Wildfly -#FROM jboss/wildfly -#ADD target/myservice.war /opt/jboss/wildfly/standalone/deployments/ - -# Payara -#FROM payara/micro:5.193 -#CMD ["--deploymentDir", "/opt/payara/deployments", "--noCluster"] -#ADD target/myservice.war /opt/payara/deployments - -# TomEE -#FROM tomee:8-jre-8.0.0-M2-microprofile -#COPY target/myservice.war /usr/local/tomee/webapps/ diff --git a/sample-apps/wildfly-app/src/test/java/org/example/app/JaxrsJsonIT.java b/sample-apps/payara-app/src/test/java/org/example/app/PayaraIT.java similarity index 99% rename from sample-apps/wildfly-app/src/test/java/org/example/app/JaxrsJsonIT.java rename to sample-apps/payara-app/src/test/java/org/example/app/PayaraIT.java index 789ef4cb..8987c3e4 100644 --- a/sample-apps/wildfly-app/src/test/java/org/example/app/JaxrsJsonIT.java +++ b/sample-apps/payara-app/src/test/java/org/example/app/PayaraIT.java @@ -36,16 +36,16 @@ import org.testcontainers.junit.jupiter.Container; @MicroShedTest -public class JaxrsJsonIT { - +public class PayaraIT { + @Container public static ApplicationContainer app = new ApplicationContainer() .withAppContextRoot("/myservice") .withReadinessPath("/myservice/app/people"); - + @RESTClient public static PersonService personSvc; - + @Test public void testCreatePerson() { Long createId = personSvc.createPerson("Hank", 42); @@ -127,7 +127,7 @@ public void testCreateBadPersonNegativeAge() { public void testCreateBadPersonNameTooLong() { assertThrows(BadRequestException.class, () -> personSvc.createPerson("NameTooLongPersonNameTooLongPersonNameTooLongPerson", 5)); } - + @Test public void testNonJaxrsMethod() { assertThrows(ProcessingException.class, () -> personSvc.nonJaxrsMethod()); diff --git a/sample-apps/payara-app/src/test/java/org/example/app/JaxrsJsonIT.java b/sample-apps/wildfly-app/src/test/java/org/example/app/WildFlyIT.java similarity index 99% rename from sample-apps/payara-app/src/test/java/org/example/app/JaxrsJsonIT.java rename to sample-apps/wildfly-app/src/test/java/org/example/app/WildFlyIT.java index 789ef4cb..95b17226 100644 --- a/sample-apps/payara-app/src/test/java/org/example/app/JaxrsJsonIT.java +++ b/sample-apps/wildfly-app/src/test/java/org/example/app/WildFlyIT.java @@ -36,7 +36,7 @@ import org.testcontainers.junit.jupiter.Container; @MicroShedTest -public class JaxrsJsonIT { +public class WildFlyIT { @Container public static ApplicationContainer app = new ApplicationContainer()