Skip to content

Commit

Permalink
ci: introduce github action for building and running tests
Browse files Browse the repository at this point in the history
Refs: XRDDEV-2628
  • Loading branch information
mloitm committed Oct 15, 2024
1 parent 818b0aa commit 2e46e79
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/build.yml
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'

0 comments on commit 2e46e79

Please sign in to comment.