-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: introduce github action for building and running tests
Refs: XRDDEV-2628
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Build and test | ||
on: | ||
# Capture this event so that gradle caches are updated when a PR is merged to develop | ||
# More information on why: https://github.com/gradle/gradle-build-action#using-the-caches-read-only | ||
push: | ||
# branches: | ||
# - develop | ||
paths: | ||
- 'src/**' | ||
- '.github/**' | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
paths: | ||
- 'src/**' | ||
- '.github/**' | ||
permissions: | ||
contents: write # Required for https://github.com/gradle/actions/tree/main/setup-gradle#github-dependency-graph-support | ||
pull-requests: write # https://github.com/gradle/actions/tree/main/setup-gradle#adding-job-summary-as-a-pull-request-comment | ||
actions: read # Required for https://github.com/dorny/test-reporter | ||
checks: write # Required for https://github.com/dorny/test-reporter | ||
# Cancels previous workflow run on PR if a new one is started (does not affect push to develop). | ||
# This is because github.head_ref is empty on push events so defaults to the unique github.run_id. | ||
# More info: https://docs.github.com/en/actions/using-jobs/using-concurrency | ||
concurrency: | ||
group: ${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
jobs: | ||
BuildAndPackageWithUnitTests: | ||
name: Build, test and package code | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # SonarCloud: Shallow clones should be disabled for a better relevancy of analysis | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
- name: Cache SonarCloud packages | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.sonar/cache | ||
key: ${{ runner.os }}-sonar | ||
restore-keys: ${{ runner.os }}-sonar | ||
- name: Set up Gradle | ||
uses: gradle/actions/setup-gradle@v4 | ||
with: | ||
cache-read-only: ${{ github.ref != 'refs/heads/develop' }} | ||
gradle-home-cache-cleanup: true | ||
dependency-graph: generate-and-submit | ||
add-job-summary-as-pr-comment: always | ||
- name: Build and test source | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
working-directory: ./src | ||
run: ./gradlew build | ||
- name: Test report | ||
uses: dorny/test-reporter@v1 | ||
if: success() || failure() | ||
with: | ||
name: Unit and integration tests | ||
path: src/**/build/test-results/**/TEST-*.xml | ||
reporter: java-junit | ||
list-suites: 'failed' | ||
list-tests: 'failed' |