forked from line/armeria
-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (119 loc) · 4.33 KB
/
gradle-enterprise-postjob.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Upload artifacts to ge.armeria.dev
on:
workflow_run:
workflows: [CI]
types:
- completed
env:
LC_ALL: "en_US.UTF-8"
BUILD_JDK_VERSION: "19"
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
RUN_ID: ${{ github.event.workflow_run.id }}
COMMIT_SHA: ${{ github.event.workflow_run.head_sha }}
# Used by Octokit
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOWNLOAD_DIR: build-scans/
jobs:
upload-gradle-build-scan:
name: Upload Gradle build scans
if: github.repository == 'line/armeria'
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- id: setup-jdk-19
name: Set up JDK 19
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '19'
- name: Download artifact
id: download-artifact
uses: dawidd6/action-download-artifact@v2
with:
workflow_conclusion: ""
run_id: ${{ env.RUN_ID }}
name: build-scan.*
name_is_regexp: true
path: ${{ env.DOWNLOAD_DIR }}
check_artifacts: true
search_artifacts: true
- id: get-pr-number
name: Get PR number
run: |
PR_NUMBER=$(ls $DOWNLOAD_DIR | head -1 | sed -n 's/\([0-9]*\)-build-scan.*/\1/p')
if [ -z "$PR_NUMBER" ]; then
echo "❔️No pull request number found."
else
echo "✅ Pull request number: ${PR_NUMBER}"
echo "PR_NUMBER=${PR_NUMBER}" >> "$GITHUB_OUTPUT"
fi
shell: bash
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- id: upload-build-scans
name: Upload build scans
run: |
BUILD_SCAN_DIR="${HOME}/.gradle/build-scan-data"
BUILD_SCANS=""
echo "## Build Scan®" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
rm -rf $BUILD_SCAN_DIR
for SCAN in $(ls $DOWNLOAD_DIR) ; do
mkdir -p $BUILD_SCAN_DIR
echo "🚚 Copying build scan: ${DOWNLOAD_DIR}${SCAN}/ to $BUILD_SCAN_DIR ..."
cp -r ${DOWNLOAD_DIR}${SCAN}/* $BUILD_SCAN_DIR
JOB_NAME=$(echo ${SCAN} | sed 's/.*build-scan-\(.*\)/\1/')
echo "📤 Uploading build scan for job ${JOB_NAME} ..."
if ./gradlew --no-daemon --stacktrace clean buildScanPublishPrevious; then
echo "✅ Published build scan: ${JOB_NAME}"
BUILD_SCANS="${JOB_NAME} $(cat build/build-scan-url.txt),${BUILD_SCANS}"
echo "- [${JOB_NAME}]($(cat build/build-scan-url.txt))" >> "$GITHUB_STEP_SUMMARY"
else
echo "❌ Failed to upload build scan: ${JOB_NAME}"
fi
rm -rf $BUILD_SCAN_DIR
done
echo "BUILD_SCANS=${BUILD_SCANS}" >> "$GITHUB_OUTPUT"
shell: bash
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- id: create-or-update-comment
name: Create or update comment
if: steps.get-pr-number.outputs.PR_NUMBER
working-directory: .github/actions
run: |
npm ci
npm run comment-build-scan
shell: bash
env:
BUILD_SCANS: ${{ steps.upload-build-scans.outputs.BUILD_SCANS }}
PR_NUMBER: ${{ steps.get-pr-number.outputs.PR_NUMBER }}
upload-build-cache:
runs-on: ${{ matrix.on }}
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
on: [ self-hosted, macos-12, windows-latest ]
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.COMMIT_SHA }}
- id: setup-build-jdk
name: Set up build JDK ${{ env.BUILD_JDK_VERSION }}
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ env.BUILD_JDK_VERSION }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Build with Gradle
run: |
./gradlew --no-daemon --stacktrace --build-cache build \
${{ (matrix.on == 'self-hosted') && '--max-workers=8' || '--max-workers=2' }} --parallel \
-PbuildJdkVersion=${{ env.BUILD_JDK_VERSION }} \
-Pretry=true -PfailOnPassedAfterRetry=false \
-Porg.gradle.java.installations.paths=${{ steps.setup-build-jdk.outputs.path }}
shell: bash