Skip to content

Commit 0248d8e

Browse files
authored
Merge branch 'jMonkeyEngine:master' into master
2 parents 62f5398 + 1f9d606 commit 0248d8e

File tree

126 files changed

+8433
-2168
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+8433
-2168
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#! /bin/bash
2+
set -euo pipefail
3+
4+
## Upload a deployment
5+
## from the "org.jmonkeyengine" namespace in Sonatype's OSSRH staging area
6+
## to Sonatype's Central Publisher Portal
7+
## so the deployment can be tested and then published or dropped.
8+
9+
## IMPORTANT: The upload request must originate
10+
## from the IP address used to stage the deployment to the staging area!
11+
12+
# The required -p and -u flags on the command line
13+
# specify the password and username components of a "user token"
14+
# generated using the web interface at https://central.sonatype.com/account
15+
16+
while getopts p:u: flag
17+
do
18+
case "${flag}" in
19+
p) centralPassword=${OPTARG};;
20+
u) centralUsername=${OPTARG};;
21+
esac
22+
done
23+
24+
# Combine both components into a base64 "user token"
25+
# suitable for the Authorization header of a POST request:
26+
27+
token=$(printf %s:%s "${centralUsername}" "${centralPassword}" | base64)
28+
29+
# Send a POST request to upload the deployment:
30+
31+
server='ossrh-staging-api.central.sonatype.com'
32+
endpoint='/manual/upload/defaultRepository/org.jmonkeyengine'
33+
url="https://${server}${endpoint}"
34+
35+
statusCode=$(curl "${url}" \
36+
--no-progress-meter \
37+
--output postData1.txt \
38+
--write-out '%{response_code}' \
39+
--request POST \
40+
--header 'accept: */*' \
41+
--header "Authorization: Bearer ${token}" \
42+
--data '')
43+
44+
echo "Status code = ${statusCode}"
45+
echo 'Received data:'
46+
cat postData1.txt
47+
echo '[EOF]'
48+
49+
# Retry if the default repo isn't found (status=400).
50+
51+
if [ "${statusCode}" == "400" ]; then
52+
echo "Will retry after 30 seconds."
53+
sleep 30
54+
55+
statusCode2=$(curl "${url}" \
56+
--no-progress-meter \
57+
--output postData2.txt \
58+
--write-out '%{response_code}' \
59+
--request POST \
60+
--header 'accept: */*' \
61+
--header "Authorization: Bearer ${token}" \
62+
--data '')
63+
64+
echo "Status code = ${statusCode2}"
65+
echo 'Received data:'
66+
cat postData2.txt
67+
echo '[EOF]'
68+
fi

.github/workflows/main.yml

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
# >> Configure MINIO NATIVES SNAPSHOT
1717
# OBJECTS_KEY=XXXXXX
1818
# >> Configure SONATYPE RELEASE
19-
# OSSRH_PASSWORD=XXXXXX
20-
# OSSRH_USERNAME=XXXXXX
19+
# CENTRAL_PASSWORD=XXXXXX
20+
# CENTRAL_USERNAME=XXXXXX
2121
# >> Configure SIGNING
2222
# SIGNING_KEY=XXXXXX
2323
# SIGNING_PASSWORD=XXXXXX
@@ -359,16 +359,16 @@ jobs:
359359
name: android-natives
360360
path: build/native
361361

362-
- name: Rebuild the maven artifacts and deploy them to the Sonatype repository
362+
- name: Rebuild the maven artifacts and upload them to Sonatype's maven-snapshots repo
363363
run: |
364-
if [ "${{ secrets.OSSRH_PASSWORD }}" = "" ];
364+
if [ "${{ secrets.CENTRAL_PASSWORD }}" = "" ];
365365
then
366-
echo "Configure the following secrets to enable deployment to Sonatype:"
367-
echo "OSSRH_PASSWORD, OSSRH_USERNAME, SIGNING_KEY, SIGNING_PASSWORD"
366+
echo "Configure the following secrets to enable uploading to Sonatype:"
367+
echo "CENTRAL_PASSWORD, CENTRAL_USERNAME, SIGNING_KEY, SIGNING_PASSWORD"
368368
else
369369
./gradlew publishMavenPublicationToSNAPSHOTRepository \
370-
-PossrhPassword=${{ secrets.OSSRH_PASSWORD }} \
371-
-PossrhUsername=${{ secrets.OSSRH_USERNAME }} \
370+
-PcentralPassword=${{ secrets.CENTRAL_PASSWORD }} \
371+
-PcentralUsername=${{ secrets.CENTRAL_USERNAME }} \
372372
-PsigningKey='${{ secrets.SIGNING_KEY }}' \
373373
-PsigningPassword='${{ secrets.SIGNING_PASSWORD }}' \
374374
-PuseCommitHashAsVersionName=true \
@@ -384,13 +384,13 @@ jobs:
384384
if: github.event_name == 'release'
385385
steps:
386386

