Skip to content

Build and test with Scenamatica #290

Build and test with Scenamatica

Build and test with Scenamatica #290

name: Build and test with Scenamatica
on:
push:
paths:
- "Scenamatica/**"
pull_request:
paths:
- "Scenamatica/**"
workflow_dispatch:
permissions:
pull-requests: write
concurrency:
group: ${{ github.workflow }}-scenamatica-${{ github.ref }}
cancel-in-progress: true
jobs:
setup-nms:
name: Build NMS with NMSAction
strategy:
matrix:
nms-version:
- 1.16.5
- 1.16.3
- 1.15.2
- 1.14.4
- 1.13.2
- 1.13
runs-on: self-hosted
steps:
- name: Try to restore caches
uses: actions/cache@v4
id: restore-cache
with:
path: nms-build/.m2
key: nms-maven-${{ matrix.nms-version }}
restore-keys: |
nms-maven-${{ matrix.nms-version }}
lookup-only: true
- name: Build NMS if cache miss
if: steps.restore-cache.outputs.cache-hit != 'true'
uses: PeyaPeyaPeyang/nmsaction@v9
with:
rev: ${{ matrix.nms-version }}
- name: Save caches
if: steps.restore-cache.outputs.cache-hit != 'true'
uses: actions/cache@v4
with:
path: nms-build/.m2
key: nms-maven-${{ matrix.nms-version }}
build:
name: Build with Maven
runs-on: self-hosted
needs: setup-nms
steps:
- uses: actions/checkout@v4
- name: Change directory to scenamatica
run: cd Scenamatica
- name: Set up JDK 8
uses: actions/setup-java@v4
id: maven-cache
with:
java-version: 8
distribution: zulu
cache: maven
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.8.2
- uses: actions/setup-node@v4
if: steps.maven-cache.outputs.cache-hit != 'true'
with:
node-version: '20.x'
- run: npm install @actions/cache
if: steps.maven-cache.outputs.cache-hit != 'true'
- name: Restore NMS cache
uses: actions/github-script@v7
if: steps.maven-cache.outputs.cache-hit != 'true'
with:
script: |
const cache = require('@actions/cache');
const path = require('path');
const nmsVersions = [
'1.16.5',
'1.16.3',
'1.15.2',
'1.14.4',
'1.13.2',
'1.13'
];
for (const nmsVersion of nmsVersions) {
const key = `nms-maven-${nmsVersion}`;
const cacheKey = await cache.restoreCache(
['nms-build/.m2'],
key,
nmsVersions
);
if (cacheKey) {
console.log(`Cache restored from key: ${cacheKey}`);
} else {
console.error(`Cache not found for key: ${key}`);
process.exit(1);
}
}
- name: Deploy NMS cache
if: steps.maven-cache.outputs.cache-hit != 'true'
run: |
mv -f nms-build/.m2/repository/repository $HOME/.m2/ -v
- name: Build with Maven
run: |
mvn -B package --file Scenamatica/pom.xml -D"jar.finalName=Scenamatica" -P debug
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: scenamatica
path: Scenamatica/ScenamaticaPlugin/target/Scenamatica.jar
retention-days: 1
if-no-files-found: error
self-tests:
name: Self-test with Scenamatica
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
include:
- minecraft: 1.16.5
java: 16
- minecraft: 1.15.2
java: 12
- minecraft: 1.14.4
java: 12
- minecraft: 1.13.2
java: 12
steps:
- uses: actions/download-artifact@v4
with:
name: scenamatica
- name: Run Scenamatica tests
uses: teamkun/scenamatica-action@main
with:
plugin: Scenamatica.jar
java: ${{ matrix.java }}
minecraft: ${{ matrix.minecraft }}
server-dir: server-${{ matrix.minecraft }}
scenamatica: 1.1.0-pre1
report-artifact-name: scenamatica-reports-${{ matrix.minecraft }}
java-arguments: "-Xms8G -Xmx8G -XX:+UseG1GC -XX:+AlwaysPreTouch -XX:MaxGCPauseMillis=1000 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:G1NewSizePercent=50 -XX:G1MaxNewSizePercent=60 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:-ParallelRefProcEnabled -XX:MaxTenuringThreshold=10"
env:
NO_SCENAMATICA: true
timeout-minutes: 60
cleanup:
name: Clean up
runs-on: self-hosted
needs: self-tests
steps:
- name: Clean artifacts
uses: geekyeggo/delete-artifact@v2
with:
name: scenamatica