Skip to content

Test parallel test actions #7944

Test parallel test actions

Test parallel test actions #7944

Workflow file for this run

name: Java 21 CI (MC 1.20.6+)
on:
push:
branches:
- master
- 'dev/**'
pull_request:
jobs:
prepare:
if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.split.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- name: Split environments into balanced groups
id: split
run: |
# This code was primarily generated by Claude AI. Beware of potential mistakes. - sovde
# Number of parallel jobs
N=3
# Find all JSON files in environments directory
files=$(find environments -name "*.json" -type f | sort)
mapfile -t file_array <<< "$files"
total=${#file_array[@]}
# Calculate items per group (round up)
per_group=$(( (total + N - 1) / N ))
# Build JSON matrix
matrix_json='{"include":['
for i in $(seq 0 $((N - 1))); do
start=$((i * per_group))
end=$((start + per_group))
# Get slice of files for this group
group_files=$(printf '%s\n' "${file_array[@]:$start:$per_group}" | jq -R . | jq -s -c .)
if [ $i -gt 0 ]; then
matrix_json+=","
fi
matrix_json+="{\"group\":$((i + 1)),\"files\":$group_files}"
done
matrix_json+=']}'
echo "matrix=$matrix_json" >> $GITHUB_OUTPUT
echo "Generated matrix:"
echo "$matrix_json" | jq .
build:
needs: prepare
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}
steps:
- uses: actions/checkout@v5
with:
submodules: recursive
- name: Display group info
run: |
echo "Processing Group ${{ matrix.group }}"
echo "Files in this group:"
echo '${{ toJSON(matrix.files) }}' | jq -r '.[]'
- name: validate gradle wrapper
uses: gradle/actions/wrapper-validation@v4
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# - name: Build Skript and run test scripts
# run: ./gradlew clean skriptTestJava21 -PparallelTests=true
# - name: Upload Nightly Build
# uses: actions/upload-artifact@v4
# if: success()
# with:
# name: skript-nightly
# path: build/libs/*