build.yml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. name: Java CI with Maven
  2. on:
  3. push:
  4. branches: [ main, 2.3.x, 2.4.x, 3.0.x, 3.1.x ]
  5. pull_request:
  6. branches: [ main, 2.3.x, 2.4.x, 3.0.x, 3.1.x ]
  7. permissions:
  8. contents: read
  9. jobs:
  10. build:
  11. name: "Test with ${{ matrix.version }}"
  12. strategy:
  13. matrix:
  14. version: [ 17.0.1-tem, 21-tem ]
  15. runs-on: ubuntu-latest
  16. steps:
  17. - uses: actions/checkout@v2
  18. - name: Cache local Maven repository
  19. uses: actions/cache@v2
  20. with:
  21. path: ~/.m2/repository
  22. key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
  23. restore-keys: ${{ runner.os }}-maven-
  24. - name: Download ${{ matrix.version }}
  25. uses: sdkman/sdkman-action@master
  26. id: sdkman
  27. with:
  28. candidate: java
  29. version: ${{ matrix.version }}
  30. - name: Set up ${{ matrix.version }}
  31. uses: actions/setup-java@v1
  32. with:
  33. java-version: 8
  34. jdkFile: ${{ steps.sdkman.outputs.file }}
  35. - name: Build with Maven
  36. run: ./mvnw -V -B verify -Pspring
  37. sonar:
  38. name: "Run Sonar Analysis"
  39. runs-on: ubuntu-latest
  40. # Disable Sonar for foreign PRs
  41. if: (github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository))
  42. steps:
  43. - uses: actions/checkout@v2
  44. - name: Cache local Maven repository
  45. uses: actions/cache@v2
  46. with:
  47. path: ~/.m2/repository
  48. key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
  49. restore-keys: ${{ runner.os }}-maven-
  50. - name: Download JDK
  51. uses: sdkman/sdkman-action@master
  52. id: sdkman
  53. with:
  54. candidate: java
  55. version: 17.0.1-tem
  56. - name: Set up JDK
  57. uses: actions/setup-java@v1
  58. with:
  59. java-version: 8
  60. jdkFile: ${{ steps.sdkman.outputs.file }}
  61. - name: Cache SonarCloud packages
  62. uses: actions/cache@v1
  63. with:
  64. path: ~/.sonar/cache
  65. key: ${{ runner.os }}-sonar
  66. restore-keys: ${{ runner.os }}-sonar
  67. - name: Build with Maven
  68. env:
  69. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
  70. SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
  71. run: ./mvnw -V -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Pcoverage,spring