|
1 | | -name: Validate and Test |
| 1 | +name: Build and Test |
2 | 2 | on: |
3 | | - push: |
4 | | - branches-ignore: |
5 | | - - gh-pages |
| 3 | + pull_request: |
| 4 | + branches: |
| 5 | + - main |
6 | 6 | jobs: |
7 | | - gradle: |
| 7 | + build: |
8 | 8 | runs-on: ubuntu-latest |
9 | 9 | permissions: |
10 | 10 | checks: write |
| 11 | + contents: write |
11 | 12 | pull-requests: write |
12 | 13 | steps: |
13 | | - - uses: actions/checkout@v3 |
14 | | - - uses: actions/setup-java@v3 |
| 14 | + - name: Checkout code |
| 15 | + uses: actions/checkout@v4 |
| 16 | + - name: Set up JDK |
| 17 | + uses: actions/setup-java@v3 |
15 | 18 | with: |
16 | | - java-version: '17' |
| 19 | + java-version: '21' |
17 | 20 | distribution: 'adopt' |
18 | | - - name: Setup Gradle |
19 | | - uses: gradle/gradle-build-action@v2.4.2 |
20 | | - with: |
21 | | - gradle-version: 8.2.1 |
22 | | - - name: Change wrapper permissions |
23 | | - run: chmod +x ./gradlew |
24 | | - - name: Execute Gradle build |
25 | | - run: ./gradlew clean build jacocoTestReport |
| 21 | + cache: maven |
| 22 | + - name: Build with maven |
| 23 | + run: mvn -Pgithub-action clean verify |
| 24 | + |
26 | 25 | - name: Publish Unit Test Results |
27 | 26 | uses: EnricoMi/publish-unit-test-result-action@v2 |
28 | | - if: always() # clause guarantees that this action always runs, even if earlier steps (e.g., the unit test step) in your workflow fail. |
| 27 | + #if: always() # clause guarantees that this action always runs, even if earlier steps (e.g., the unit test step) in your workflow fail. |
29 | 28 | with: |
30 | | - files: "build/test-results/**/*.xml" |
| 29 | + files: ${{ github.workspace }}/target/surefire-reports/**/*.xml |
31 | 30 | - name: Add coverage to PR |
32 | 31 | id: jacoco |
33 | 32 | uses: madrapps/jacoco-report@v1.6.1 # requires at least two pushes to a PR, see https://github.com/Madrapps/jacoco-report/issues/13 |
34 | 33 | with: |
35 | | - paths: ${{ github.workspace }}/build/reports/jacoco/test/jacocoTestReport.xml |
| 34 | + paths: ${{ github.workspace }}/target/jacoco-report/jacoco.xml |
36 | 35 | token: ${{ secrets.GITHUB_TOKEN }} |
37 | 36 | min-coverage-overall: 40 |
38 | 37 | min-coverage-changed-files: 60 |
39 | 38 | - name: Archive code coverage results |
40 | 39 | uses: actions/upload-artifact@v3 |
41 | 40 | with: |
42 | 41 | name: code-coverage-report |
43 | | - path: build/reports/jacoco/** |
44 | | - |
| 42 | + path: target/jacoco-report/** |
| 43 | + - name: ls |
| 44 | + run: ls -al target/jacoco-report/ |
| 45 | + - name: Generate JaCoCo Badge |
| 46 | + uses: cicirello/jacoco-badge-generator@v2 |
| 47 | + with: |
| 48 | + jacoco-csv-file: target/jacoco-report/jacoco.csv |
| 49 | + generate-coverage-badge: true |
| 50 | + badges-directory: .github/badges |
| 51 | + - name: Commit the badge (if it changed) |
| 52 | + run: | |
| 53 | + git config user.name 'github-actions[bot]' |
| 54 | + git config user.email '41898282+github-actions[bot]@users.noreply.github.com' |
| 55 | + if [[ `git diff --exit-code .github/badges/jacoco.svg` ]]; then |
| 56 | + git add .github/badges/jacoco.svg |
| 57 | + git commit -m "Autogenerated JaCoCo coverage badge" |
| 58 | + git push |
| 59 | + fi |
45 | 60 | lint-markdown: |
46 | 61 | name: Lint all markdown files in project |
47 | 62 | runs-on: ubuntu-latest |
|
52 | 67 | uses: nosborn/github-action-markdown-cli@v3.0.1 |
53 | 68 | with: |
54 | 69 | files: '**/*.md' |
55 | | - checkstyle: |
56 | | - runs-on: ubuntu-latest |
57 | | - name: Run CheckStyle |
58 | | - steps: |
59 | | - - name: Check out code |
60 | | - uses: actions/checkout@v3 |
61 | | - - name: Run CheckStyle |
62 | | - uses: nikitasavinov/checkstyle-action@master |
63 | | - with: |
64 | | - checkstyle_config: checkstyle.xml |
65 | | - level: error |
66 | | - fail_on_error: true |
67 | | - reporter: 'github-check' |
68 | | - github_token: ${{ secrets.GITHUB_TOKEN }} |
| 70 | + |
69 | 71 |
|
0 commit comments