Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/migration-from-portlet-to-rest-A…
Browse files Browse the repository at this point in the history
…PI' into migration-from-portlet-to-rest-API
  • Loading branch information
Mxqueen-yr01 committed Jul 1, 2024
2 parents 3f80eef + b920d55 commit 3ff7824
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 98 deletions.
85 changes: 0 additions & 85 deletions .github/workflows/badges.yml

This file was deleted.

101 changes: 88 additions & 13 deletions .github/workflows/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,112 @@ name: Project CI

on:
push:
branches: ['*']
branches: ['main']
paths: ['**.java', '.github/workflows/**', 'pom.xml']
pull_request:
branches: ['main']
workflow_dispatch:

jobs:
build:
license-and-header:
runs-on: ubuntu-latest

env:
JAVA_VERSION: '11'

name: Check license headers and notice

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'temurin'
cache: maven

- name: Check license hearders
run: ./mvnw license:check

- name: Check NOTICE
run: ./mvnw notice:check

backend:
runs-on: ubuntu-latest

strategy:
matrix:
java: ['11','17']
java: ['11', '17']

env:
JACOCO_JAVA: '11'

name: Java ${{ matrix.java }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Checkout badges branch to a badges directory nested inside first checkout
uses: actions/checkout@v4
with:
ref: badges
path: badges

# Setup Java
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '${{ matrix.java }}'
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: maven
- name: Check license hearders
run: ./mvnw license:check
- name: Check NOTICE
run: ./mvnw -B notice:check

- name: Build backend
run: ./mvnw -B package --file pom.xml -Dmaven.test.skip=true -Darguments="-DskipTests"
run: ./mvnw -B package -Pprod -Dmaven.test.skip=true -Darguments="-DskipTests"

- name: Tests backend
run: ./mvnw -B test --file pom.xml -P ci
run: ./mvnw test -Ptest

- name: Generate JaCoCo badge
id: jacoco
uses: cicirello/jacoco-badge-generator@v2
with:
badges-directory: badges
generate-branches-badge: true
generate-summary: true

- name: Log coverage percentages to workflow output
run: |
echo "coverage = ${{ steps.jacoco.outputs.coverage }}"
echo "branches = ${{ steps.jacoco.outputs.branches }}"
- name: Upload JaCoCo coverage report as a workflow artifact
uses: actions/upload-artifact@v4
with:
name: jacoco-report-java-${{ matrix.java }}
path: target/site/jacoco/

- name: Commit and push the coverage badges and summary file
if: ${{ github.event_name != 'pull_request' && matrix.java == env.JACOCO_JAVA }}
run: |
cd badges
if [[ `git status --porcelain *.svg *.json` ]]; then
git config --global user.name 'github-actions'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add *.svg *.json
git commit -m "Autogenerated JaCoCo coverage badges" *.svg *.json
git push
fi
- name: Comment on PR with coverage percentages
if: ${{ github.event_name == 'pull_request' && matrix.java == env.JACOCO_JAVA }}
run: |
REPORT=$(<badges/coverage-summary.json)
COVERAGE=$(jq -r '.coverage' <<< "$REPORT")%
BRANCHES=$(jq -r '.branches' <<< "$REPORT")%
NEWLINE=$'\n'
BODY="## JaCoCo Test Coverage Summary Statistics${NEWLINE}* __Coverage:__ ${COVERAGE}${NEWLINE}* __Branches:__ ${BRANCHES}"
gh pr comment ${{github.event.pull_request.number}} -b "${BODY}"
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 3ff7824

Please sign in to comment.