387-
# We need to clone everything again for uploadToMaven.sh ...
387+
# We need to clone everything again for uploadToCentral.sh ...
388388
- name: Clone the repo
389389
uses: actions/checkout@v4
390390
with:
391391
fetch-depth: 1
392392

393-
# Setup jdk 21 used for building Sonatype OSSRH artifacts
393+
# Setup jdk 21 used for building Sonatype artifacts
394394
- name: Setup the java environment
395395
uses: actions/setup-java@v4
396396
with:
@@ -416,20 +416,23 @@ jobs:
416416
name: android-natives
417417
path: build/native
418418

419-
- name: Rebuild the maven artifacts and deploy them to Sonatype OSSRH
419+
- name: Rebuild the maven artifacts and upload them to Sonatype's Central Publisher Portal
420420
run: |
421-
if [ "${{ secrets.OSSRH_PASSWORD }}" = "" ];
421+
if [ "${{ secrets.CENTRAL_PASSWORD }}" = "" ];
422422
then
423-
echo "Configure the following secrets to enable deployment to Sonatype:"
424-
echo "OSSRH_PASSWORD, OSSRH_USERNAME, SIGNING_KEY, SIGNING_PASSWORD"
423+
echo "Configure the following secrets to enable uploading to Sonatype:"
424+
echo "CENTRAL_PASSWORD, CENTRAL_USERNAME, SIGNING_KEY, SIGNING_PASSWORD"
425425
else
426-
./gradlew publishMavenPublicationToOSSRHRepository \
427-
-PossrhPassword=${{ secrets.OSSRH_PASSWORD }} \
428-
-PossrhUsername=${{ secrets.OSSRH_USERNAME }} \
429-
-PsigningKey='${{ secrets.SIGNING_KEY }}' \
430-
-PsigningPassword='${{ secrets.SIGNING_PASSWORD }}' \
431-
-PuseCommitHashAsVersionName=true \
432-
--console=plain --stacktrace
426+
./gradlew publishMavenPublicationToCentralRepository \
427+
-PcentralPassword=${{ secrets.CENTRAL_PASSWORD }} \
428+
-PcentralUsername=${{ secrets.CENTRAL_USERNAME }} \
429+
-PsigningKey='${{ secrets.SIGNING_KEY }}' \
430+
-PsigningPassword='${{ secrets.SIGNING_PASSWORD }}' \
431+
-PuseCommitHashAsVersionName=true \
432+
--console=plain --stacktrace
433+
.github/actions/tools/uploadToCentral.sh \
434+
-p '${{ secrets.CENTRAL_PASSWORD }}' \
435+
-u '${{ secrets.CENTRAL_USERNAME }}'
433436
fi
434437
435438
- name: Deploy to GitHub Releases
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Screenshot Test PR Comment
2+
3+
# This workflow is designed to safely comment on PRs from forks
4+
# It uses pull_request_target which has higher permissions than pull_request
5+
# Security note: This workflow does NOT check out or execute code from the PR
6+
# It only monitors the status of the ScreenshotTests job and posts comments
7+
# (If this commenting was done in the main worflow it would not have the permissions
8+
# to create a comment)
9+
10+
on:
11+
pull_request_target:
12+
types: [opened, synchronize, reopened]
13+
14+
jobs:
15+
monitor-screenshot-tests:
16+
name: Monitor Screenshot Tests and Comment
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 60
19+
permissions:
20+
pull-requests: write
21+
contents: read
22+
steps:
23+
- name: Wait for GitHub to register the workflow run
24+
run: sleep 15
25+
26+
- name: Wait for Screenshot Tests to complete
27+
uses: lewagon/[email protected]
28+
with:
29+
ref: ${{ github.event.pull_request.head.sha }}
30+
check-name: 'Run Screenshot Tests'
31+
repo-token: ${{ secrets.GITHUB_TOKEN }}
32+
wait-interval: 10
33+
allowed-conclusions: success,skipped,failure
34+
- name: Check Screenshot Tests status
35+
id: check-status
36+
uses: actions/github-script@v6
37+
with:
38+
github-token: ${{ secrets.GITHUB_TOKEN }}
39+
script: |
40+
const { owner, repo } = context.repo;
41+
const ref = '${{ github.event.pull_request.head.sha }}';
42+
43+
// Get workflow runs for the PR
44+
const runs = await github.rest.actions.listWorkflowRunsForRepo({
45+
owner,
46+
repo,
47+
head_sha: ref
48+
});
49+
50+
// Find the ScreenshotTests job
51+
let screenshotTestRun = null;
52+
for (const run of runs.data.workflow_runs) {
53+
if (run.name === 'Build jMonkeyEngine') {
54+
const jobs = await github.rest.actions.listJobsForWorkflowRun({
55+
owner,
56+
repo,
57+
run_id: run.id
58+
});
59+
60+
for (const job of jobs.data.jobs) {
61+
if (job.name === 'Run Screenshot Tests') {
62+
screenshotTestRun = job;
63+
break;
64+
}
65+
}
66+
67+
if (screenshotTestRun) break;
68+
}
69+
}
70+
71+
if (!screenshotTestRun) {
72+
console.log('Screenshot test job not found');
73+
return;
74+
}
75+
76+
// Check if the job failed
77+
if (screenshotTestRun.conclusion === 'failure') {
78+
core.setOutput('failed', 'true');
79+
} else {
80+
core.setOutput('failed', 'false');
81+
}
82+
- name: Find Existing Comment
83+
uses: peter-evans/find-comment@v3
84+
id: existingCommentId
85+
with:
86+
issue-number: ${{ github.event.pull_request.number }}
87+
comment-author: 'github-actions[bot]'
88+
body-includes: Screenshot tests have failed.
89+
90+
- name: Comment on PR if tests fail
91+
if: steps.check-status.outputs.failed == 'true'
92+
uses: peter-evans/create-or-update-comment@v4
93+
with:
94+
issue-number: ${{ github.event.pull_request.number }}
95+
body: |
96+
🖼️ **Screenshot tests have failed.**
97+
98+
The purpose of these tests is to ensure that changes introduced in this PR don't break visual features. They are visual unit tests.
99+
100+
📄 **Where to find the report:**
101+
- Go to the (failed run) > Summary > Artifacts > screenshot-test-report
102+
- Download the zip and open jme3-screenshot-tests/build/reports/ScreenshotDiffReport.html
103+
104+
⚠️ **If you didn't expect to change anything visual:**
105+
Fix your changes so the screenshot tests pass.
106+
107+
✅ **If you did mean to change things:**
108+
Review the replacement images in jme3-screenshot-tests/build/changed-images to make sure they really are improvements and then replace and commit the replacement images at jme3-screenshot-tests/src/test/resources.
109+
110+
✨ **If you are creating entirely new tests:**
111+
Find the new images in jme3-screenshot-tests/build/changed-images and commit the new images at jme3-screenshot-tests/src/test/resources.
112+
113+
**Note;** it is very important that the committed reference images are created on the build pipeline, locally created images are not reliable. Similarly tests will fail locally but you can look at the report to check they are "visually similar".
114+
115+
See https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-screenshot-tests/README.md for more information
116+
117+
Contact @richardTingle (aka richtea) for guidance if required
118+
edit-mode: replace
119+
comment-id: ${{ steps.existingCommentId.outputs.comment-id }}

