continuous-integration-workflow.yml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. name: CI
  2. on:
  3. push:
  4. branches:
  5. - main
  6. schedule:
  7. - cron: '0 10 * * *' # Once per day at 10am UTC
  8. workflow_dispatch: # Manual trigger
  9. env:
  10. SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
  11. GRADLE_ENTERPRISE_CACHE_USER: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USER }}
  12. GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
  13. GRADLE_ENTERPRISE_SECRET_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
  14. COMMIT_OWNER: ${{ github.event.pusher.name }}
  15. COMMIT_SHA: ${{ github.sha }}
  16. ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
  17. ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
  18. RUN_JOBS: ${{ github.repository == 'spring-projects/spring-security' }}
  19. jobs:
  20. prerequisites:
  21. name: Pre-requisites for building
  22. runs-on: ubuntu-latest
  23. outputs:
  24. runjobs: ${{ steps.continue.outputs.runjobs }}
  25. steps:
  26. - uses: actions/checkout@v2
  27. - name: Initiate error tracking
  28. uses: spring-projects/track-build-errors-action@v1
  29. with:
  30. job-name: "prerequisites"
  31. - name: Export errors file
  32. uses: actions/upload-artifact@v2
  33. with:
  34. name: errors
  35. path: job-prerequisites.txt
  36. - id: continue
  37. name: Determine if should continue
  38. if: env.RUN_JOBS == 'true'
  39. run: echo "::set-output name=runjobs::true"
  40. build_jdk_11:
  41. name: Build JDK 11
  42. needs: [prerequisites]
  43. runs-on: ubuntu-latest
  44. if: needs.prerequisites.outputs.runjobs
  45. steps:
  46. - uses: actions/checkout@v2
  47. - name: Set up JDK 11
  48. uses: actions/setup-java@v1
  49. with:
  50. java-version: '11'
  51. - name: Cache Gradle packages
  52. uses: actions/cache@v2
  53. with:
  54. path: ~/.gradle/caches
  55. key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
  56. - name: Build with Gradle
  57. run: |
  58. export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
  59. export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
  60. export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
  61. ./gradlew clean build --continue -PartifactoryUsername="$ARTIFACTORY_USERNAME" -PartifactoryPassword="$ARTIFACTORY_PASSWORD"
  62. - name: Track error step
  63. uses: spring-projects/track-build-errors-action@v1
  64. if: ${{ failure() }}
  65. with:
  66. job-name: ${{ github.job }}
  67. - name: Export errors file
  68. uses: actions/upload-artifact@v2
  69. if: ${{ failure() }}
  70. with:
  71. name: errors
  72. path: job-${{ github.job }}.txt
  73. check_windows:
  74. name: Check Windows
  75. needs: [prerequisites]
  76. runs-on: windows-latest
  77. if: needs.prerequisites.outputs.runjobs
  78. steps:
  79. - uses: actions/checkout@v2
  80. - name: Set up JDK 11
  81. uses: actions/setup-java@v1
  82. with:
  83. java-version: '11'
  84. - name: Cache Gradle packages
  85. uses: actions/cache@v2
  86. with:
  87. path: ~/.gradle/caches
  88. key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
  89. - name: Check with Gradle
  90. run: |
  91. set GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
  92. set GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
  93. set GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
  94. ./gradlew check -PartifactoryUsername="$ARTIFACTORY_USERNAME" -PartifactoryPassword="$ARTIFACTORY_PASSWORD"
  95. snapshot_tests:
  96. name: Test against snapshots
  97. needs: [prerequisites]
  98. runs-on: ubuntu-latest
  99. if: needs.prerequisites.outputs.runjobs
  100. steps:
  101. - uses: actions/checkout@v2
  102. - name: Set up JDK
  103. uses: actions/setup-java@v1
  104. with:
  105. java-version: '11'
  106. - name: Snapshot Tests
  107. run: |
  108. export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
  109. export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
  110. export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
  111. ./gradlew test --refresh-dependencies -PartifactoryUsername="$ARTIFACTORY_USERNAME" -PartifactoryPassword="$ARTIFACTORY_PASSWORD" -PforceMavenRepositories=snapshot -PspringVersion='5.+' -PreactorVersion='20+' -PspringDataVersion='Neumann-BUILD-SNAPSHOT' -PrsocketVersion=1.1.0-SNAPSHOT -PspringBootVersion=2.4.0-SNAPSHOT -PlocksDisabled --stacktrace
  112. - name: Track error step
  113. uses: spring-projects/track-build-errors-action@v1
  114. if: ${{ failure() }}
  115. with:
  116. job-name: ${{ github.job }}
  117. - name: Export errors file
  118. uses: actions/upload-artifact@v2
  119. if: ${{ failure() }}
  120. with:
  121. name: errors
  122. path: job-${{ github.job }}.txt
  123. sonar_analysis:
  124. name: Static Code Analysis
  125. needs: [prerequisites]
  126. runs-on: ubuntu-latest
  127. if: needs.prerequisites.outputs.runjobs
  128. env:
  129. SONAR_URL: ${{ secrets.SONAR_URL }}
  130. SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
  131. steps:
  132. - uses: actions/checkout@v2
  133. - name: Set up JDK
  134. uses: actions/setup-java@v1
  135. with:
  136. java-version: '11'
  137. - name: Run Sonar on given (non-main) branch
  138. if: ${{ github.ref != 'refs/heads/main' }}
  139. run: |
  140. export BRANCH=${GITHUB_REF#refs/heads/}
  141. export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
  142. export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
  143. export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
  144. ./gradlew sonarqube -PartifactoryUsername="$ARTIFACTORY_USERNAME" -PartifactoryPassword="$ARTIFACTORY_PASSWORD" -PexcludeProjects='**/samples/**' -Dsonar.projectKey="spring-security-${GITHUB_REF#refs/heads/}" -Dsonar.projectName="spring-security-${GITHUB_REF#refs/heads/}" -Dsonar.host.url="$SONAR_URL" -Dsonar.login="$SONAR_TOKEN" --stacktrace
  145. - name: Run Sonar on main
  146. if: ${{ github.ref == 'refs/heads/main' }}
  147. run: |
  148. export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
  149. export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
  150. export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
  151. ./gradlew sonarqube -PartifactoryUsername="$ARTIFACTORY_USERNAME" -PartifactoryPassword="$ARTIFACTORY_PASSWORD" -PexcludeProjects='**/samples/**' -Dsonar.host.url="$SONAR_URL" -Dsonar.login="$SONAR_TOKEN" --stacktrace
  152. - name: Track error step
  153. uses: spring-projects/track-build-errors-action@v1
  154. if: ${{ failure() }}
  155. with:
  156. job-name: ${{ github.job }}
  157. - name: Export errors file
  158. uses: actions/upload-artifact@v2
  159. if: ${{ failure() }}
  160. with:
  161. name: errors
  162. path: job-${{ github.job }}.txt
  163. deploy_artifacts:
  164. name: Deploy Artifacts
  165. needs: [build_jdk_11, snapshot_tests, sonar_analysis]
  166. runs-on: ubuntu-latest
  167. steps:
  168. - uses: actions/checkout@v2
  169. - name: Set up JDK
  170. uses: actions/setup-java@v1
  171. with:
  172. java-version: '11'
  173. - name: Deploy artifacts
  174. run: |
  175. export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
  176. export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
  177. export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
  178. export VERSION_HEADER=$'Version: GnuPG v2\n\n'
  179. export ORG_GRADLE_PROJECT_signingKey=${GPG_PRIVATE_KEY_NO_HEADER#"$VERSION_HEADER"}
  180. export ORG_GRADLE_PROJECT_signingPassword="$GPG_PASSPHRASE"
  181. ./gradlew deployArtifacts -PossrhUsername="$OSSRH_TOKEN_USERNAME" -PossrhPassword="$OSSRH_TOKEN_PASSWORD" -PartifactoryUsername="$ARTIFACTORY_USERNAME" -PartifactoryPassword="$ARTIFACTORY_PASSWORD" --stacktrace --no-parallel
  182. ./gradlew finalizeDeployArtifacts -PossrhUsername="$OSSRH_TOKEN_USERNAME" -PossrhPassword="$OSSRH_TOKEN_PASSWORD" -PartifactoryUsername="$ARTIFACTORY_USERNAME" -PartifactoryPassword="$ARTIFACTORY_PASSWORD" --stacktrace --no-parallel
  183. env:
  184. GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
  185. GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
  186. OSSRH_TOKEN_USERNAME: ${{ secrets.OSSRH_TOKEN_USERNAME }}
  187. OSSRH_TOKEN_PASSWORD: ${{ secrets.OSSRH_TOKEN_PASSWORD }}
  188. ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
  189. ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
  190. - name: Track error step
  191. uses: spring-projects/track-build-errors-action@v1
  192. if: ${{ failure() }}
  193. with:
  194. job-name: ${{ github.job }}
  195. - name: Export errors file
  196. uses: actions/upload-artifact@v2
  197. if: ${{ failure() }}
  198. with:
  199. name: errors
  200. path: job-${{ github.job }}.txt
  201. deploy_docs:
  202. name: Deploy Docs
  203. needs: [build_jdk_11, snapshot_tests, sonar_analysis]
  204. runs-on: ubuntu-latest
  205. steps:
  206. - uses: actions/checkout@v2
  207. - name: Set up JDK
  208. uses: actions/setup-java@v1
  209. with:
  210. java-version: '11'
  211. - name: Deploy Docs
  212. run: |
  213. export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
  214. export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
  215. export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
  216. ./gradlew deployDocs -PdeployDocsSshKey="$DOCS_SSH_KEY" -PdeployDocsSshUsername="$DOCS_USERNAME" -PdeployDocsHost="$DOCS_HOST" --stacktrace
  217. env:
  218. DOCS_USERNAME: ${{ secrets.DOCS_USERNAME }}
  219. DOCS_SSH_KEY: ${{ secrets.DOCS_SSH_KEY }}
  220. DOCS_HOST: ${{ secrets.DOCS_HOST }}
  221. - name: Track error step
  222. uses: spring-projects/track-build-errors-action@v1
  223. if: ${{ failure() }}
  224. with:
  225. job-name: ${{ github.job }}
  226. - name: Export errors file
  227. uses: actions/upload-artifact@v2
  228. if: ${{ failure() }}
  229. with:
  230. name: errors
  231. path: job-${{ github.job }}.txt
  232. deploy_schema:
  233. name: Deploy Schema
  234. needs: [build_jdk_11, snapshot_tests, sonar_analysis]
  235. runs-on: ubuntu-latest
  236. steps:
  237. - uses: actions/checkout@v2
  238. - name: Set up JDK
  239. uses: actions/setup-java@v1
  240. with:
  241. java-version: '11'
  242. - name: Deploy Schema
  243. run: |
  244. export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
  245. export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
  246. export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
  247. ./gradlew deploySchema -PdeployDocsSshKey="$DOCS_SSH_KEY" -PdeployDocsSshUsername="$DOCS_USERNAME" -PdeployDocsHost="$DOCS_HOST" --stacktrace --info
  248. env:
  249. DOCS_USERNAME: ${{ secrets.DOCS_USERNAME }}
  250. DOCS_SSH_KEY: ${{ secrets.DOCS_SSH_KEY }}
  251. DOCS_HOST: ${{ secrets.DOCS_HOST }}
  252. - name: Track error step
  253. uses: spring-projects/track-build-errors-action@v1
  254. if: ${{ failure() }}
  255. with:
  256. job-name: ${{ github.job }}
  257. - name: Export errors file
  258. uses: actions/upload-artifact@v2
  259. if: ${{ failure() }}
  260. with:
  261. name: errors
  262. path: job-${{ github.job }}.txt
  263. notify_result:
  264. name: Check for failures
  265. needs: [build_jdk_11, snapshot_tests, sonar_analysis, deploy_artifacts, deploy_docs, deploy_schema]
  266. if: always()
  267. runs-on: ubuntu-latest
  268. steps:
  269. - uses: actions/checkout@v2
  270. - name: Download errors folder
  271. uses: actions/download-artifact@v2
  272. with:
  273. name: errors
  274. - name: Send Slack message
  275. uses: spring-projects/notify-slack-errors-action@v1
  276. with:
  277. slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
  278. branch-name: ${{ github.ref }}
  279. commit-sha: ${{ github.sha }}
  280. commit-owner: ${{ github.actor }}
  281. repo-name: ${{ github.repository }}
  282. run-id: ${{ github.run_id }}