From 67933c775add8a9329ce61313067ec1add726dcc Mon Sep 17 00:00:00 2001 From: Mohammad Faisal Khatri Date: Thu, 2 Mar 2023 16:45:19 +0530 Subject: [PATCH 1/5] created maven workflow file for githubactions --- .github/workflows/maven.yml | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/maven.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..6cd7f0c --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,46 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Java CI with Maven + +on: + push: + branches: + - master + - issue-* + +jobs: + build: + name: Build and Test + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' + cache: maven + + - name: Start restful booker service + run: docker-compose -f ./docker-compose-restfulbooker.yml up -d + + - name: Build with Maven and run tests + run: mvn clean install + + - name: Stop restful booker service + run: docker-compose -f ./docker-compose-restfulbooker.yml down --remove-orphans + + - name: Test Report + uses: dorny/test-reporter@v1 + if: always() + with: + name: Test Results + path: ./target/surefire-reports/TEST-TestSuite.xml + reporter: java-junit From fbf352c571a0c95c8116d1e01bf99f5fc6ea9929 Mon Sep 17 00:00:00 2001 From: Mohammad Faisal Khatri Date: Thu, 2 Mar 2023 16:50:07 +0530 Subject: [PATCH 2/5] updated test report config for maven workflow --- .github/workflows/maven.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 6cd7f0c..0311b40 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -42,5 +42,6 @@ jobs: if: always() with: name: Test Results - path: ./target/surefire-reports/TEST-TestSuite.xml + path: ${{ github.workspace }}/target/surefire-reports/TEST-TestSuite.xml reporter: java-junit + java-version: 11 From 2c7695d18cca4b631b6cf3fc50b94ee81bfee3ca Mon Sep 17 00:00:00 2001 From: "mohammadfaisalkhatri@gmail.com" Date: Thu, 2 Mar 2023 17:01:22 +0530 Subject: [PATCH 3/5] updated maven workflow file --- .github/workflows/maven.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 0311b40..7fcb8b3 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -31,17 +31,19 @@ jobs: - name: Start restful booker service run: docker-compose -f ./docker-compose-restfulbooker.yml up -d - - name: Build with Maven and run tests - run: mvn clean install + - name: Build Project + run: mvn clean install -Dskiptests + + - name: Run tests + run: mvn clean test - name: Stop restful booker service run: docker-compose -f ./docker-compose-restfulbooker.yml down --remove-orphans - - name: Test Report - uses: dorny/test-reporter@v1 + - name: Test Reporter + uses: dorny/test-reporter@v1.6.0 if: always() with: name: Test Results - path: ${{ github.workspace }}/target/surefire-reports/TEST-TestSuite.xml + path: target/surefire-reports/*.xml reporter: java-junit - java-version: 11 From 87b0d4df0d8bcba3b78748dd1beeef0ea2e715de Mon Sep 17 00:00:00 2001 From: "mohammadfaisalkhatri@gmail.com" Date: Thu, 2 Mar 2023 17:05:48 +0530 Subject: [PATCH 4/5] command updated to skip tests while building project, updated test suite file path for test reporter --- .github/workflows/maven.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 7fcb8b3..0eac5bd 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -32,7 +32,7 @@ jobs: run: docker-compose -f ./docker-compose-restfulbooker.yml up -d - name: Build Project - run: mvn clean install -Dskiptests + run: mvn clean install -DskipTests - name: Run tests run: mvn clean test @@ -45,5 +45,5 @@ jobs: if: always() with: name: Test Results - path: target/surefire-reports/*.xml + path: target/surefire-reports/TEST-TestSuite.xml reporter: java-junit From 1daf6f824be1a15be14e6f94cbbf58a75cfdbd6d Mon Sep 17 00:00:00 2001 From: "mohammadfaisalkhatri@gmail.com" Date: Thu, 2 Mar 2023 17:11:02 +0530 Subject: [PATCH 5/5] added permission block in maven workflow for test reporterto work --- .github/workflows/maven.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 0eac5bd..7a7c18c 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -14,6 +14,12 @@ on: - master - issue-* +permissions: + statuses: write + checks: write + contents: write + pull-requests: write + jobs: build: name: Build and Test