common.gradle

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -157,27 +157,35 @@ publishing {
157157
version project.version
158158
}
159159
}
160+
160161
repositories {
161162
maven {
162163
name = 'Dist'
163164
url = gradle.rootProject.projectDir.absolutePath + '/dist/maven'
164165
}
166+
167+
// Uploading to Sonatype relies on the existence of 2 properties
168+
// (centralUsername and centralPassword)
169+
// which should be set using -P options on the command line.
170+
171+
maven {
172+
// for uploading release builds to the default repo in Sonatype's OSSRH staging area
173+
credentials {
174+
username = gradle.rootProject.hasProperty('centralUsername') ? centralUsername : 'Unknown user'
175+
password = gradle.rootProject.hasProperty('centralPassword') ? centralPassword : 'Unknown password'
176+
}
177+
name = 'Central'
178+
url = 'https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/'
179+
}
165180
maven {
181+
// for uploading snapshot builds to Sonatype's maven-snapshots repo
166182
credentials {
167-
username = gradle.rootProject.hasProperty('ossrhUsername') ? ossrhUsername : 'Unknown user'
168-
password = gradle.rootProject.hasProperty('ossrhPassword') ? ossrhPassword : 'Unknown password'
183+
username = gradle.rootProject.hasProperty('centralUsername') ? centralUsername : 'Unknown user'
184+
password = gradle.rootProject.hasProperty('centralPassword') ? centralPassword : 'Unknown password'
169185
}
170-
name = 'OSSRH'
171-
url = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2'
186+
name = 'SNAPSHOT'
187+
url = 'https://central.sonatype.com/repository/maven-snapshots/'
172188
}
173-
maven {
174-
credentials {
175-
username = gradle.rootProject.hasProperty('ossrhUsername') ? ossrhUsername : 'Unknown user'
176-
password = gradle.rootProject.hasProperty('ossrhPassword') ? ossrhPassword : 'Unknown password'
177-
}
178-
name = 'SNAPSHOT'
179-
url = 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
180-
}
181189
}
182190
}
183191

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Version number: Major.Minor.SubMinor (e.g. 3.3.0)
2-
jmeVersion = 3.8.0
2+
jmeVersion = 3.9.0
33

44
# Leave empty to autogenerate
55
# (use -PjmeVersionName="myVersion" from commandline to specify a custom version name )

0 commit comments

Comments
 (0)