From 73996a37cce122f8830c1fb35f5d6ae1f3a90cc1 Mon Sep 17 00:00:00 2001 From: Ondrej Dockal Date: Wed, 18 Aug 2021 21:37:25 +0200 Subject: [PATCH] Introduce github actions PR check job, fixes #2131 Signed-off-by: Ondrej Dockal --- .github/workflows/build_test.yml | 55 +++++++++++++++++++++++++++ .github/workflows/publish_reports.yml | 49 ++++++++++++++++++++++++ .gitignore | 1 + 3 files changed, 105 insertions(+) create mode 100644 .github/workflows/build_test.yml create mode 100644 .github/workflows/publish_reports.yml diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml new file mode 100644 index 0000000000..0560c3cf44 --- /dev/null +++ b/.github/workflows/build_test.yml @@ -0,0 +1,55 @@ +name: Build and Test + +on: + pull_request: + branches: [master] + +jobs: + test: + runs-on: ${{ matrix.os }} # compiles and test on Ubuntu + + strategy: + matrix: + os: [ubuntu-latest] + java: ["11"] + fail-fast: false + + steps: + - name: Checkout PR branch + uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + + # Java JDK 11 used for maven build + - name: Setup Java ${{ matrix.java }} + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk + architecture: x64 + + # Try to find and apply jbosstools cache + - name: Cache local Maven repository for RedDeer components + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: reddeer-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + reddeer-${{ runner.os }}-maven- + + # Build and compile using Maven + - name: Build/Compile and run unit tests + uses: GabrielBB/xvfb-action@v1 + with: + run: mvn clean verify -U -fae -Dmaven.test.error.ignore=true -Dmaven.test.failure.ignore=true --quiet + + # Archive artifacts to be applied in Publish Reports workflow + - name: Archiving test artifacts + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.os }}-test-reports + path: | + *tests/*/target/surefire-reports/ + */*tests/*/target/surefire-reports/ + **/*.log diff --git a/.github/workflows/publish_reports.yml b/.github/workflows/publish_reports.yml new file mode 100644 index 0000000000..2a062f8053 --- /dev/null +++ b/.github/workflows/publish_reports.yml @@ -0,0 +1,49 @@ +name: Publish reports + +on: + workflow_run: + workflows: ["Build And Test"] + types: + - completed + +jobs: + publish: + name: Publish Test Report + runs-on: ubuntu-latest + steps: + - name: Download artifacts + uses: actions/github-script@v3.1.0 + with: + script: | + var artifacts = await github.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: ${{github.event.workflow_run.id}}, + }); + for (var artifact of artifacts.data.artifacts) { + if (artifact.name.endsWith('test-reports')) { + var zipfile = await github.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: artifact.id, + archive_format: 'zip', + }); + var fs = require('fs'); + var path = require('path'); + var pathFile = path.format({ + root: '${{github.workspace}}/', + name: artifact.name, + ext: '.zip' + }); + fs.writeFileSync(pathFile, Buffer.from(zipfile.data)); + } + } + - name: Unzip artifacts + run: | + find . -name '*.zip' -exec sh -c 'unzip -d "${1%.*}" "$1"' _ {} \; + - name: Publish aggregated tests reports + uses: scacap/action-surefire-report@v1 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + report_paths: '${{github.workspace}}/*test-reports/**/TEST-*.xml' + commit: ${{github.event.workflow_run.head_sha}} diff --git a/.gitignore b/.gitignore index 7a08fe0d88..3343b89b90 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ target *.swp *.out .* +!.github !.gitignore # Eclipse files .project