Repository navigation
220 lines (209 loc) · 9.21 KB
/
Copy pathci.yml
File metadata and controls
220 lines (209 loc) · 9.21 KB
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
name: CI
on:
push:
pull_request:
permissions:
contents: read
jobs:
verify:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v7
- uses: actions/setup-java@v6
with:
distribution: temurin
java-version: '25'
cache: maven
- name: Verify
shell: bash
run: ./mvnw --batch-mode --no-transfer-progress verify
external-rag-consumer:
name: External RAG consumer on ${{ matrix.os }}
needs: verify
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- name: Check out ArchUnitJava
uses: actions/checkout@v7
with:
path: ArchUnitJava
- name: Check out the RAG fixture
uses: actions/checkout@v7
with:
repository: TristanKruse/ArchUnitJava-TestRepo-RAG
path: ArchUnitJava-TestRepo-RAG
- name: Set up Java
uses: actions/setup-java@v6
with:
distribution: temurin
java-version: '25'
cache: maven
- name: Install the library candidate
id: candidate
shell: bash
working-directory: ArchUnitJava
run: |
candidate_version="$(./mvnw --batch-mode --no-transfer-progress \
help:evaluate -Dexpression=project.version -q -DforceStdout)"
echo "version=$candidate_version" >>"$GITHUB_OUTPUT"
./mvnw --batch-mode --no-transfer-progress -Prelease-candidate -DskipTests install
- name: Verify the external consumer
shell: bash
working-directory: ArchUnitJava-TestRepo-RAG
run: |
./mvnw --batch-mode --no-transfer-progress \
-Darchunitjava.version="${{ steps.candidate.outputs.version }}" verify
release-dry-run:
needs: verify
runs-on: ubuntu-latest
env:
CI_CENTRAL_USERNAME: local-dry-run
CI_CENTRAL_PASSWORD: local-dry-run
steps:
- uses: actions/checkout@v7
- uses: actions/setup-java@v6
with:
distribution: temurin
java-version: '25'
cache: maven
server-id: central
server-username: CI_CENTRAL_USERNAME
server-password: CI_CENTRAL_PASSWORD
- name: Check release documentation
shell: bash
run: |
for file in README.md LICENSE CHANGELOG.md CONTRIBUTING.md SECURITY.md docs/COMPATIBILITY.md docs/MIGRATION.md docs/RELEASE.md docs/THREAT_MODEL.md; do
test -s "$file"
done
grep -F 'Decision: PUBLISHED PUBLIC BETA.' docs/RELEASE.md
- name: Build release candidate
shell: bash
run: ./mvnw --batch-mode --no-transfer-progress -Prelease-candidate -DskipTests verify
- name: Reject unexpected SpotBugs findings
shell: bash
run: |
./mvnw --batch-mode --no-transfer-progress \
com.github.spotbugs:spotbugs-maven-plugin:4.10.3.0:spotbugs -DskipTests
python3 - <<'PY'
import hashlib
import xml.etree.ElementTree as ET
report = ET.parse("target/spotbugsXml.xml").getroot()
errors = report.find("Errors")
if errors is None or errors.get("errors") != "0" or errors.get("missingClasses") != "0":
raise SystemExit("SpotBugs analysis errors or missing classes were reported")
allowed = {"EI_EXPOSE_REP", "EQ_COMPARETO_USE_OBJECT_EQUALS"}
findings = report.findall("BugInstance")
finding_keys = []
for item in findings:
class_element = item.find("Class")
field = item.find("Field")
finding_keys.append("|".join((
item.get("type", ""),
class_element.get("classname", "") if class_element is not None else "",
field.get("name", "") if field is not None else "",
field.get("signature", "") if field is not None else "",
)))
fingerprint = hashlib.sha256(
"\n".join(sorted(finding_keys)).encode("utf-8")
).hexdigest()
expected_fingerprint = "fc7970533be9e41f9961b7303fa77d0170a4f441c31ea6e85057effcdfc2f555"
if len(findings) != 161 or fingerprint != expected_fingerprint:
raise SystemExit(
f"Reviewed SpotBugs baseline changed: {len(findings)} notices, {fingerprint}"
)
unexpected = sorted({item.get("type") for item in findings} - allowed)
if unexpected:
raise SystemExit("Unexpected SpotBugs categories: " + ", ".join(unexpected))
collection_signatures = {
"Ljava/util/List;", "Ljava/util/Map;", "Ljava/util/Set;"
}
for item in findings:
if item.get("type") == "EI_EXPOSE_REP":
field = item.find("Field")
if field is None or field.get("signature") not in collection_signatures:
raise SystemExit("Unexpected exposed-representation field type")
expected_comparables = {
"dev.archunitjava.importer.ClassFileResource",
"dev.archunitjava.model.JavaMember",
"dev.archunitjava.model.JavaType",
}
comparables = {
item.find("Class").get("classname")
for item in findings
if item.get("type") == "EQ_COMPARETO_USE_OBJECT_EQUALS"
}
if comparables != expected_comparables:
raise SystemExit("Natural-order exception set changed: " + repr(comparables))
print(f"Reviewed SpotBugs baseline accepted: {len(findings)} notices")
PY
- name: Verify reproducible primary artifact
shell: bash
run: |
project_version="$(./mvnw --batch-mode --no-transfer-progress \
help:evaluate -Dexpression=project.version -q -DforceStdout)"
cp "target/archunitjava-$project_version.jar" "$RUNNER_TEMP/archunitjava-first.jar"
./mvnw --batch-mode --no-transfer-progress -Prelease-candidate -DskipTests clean verify
cmp "$RUNNER_TEMP/archunitjava-first.jar" "target/archunitjava-$project_version.jar"
- name: Check package contents
shell: bash
run: |
project_version="$(./mvnw --batch-mode --no-transfer-progress \
help:evaluate -Dexpression=project.version -q -DforceStdout)"
jar_path="target/archunitjava-$project_version.jar"
test -s "$jar_path"
test -s "target/archunitjava-$project_version-sources.jar"
test -s "target/archunitjava-$project_version-javadoc.jar"
jar tf "$jar_path" | grep -F 'dev/archunitjava/cli/ArchUnitJavaCli.class'
jar tf "$jar_path" | grep -F 'META-INF/services/org.junit.platform.engine.TestEngine'
unzip -p "$jar_path" META-INF/MANIFEST.MF | grep -F 'Automatic-Module-Name: dev.archunitjava'
- name: Assemble and validate GitHub Pages
shell: pwsh
run: ./scripts/build-pages.ps1
- name: Verify external Maven consumer
shell: bash
run: |
./mvnw --batch-mode --no-transfer-progress -Prelease-candidate -DskipTests install
./mvnw --batch-mode --no-transfer-progress -f examples/basic/pom.xml test
- name: Exercise signing wiring and local-only deployment
shell: bash
run: |
./mvnw --batch-mode --no-transfer-progress -Prelease-candidate,release-sign -Dgpg.skip=true -DskipTests \
"-DaltDeploymentRepository=release-dry-run::file:$RUNNER_TEMP/archunitjava-staging" deploy
find "$RUNNER_TEMP/archunitjava-staging" -type f -name 'archunitjava-*.jar' | grep .
- name: Build a signed Central bundle against an unreachable local endpoint
shell: bash
env:
DRY_RUN_VERSION: 0.0.0
run: |
gpg --batch --pinentry-mode loopback --passphrase '' \
--quick-generate-key 'ArchUnitJava CI <[email protected]>' rsa2048 sign 1d
export MAVEN_GPG_KEY_FINGERPRINT
MAVEN_GPG_KEY_FINGERPRINT="$(gpg --batch --with-colons --list-secret-keys \
| awk -F: '$1 == "fpr" { print $10; exit }')"
test -n "$MAVEN_GPG_KEY_FINGERPRINT"
./mvnw --batch-mode --no-transfer-progress \
org.codehaus.mojo:versions-maven-plugin:2.19.1:set \
-DgenerateBackupPoms=false -DnewVersion="$DRY_RUN_VERSION"
set +e
./mvnw --batch-mode --no-transfer-progress \
-Prelease-candidate,release-sign,central-release \
-DcentralBaseUrl=http://127.0.0.1:9 \
-Dgpg.keyname="$MAVEN_GPG_KEY_FINGERPRINT" \
-DskipTests deploy
deploy_status=$?
set -e
test "$deploy_status" -ne 0
bundle=target/central-publishing/central-bundle.zip
test -s "$bundle"
unzip -l "$bundle" | grep -F "archunitjava-$DRY_RUN_VERSION.jar"
unzip -l "$bundle" | grep -F "archunitjava-$DRY_RUN_VERSION-sources.jar"
unzip -l "$bundle" | grep -F "archunitjava-$DRY_RUN_VERSION-javadoc.jar"
unzip -l "$bundle" | grep -F "archunitjava-$DRY_RUN_VERSION.pom"
unzip -l "$bundle" | grep -F "archunitjava-$DRY_RUN_VERSION.jar.asc"