-
Notifications
You must be signed in to change notification settings - Fork 4
159 lines (149 loc) · 5.64 KB
/
build.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Build
on:
pull_request:
push:
branches:
- main
- 'releases/*'
env:
DV_URL: "https://ge.solutions-team.gradle.com"
DV_FAKE_ACCESS_KEY: "ge.solutions-team.gradle.com=foo"
MAVEN_SETUP_DIST: "dist/maven-setup"
MAVEN_PUBLISH_DIST: "dist/maven-publish-build-scan"
MAVEN_CAPTURE_EXTENSION_JAR: "dist/maven-build-scan-capture-extension/maven-build-scan-capture-extension.jar"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: 11
distribution: "temurin"
- name: Install Dependencies
run: npm ci
- name: Build
run: npm run all
- name: Check maven-setup dist
run: |
if [ "$(git diff --ignore-space-at-eol --text ${{ env.MAVEN_SETUP_DIST }} | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff --ignore-space-at-eol --text ${{ env.MAVEN_SETUP_DIST }}
exit 1
fi
- name: Check maven-publish-build-scan dist
run: |
if [ "$(git diff --ignore-space-at-eol --text ${{ env.MAVEN_PUBLISH_DIST }} | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff --ignore-space-at-eol --text ${{ env.MAVEN_PUBLISH_DIST }}
exit 1
fi
- name: Check maven-build-scan-capture-extension dist
run: |
# collect current jar content status (length, crc32, name of each entries)
unzip -vqq ${{ env.MAVEN_CAPTURE_EXTENSION_JAR }} | awk '{print $1,$7,$8}' | sort -k3 --ignore-case > current-jar-status.txt
# retrieve last jar version from repository
git restore ${{ env.MAVEN_CAPTURE_EXTENSION_JAR }}
# collect last from repo jar content status (length, crc32, name of each entries)
unzip -vqq ${{ env.MAVEN_CAPTURE_EXTENSION_JAR }} | awk '{print $1,$7,$8}' | sort -k3 --ignore-case > repo-jar-status.txt
if [ "$(diff current-jar-status.txt repo-jar-status.txt | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
diff current-jar-status.txt repo-jar-status.txt
exit 1
fi
test-capture:
runs-on: ubuntu-latest
if: "github.event_name == 'pull_request'"
needs: build
steps:
- name: Find PR Comment with publication summary
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.number }}
body-includes: '###### Generated by gradle/develocity-actions'
- name: Delete PR Comment with publication summary
env:
GH_TOKEN: ${{ github.token }}
run: |
if [[ ! -z "${{ steps.fc.outputs.comment-id }}" ]]; then
echo "Removing PR Comment with publication summary"
gh api --method DELETE "repos/${GITHUB_REPOSITORY}/issues/comments/${{ steps.fc.outputs.comment-id }}"
fi
- name: Checkout
uses: actions/checkout@v4
- name: Checkout Maven sample project
uses: actions/checkout@v4
with:
repository: 'gradle/develocity-build-config-samples'
path: 'sample'
ref: 'main'
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Build Scan dump capture
uses: ./maven-setup
- name: Run Maven Build 1
working-directory: ./sample/common-develocity-maven-configuration
run: mvn clean -B -X -Ddevelocity.url=${{ env.DV_URL }}
- name: Run Maven Build 2
working-directory: ./sample/common-develocity-maven-configuration
run: mvn initialize -B -X -Ddevelocity.url=${{ env.DV_URL }}
test-publish:
runs-on: ubuntu-latest
if: "github.event_name == 'pull_request'"
needs: test-capture
permissions:
actions: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Build Scan link capture
uses: ./maven-setup
- name: Publish Build Scans
uses: ./maven-publish-build-scan
with:
develocity-url: ${{ env.DV_URL }}
develocity-access-key: ${{ env.DV_FAKE_ACCESS_KEY }}
assert-test:
runs-on: ubuntu-latest
if: "github.event_name == 'pull_request'"
needs: test-publish
steps:
- name: Find PR Comment with publication summary
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.number }}
body-includes: '###### Generated by gradle/develocity-actions'
- name: Assert PR Comment with publication summary is present
env:
GH_TOKEN: ${{ github.token }}
run: |
if [[ -z "${{ steps.fc.outputs.comment-id }}" ]]; then
echo "Expected comment not found"
exit 1
fi
- name: Assert PR Comment contains expected goals
env:
GH_TOKEN: ${{ github.token }}
run: |
trimmedComment=$(echo "${{ steps.fc.outputs.comment-body }}" | sed 's/^ *//g')
if [[ ! "$trimmedComment" == *clean* ]]; then
echo "Publication summary does not contain clean goals"
exit 1
fi
if [[ ! "$trimmedComment" == *initialize* ]]; then
echo "Publication summary does not contain initialize goals"
exit 1
fi