Skip to content

Commit 5e20972

Browse files
authored
Merge branch 'dev/feature' into feature/pdc_round_2
2 parents a43152d + 24a2435 commit 5e20972

40 files changed

Lines changed: 749 additions & 312 deletions

.github/workflows/java-17-builds.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/java-21-builds.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Java 21 CI (MC 1.20.6+)
1+
name: Java 21 CI
22

33
on:
44
push:
@@ -8,9 +8,21 @@ on:
88
pull_request:
99

1010
jobs:
11-
build:
11+
prepare:
12+
name: Parallelize Tests
1213
if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
14+
uses: ./.github/workflows/parallelize-tests.yml
15+
with:
16+
environments: 1.21,1.21.1,1.21.3,1.21.4,1.21.5,1.21.8,1.21.10
17+
java_version: 21
18+
parallel_jobs: 3
19+
20+
build:
21+
name: ${{ matrix.display }}
22+
needs: prepare
1323
runs-on: ubuntu-latest
24+
strategy:
25+
matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}
1426
steps:
1527
- uses: actions/checkout@v5
1628
with:
@@ -26,10 +38,10 @@ jobs:
2638
- name: Grant execute permission for gradlew
2739
run: chmod +x gradlew
2840
- name: Build Skript and run test scripts
29-
run: ./gradlew clean skriptTestJava21
41+
run: ./gradlew clean customTest -PtestEnvs="${{ matrix.envs }}" -PtestEnvJavaVersion=21
3042
- name: Upload Nightly Build
3143
uses: actions/upload-artifact@v4
32-
if: success()
44+
if: success() && matrix.id == 1
3345
with:
3446
name: skript-nightly
3547
path: build/libs/*

.github/workflows/junit-17-builds.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/junit-21-builds.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: JUnit (MC 1.20.6+)
1+
name: JUnit 21
22

33
on:
44
push:
@@ -8,9 +8,21 @@ on:
88
pull_request:
99

1010
jobs:
11-
build:
11+
prepare:
12+
name: Parallelize Tests
1213
if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
14+
uses: ./.github/workflows/parallelize-tests.yml
15+
with:
16+
environments: 1.21,1.21.1,1.21.3,1.21.4,1.21.5,1.21.8,1.21.10
17+
java_version: 21
18+
parallel_jobs: 3
19+
20+
build:
21+
name: ${{ matrix.display }}
22+
needs: prepare
1323
runs-on: ubuntu-latest
24+
strategy:
25+
matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}
1426
steps:
1527
- uses: actions/checkout@v5
1628
with:
@@ -25,5 +37,5 @@ jobs:
2537
cache: gradle
2638
- name: Grant execute permission for gradlew
2739
run: chmod +x gradlew
28-
- name: Build Skript and run JUnit
29-
run: ./gradlew clean JUnitJava21
40+
- name: Build Skript and run test scripts
41+
run: ./gradlew clean customTest -PtestEnvs="${{ matrix.envs }}" -PtestEnvJavaVersion=21 -Pjunit=true
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Parallelize Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
environments:
7+
required: true
8+
type: string
9+
parallel_jobs:
10+
required: false
11+
type: number
12+
default: 2
13+
java_version:
14+
required: true
15+
type: number
16+
outputs:
17+
matrix:
18+
description: "Generated test matrix"
19+
value: ${{ jobs.prepare.outputs.matrix }}
20+
21+
jobs:
22+
prepare:
23+
name: ""
24+
runs-on: ubuntu-latest
25+
outputs:
26+
matrix: ${{ steps.set-matrix.outputs.matrix }}
27+
steps:
28+
- name: Generate matrix
29+
id: set-matrix
30+
run: |
31+
# Use environment variables
32+
N=${{ inputs.parallel_jobs }}
33+
JAVA_VERSION=${{ inputs.java_version }}
34+
35+
# Convert to array and transform
36+
IFS=',' read -ra ENVS <<< "${{ inputs.environments }}"
37+
TRANSFORMED=()
38+
for env in "${ENVS[@]}"; do
39+
TRANSFORMED+=("java${JAVA_VERSION}/paper-${env}")
40+
done
41+
42+
TOTAL=${#TRANSFORMED[@]}
43+
44+
# avoid creating more jobs than needed
45+
JOBS=$((TOTAL < N ? TOTAL : N))
46+
# environments per job
47+
BASE=$((TOTAL / JOBS))
48+
EXTRA=$((TOTAL % JOBS))
49+
50+
# Build matrix JSON
51+
# Format is:
52+
# [{"id":1,"envs":"java21/paper-1.20.6,java21/paper-1.21.3","display":"1.20.6, 1.21.3"},...]
53+
# Where "envs" is the actual environment strings and "display" is for easier identification
54+
MATRIX="["
55+
INDEX=0
56+
for ((i=0; i<JOBS; i++)); do
57+
# Determine count for this job (BASE + 1 if i < EXTRA)
58+
COUNT=$BASE
59+
if [ $i -lt $EXTRA ]; then
60+
COUNT=$((COUNT + 1))
61+
fi
62+
63+
# Build envs and display strings
64+
GROUP=""
65+
DISPLAY_GROUP=""
66+
for ((j=0; j<COUNT; j++)); do
67+
if [ -n "$GROUP" ]; then
68+
GROUP="$GROUP,"
69+
DISPLAY_GROUP="$DISPLAY_GROUP, "
70+
fi
71+
GROUP="$GROUP${TRANSFORMED[$INDEX]}"
72+
DISPLAY_GROUP="$DISPLAY_GROUP${ENVS[$INDEX]}"
73+
INDEX=$((INDEX + 1))
74+
done
75+
76+
# add to matrix with separating comma if needed
77+
if [ $i -gt 0 ]; then
78+
MATRIX="$MATRIX,"
79+
fi
80+
MATRIX="$MATRIX{\"id\":$((i+1)),\"envs\":\"$GROUP\",\"display\":\"$DISPLAY_GROUP\"}"
81+
done
82+
MATRIX="$MATRIX]"
83+
84+
echo "matrix={\"include\":$MATRIX}" >> $GITHUB_OUTPUT
85+
echo "Generated matrix: {\"include\":$MATRIX}"

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,12 @@ Skript has some tests written in Skript. Running them requires a Minecraft
7373
server, but our build script will create one for you. Running the tests is easy:
7474

7575
```
76-
./gradlew (quickTest|skriptTest|skriptTestJava17|skriptTestJava21)
76+
./gradlew (quickTest|skriptTest|skriptTestJava21)
7777
```
7878

7979
<code>quickTest</code> runs the test suite on newest supported server version.
80-
<code>skriptTestJava21</code> (1.20.6+) runs the tests on Java 21 supported versions.
81-
<code>skriptTestJava17</code> (1.20.4) runs the tests on Java 17 supported versions.
82-
<code>skriptTest</code> runs the tests on all versions.
83-
That is, it runs skriptTestJava17, and skriptTestJava21.
80+
<code>skriptTestJava21</code> (1.21+) runs the tests on Java 21 supported versions.
81+
<code>skriptTest</code> runs the tests on all versions (currently identical to the Java 21 test).
8482

8583
By running the tests, you agree to Mojang's End User License Agreement.
8684

0 commit comments

Comments
 (0)