Skip to content

Commit 686dd9d

Browse files
committed
Move CI to GitHub actions
This commit moves the regular build and snapshot deployment to GitHub actions, based on a standard actions that are reusable. Closes gh-447
1 parent 0bcc787 commit 686dd9d

File tree

6 files changed

+162
-7
lines changed

6 files changed

+162
-7
lines changed

.github/actions/build/action.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: 'Build'
2+
description: 'Builds the project, optionally publishing it to a local deployment repository'
3+
inputs:
4+
java-version:
5+
required: false
6+
default: '17'
7+
description: 'The Java version to compile and test with'
8+
java-distribution:
9+
required: false
10+
default: 'liberica'
11+
description: 'The Java distribution to use for the build'
12+
publish:
13+
required: false
14+
default: 'false'
15+
description: 'Whether to publish artifacts ready for deployment to Artifactory'
16+
outputs:
17+
version:
18+
description: 'The version that was built'
19+
value: ${{ steps.read-version.outputs.version }}
20+
runs:
21+
using: composite
22+
steps:
23+
- name: Prepare Maven Build
24+
uses: ./.github/actions/prepare-maven-build
25+
with:
26+
java-version: ${{ inputs.java-version }}
27+
java-distribution: ${{ inputs.java-distribution }}
28+
- name: Build
29+
id: build
30+
if: ${{ inputs.publish == 'false' }}
31+
shell: bash
32+
run: ./mvnw --no-transfer-progress --batch-mode --update-snapshots verify
33+
- name: Publish
34+
id: publish
35+
if: ${{ inputs.publish == 'true' }}
36+
shell: bash
37+
run: ./mvnw --no-transfer-progress --batch-mode --update-snapshots -DaltDeploymentRepository=local::file:deployment-repository/ clean deploy -Pspring
38+
- name: Read version from pom.xml
39+
id: read-version
40+
shell: bash
41+
run: |
42+
version=$(sed -n 's/^.*<revision>\(.*\)<\/revision>.*$/\1/p' pom.xml)
43+
echo "Version is $version"
44+
echo "version=$version" >> $GITHUB_OUTPUT
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: 'Prepare Gradle Build'
2+
description: 'Prepares a Maven build. Sets up Java'
3+
inputs:
4+
java-version:
5+
required: false
6+
default: '17'
7+
description: 'The Java version to use for the build'
8+
java-distribution:
9+
required: false
10+
default: 'liberica'
11+
description: 'The Java distribution to use for the build'
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Set Up Java
16+
uses: actions/setup-java@v4
17+
with:
18+
distribution: ${{ inputs.java-distribution }}
19+
java-version: |
20+
${{ inputs.java-version }}
21+
${{ inputs.java-toolchain == 'true' && '17' || '' }}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Print JVM thread dumps
2+
description: Prints a thread dump for all running JVMs
3+
runs:
4+
using: composite
5+
steps:
6+
- if: ${{ runner.os == 'Linux' }}
7+
shell: bash
8+
run: |
9+
for jvm_pid in $(jps -q -J-XX:+PerfDisableSharedMem); do
10+
jcmd $jvm_pid Thread.print
11+
done
12+
- if: ${{ runner.os == 'Windows' }}
13+
shell: powershell
14+
run: |
15+
foreach ($jvm_pid in $(jps -q -J-XX:+PerfDisableSharedMem)) {
16+
jcmd $jvm_pid Thread.print
17+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Send Notification
2+
description: Sends a Google Chat message as a notification of the job's outcome
3+
inputs:
4+
webhook-url:
5+
description: 'Google Chat Webhook URL'
6+
required: true
7+
status:
8+
description: 'Status of the job'
9+
required: true
10+
run-name:
11+
description: 'Name of the run to include in the notification'
12+
default: ${{ format('{0} {1}', github.ref_name, github.job) }}
13+
runs:
14+
using: composite
15+
steps:
16+
- shell: bash
17+
run: |
18+
echo "RUN_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> "$GITHUB_ENV"
19+
- shell: bash
20+
if: ${{ inputs.status == 'success' }}
21+
run: |
22+
curl -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d '{ text: "<${{ env.RUN_URL }}|${{ inputs.run-name }}> was successful"}' || true
23+
- shell: bash
24+
if: ${{ inputs.status == 'failure' }}
25+
run: |
26+
curl -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d '{ text: "<users/all> *<${{ env.RUN_URL }}|${{ inputs.run-name }}> failed*"}' || true
27+
- shell: bash
28+
if: ${{ inputs.status == 'cancelled' }}
29+
run: |
30+
curl -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d '{ text: "<${{ env.RUN_URL }}|${{ inputs.run-name }}> was cancelled"}' || true
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build and Deploy Snapshot
2+
on:
3+
push:
4+
branches:
5+
- main
6+
permissions:
7+
actions: write
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
jobs:
11+
build-and-deploy-snapshot:
12+
if: ${{ github.repository == 'spring-projects/spring-retry' }}
13+
name: Build and Deploy Snapshot
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check Out Code
17+
uses: actions/checkout@v4
18+
- name: Build and Publish
19+
id: build-and-publish
20+
uses: ./.github/actions/build
21+
with:
22+
publish: true
23+
- name: Deploy
24+
uses: spring-io/artifactory-deploy-action@26bbe925a75f4f863e1e529e85be2d0093cac116 # v0.0.1
25+
with:
26+
uri: 'https://repo.spring.io'
27+
username: ${{ secrets.ARTIFACTORY_USERNAME }}
28+
password: ${{ secrets.ARTIFACTORY_PASSWORD }}
29+
build-name: 'spring-retry-2.0.x'
30+
repository: 'libs-snapshot-local'
31+
folder: 'deployment-repository'
32+
signing-key: ${{ secrets.GPG_PRIVATE_KEY }}
33+
signing-passphrase: ${{ secrets.GPG_PASSPHRASE }}
34+
- name: Send Notification
35+
uses: ./.github/actions/send-notification
36+
if: always()
37+
with:
38+
webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }}
39+
status: ${{ job.status }}
40+
run-name: ${{ format('{0} | Linux | Java 17', github.ref_name) }}
41+
outputs:
42+
version: ${{ steps.build-and-publish.outputs.version }}

.github/workflows/pr-build-workflow.yml renamed to .github/workflows/build-pull-request.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@ permissions:
66

77
jobs:
88
build:
9-
name: Build pull request
9+
name: Build Pull Request
1010
runs-on: ubuntu-latest
1111
if: ${{ github.repository == 'spring-projects/spring-retry' }}
1212
steps:
13-
- name: Set up JDK 17
14-
uses: actions/setup-java@v3
13+
- name: Set Up JDK 17
14+
uses: actions/setup-java@v4
1515
with:
1616
java-version: '17'
1717
distribution: 'liberica'
18-
19-
- name: Check out code
20-
uses: actions/checkout@v3
21-
18+
- name: Check Out
19+
uses: actions/checkout@v4
2220
- name: Build
2321
run: ./mvnw --batch-mode --update-snapshots verify
22+
- name: Print JVM Thread Dumps When Cancelled
23+
uses: ./.github/actions/print-jvm-thread-dumps
24+
if: cancelled()

0 commit comments

Comments
 (0)