Skip to content

Commit

Permalink
add CI
Browse files Browse the repository at this point in the history
  • Loading branch information
thwbh committed Oct 20, 2024
1 parent 4de1a9c commit 68b478d
Showing 1 changed file with 91 additions and 0 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# This workflow will build a Java project with Gradle 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-gradle
# Build a quarkus native executable

name: Test and Build

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main", "develop" ]

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- uses: actions/checkout@v4
name: Checkout badges repo
if: github.event.name != 'pull_request'
with:
ref: badges
path: badges

- name: Run gradle test
run: ./gradlew test

- name: Run gradle build
if: github.event.pull_request.base.ref == 'main'
run: ./gradlew build -x test

- name: Generate JaCoCo Badge
if: github.event_name != 'pull_request'
id: jacoco
uses: cicirello/jacoco-badge-generator@v2
with:
jacoco-csv-file: build/jacoco-report/jacoco.csv
badges-directory: badges

- name: Log coverage percentages to workflow output
if: github.event_name != 'pull_request'
run: |
echo "coverage = ${{ steps.jacoco.outputs.coverage }}"
echo "branches = ${{ steps.jacoco.outputs.branches }}"

- name: Upload JaCoCo coverage report
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
with:
name: jacoco-report
path: build/jacoco-report/

- name: Commit and push badge to 'badges' branch if required
if: github.event_name != 'pull_request'
run: |
cd badges
if [[ `git status --porcelain` ]]; then
git config --global user.name 'tohuwabohu-io'
git config --global user.email '55439476@users.noreply.github.com'
git add *.svg
git commit -m "Autogenerated JaCoCo coverage badge"
git push
fi

dependency-submission:

runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
# See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md
- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0

0 comments on commit 68b478d

Please sign in to comment.