Skip to content

Commit

Permalink
Introduce github actions PR check job, fixes #2131
Browse files Browse the repository at this point in the history
Signed-off-by: Ondrej Dockal <odockal@redhat.com>
  • Loading branch information
odockal committed Aug 19, 2021
1 parent 1d28c6c commit e1d2537
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
@@ -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
49 changes: 49 additions & 0 deletions .github/workflows/publish_reports.yml
Original file line number Diff line number Diff line change
@@ -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}}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ target
*.swp
*.out
.*
!.github
!.gitignore
# Eclipse files
.project
Expand Down

0 comments on commit e1d2537

Please sign in to comment.