Skip to content

Commit df2a579

Browse files
author
Jesus Oliver
committed
Merge branch 'master' into ios-2024_2
2 parents effe3f2 + 0248d8e commit df2a579

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
@@ -412,16 +412,16 @@ jobs:
412412
name: ios-natives
413413
path: jme3-ios-native/template/META-INF/robovm/ios/libs/jme3-ios-native.xcframework
414414

415-
- name: Rebuild the maven artifacts and deploy them to the Sonatype repository
415+
- name: Rebuild the maven artifacts and upload them to Sonatype's maven-snapshots repo
416416
run: |
417-
if [ "${{ secrets.OSSRH_PASSWORD }}" = "" ];
417+
if [ "${{ secrets.CENTRAL_PASSWORD }}" = "" ];
418418
then
419-
echo "Configure the following secrets to enable deployment to Sonatype:"
420-
echo "OSSRH_PASSWORD, OSSRH_USERNAME, SIGNING_KEY, SIGNING_PASSWORD"
419+
echo "Configure the following secrets to enable uploading to Sonatype:"
420+
echo "CENTRAL_PASSWORD, CENTRAL_USERNAME, SIGNING_KEY, SIGNING_PASSWORD"
421421
else
422422
./gradlew publishMavenPublicationToSNAPSHOTRepository \
423-
-PossrhPassword=${{ secrets.OSSRH_PASSWORD }} \
424-
-PossrhUsername=${{ secrets.OSSRH_USERNAME }} \
423+
-PcentralPassword=${{ secrets.CENTRAL_PASSWORD }} \
424+
-PcentralUsername=${{ secrets.CENTRAL_USERNAME }} \
425425
-PsigningKey='${{ secrets.SIGNING_KEY }}' \
426426
-PsigningPassword='${{ secrets.SIGNING_PASSWORD }}' \
427427
-PuseCommitHashAsVersionName=true \
@@ -437,13 +437,13 @@ jobs:
437437
if: github.event_name == 'release'
438438
steps:
439439

440-
# We need to clone everything again for uploadToMaven.sh ...
440+
# We need to clone everything again for uploadToCentral.sh ...
441441
- name: Clone the repo
442442
uses: actions/checkout@v4
443443
with:
444444
fetch-depth: 1
445445

446-
# Setup jdk 21 used for building Sonatype OSSRH artifacts
446+
# Setup jdk 21 used for building Sonatype artifacts
447447
- name: Setup the java environment
448448
uses: actions/setup-java@v4
449449
with:
@@ -475,20 +475,23 @@ jobs:
475475
name: ios-natives
476476
path: jme3-ios-native/template/META-INF/robovm/ios/libs/jme3-ios-native.xcframework
477477

478-
- name: Rebuild the maven artifacts and deploy them to Sonatype OSSRH
478+
- name: Rebuild the maven artifacts and upload them to Sonatype's Central Publisher Portal
479479
run: |
480-
if [ "${{ secrets.OSSRH_PASSWORD }}" = "" ];
480+
if [ "${{ secrets.CENTRAL_PASSWORD }}" = "" ];
481481
then
482-
echo "Configure the following secrets to enable deployment to Sonatype:"
483-
echo "OSSRH_PASSWORD, OSSRH_USERNAME, SIGNING_KEY, SIGNING_PASSWORD"
482+
echo "Configure the following secrets to enable uploading to Sonatype:"
483+
echo "CENTRAL_PASSWORD, CENTRAL_USERNAME, SIGNING_KEY, SIGNING_PASSWORD"
484484
else
485-
./gradlew publishMavenPublicationToOSSRHRepository \
486-
-PossrhPassword=${{ secrets.OSSRH_PASSWORD }} \
487-
-PossrhUsername=${{ secrets.OSSRH_USERNAME }} \
488-
-PsigningKey='${{ secrets.SIGNING_KEY }}' \
489-
-PsigningPassword='${{ secrets.SIGNING_PASSWORD }}' \
490-
-PuseCommitHashAsVersionName=true \
491-
--console=plain --stacktrace
485+
./gradlew publishMavenPublicationToCentralRepository \
486+
-PcentralPassword=${{ secrets.CENTRAL_PASSWORD }} \
487+
-PcentralUsername=${{ secrets.CENTRAL_USERNAME }} \
488+
-PsigningKey='${{ secrets.SIGNING_KEY }}' \
489+
-PsigningPassword='${{ secrets.SIGNING_PASSWORD }}' \
490+
-PuseCommitHashAsVersionName=true \
491+
--console=plain --stacktrace
492+
.github/actions/tools/uploadToCentral.sh \
493+
-p '${{ secrets.CENTRAL_PASSWORD }}' \
494+
-u '${{ secrets.CENTRAL_USERNAME }}'
492495
fi
493496
494497
- 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)