Skip to content

Create CommandBuildContext only once in later versions #3263

Create CommandBuildContext only once in later versions

Create CommandBuildContext only once in later versions #3263

Workflow file for this run

# Automatically build the project and run any configured tests for every push
# and submitted pull request. This can help catch issues that only occur on
# certain platforms or Java versions, and provides a first line of defence
# against bad commits.
name: build
on:
push:
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
strategy:
matrix:
# Use these Java versions
java: [
21, # Current Java LTS & minimum supported by Minecraft
]
# and run on both Linux and Windows
# os: [ubuntu-20.04, windows-2022]
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}
steps:
### Set up ###
- name: Checkout the CommandAPI repository
uses: actions/checkout@v3
- name: Setup JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.java }}
cache: maven
### Documentation ###
# Build the documentation first. Building the CommandAPI takes some time and nobody wants to wait until the whole
# CommandAPI has been built to realize that someone left a trailing space in one Markdown file in the documentation!
- name: Run markdownlint on all documentation Markdown documents
uses: DavidAnson/markdownlint-cli2-action@v8
with:
globs: 'docssrc/src/*.md'
- name: Build the documentation with mdBook
continue-on-error: true # If link checking fails with 403, that's probably just a timing/automated-related issue. We can ignore those - forcing the whole build to fail for this is not ideal.
run: |
cd docssrc
curl -LJO https://github.com/JorelAli/mdBook/releases/download/v0.4.21-fa6/mdbook-fa6 && chmod +x mdbook-fa6
mkdir -p mdbook-linkcheck && cd "$_" && curl -L https://github.com/Michael-F-Bryan/mdbook-linkcheck/releases/latest/download/mdbook-linkcheck.x86_64-unknown-linux-gnu.zip -o mdbook-linkcheck.zip && unzip "$_" && chmod +x mdbook-linkcheck && export PATH=$PWD:$PATH && cd ..
./mdbook-fa6 build
### Compilation ###
- name: Setup Paper NMS for all applicable versions
run: ./setupPaperNMS.sh
- name: Build the CommandAPI (Bukkit+Velocity) using maven
run: mvn clean install --batch-mode -P Platform.Bukkit,Platform.Velocity
- name: Check NMS_Common compiles against all compatible Minecraft versions
run: |
mvn clean package -pl :commandapi-bukkit-nms-common -P Platform.Bukkit,Spigot_1_17_R1
mvn clean package -pl :commandapi-bukkit-nms-common -P Platform.Bukkit,Spigot_1_18_R1
mvn clean package -pl :commandapi-bukkit-nms-common -P Platform.Bukkit,Spigot_1_18_2_R2
mvn clean package -pl :commandapi-bukkit-nms-common -P Platform.Bukkit,Spigot_1_19_R1
mvn clean package -pl :commandapi-bukkit-nms-common -P Platform.Bukkit,Spigot_1_19_3_R2
mvn clean package -pl :commandapi-bukkit-nms-common -P Platform.Bukkit,Spigot_1_20_R1
mvn clean package -pl :commandapi-bukkit-nms-common -P Platform.Bukkit,Spigot_1_20_2_R2;
# Not Spigot_1_20_4_R3. This isn't compatible with NMS_CommonWithFunctions
# mvn clean package -pl :commandapi-bukkit-nms-common -P Platform.Bukkit,Spigot_1_20_4_R3;
# - name: validate version-specific dependencies (nms-common)
# run: |
# nms_common_path="commandapi-platforms/commandapi-bukkit/commandapi-bukkit-nms/commandapi-bukkit-nms-common/target/classes/dev/jorel/commandapi/nms/NMS_Common.class"
# if ! command -v javap &> /dev/null
# then
# echo "javap could not be found, skipping NMS Common validation check"
# exit
# else
# javapcommand=$(javap -v $nms_common_path | grep -E '#[0-9]+ = Class ' | cut -c 46- | sort | grep 'org/bukkit/craftbukkit')
# if [[ -n "$javapcommand" ]]; then
# echo "NMS Common has version-specific dependencies!"
# echo $javapcommand
# exit 1
# else
# echo "NMS Common has no version-specific dependencies :)"
# fi
# fi
### Bukkit tests across all NMS versions ###
# Dev note: Yes, I know I could put this under one run section, but it's a million times easier
# to see which version failed when it's got the version name and subsection in GitHub Actions
- name: Run Bukkit unit tests across all versions (1.20.5 - 1.20.6)
continue-on-error: true
run: mvn clean package -pl :commandapi-bukkit-test-tests -P Platform.Bukkit -Dmaven.javadoc.skip=true -P Minecraft_1_20_5
- name: Run Bukkit unit tests across all versions (Mojang Mapped 1.20.5 - 1.20.6)
continue-on-error: true
run: mvn clean package -pl :commandapi-bukkit-test-tests -P Platform.Bukkit -Dmaven.javadoc.skip=true -P Minecraft_1_20_5_Mojang
- name: Run Bukkit unit tests across all versions (1.20.3 - 1.20.4)
continue-on-error: true
run: mvn clean package -pl :commandapi-bukkit-test-tests -P Platform.Bukkit -Dmaven.javadoc.skip=true -P Minecraft_1_20_3
- name: Run Bukkit unit tests across all versions (1.20.2)
continue-on-error: true
run: mvn clean package -pl :commandapi-bukkit-test-tests -P Platform.Bukkit -Dmaven.javadoc.skip=true -P Minecraft_1_20_2
- name: Run Bukkit unit tests across all versions (1.20 - 1.20.1)
continue-on-error: true
run: mvn clean package -pl :commandapi-bukkit-test-tests -P Platform.Bukkit -Dmaven.javadoc.skip=true -P Minecraft_1_20
- name: Run Bukkit unit tests across all versions (Mojang Mapped 1.20 - 1.20.1)
continue-on-error: true
run: mvn clean package -pl :commandapi-bukkit-test-tests -P Platform.Bukkit -Dmaven.javadoc.skip=true -P Minecraft_1_20_Mojang
- name: Run Bukkit unit tests across all versions (1.19.4)
continue-on-error: true
run: mvn clean package -pl :commandapi-bukkit-test-tests -P Platform.Bukkit -Dmaven.javadoc.skip=true -P Minecraft_1_19_4
- name: Run Bukkit unit tests across all versions (Mojang Mapped 1.19.4)
continue-on-error: true
run: mvn clean package -pl :commandapi-bukkit-test-tests -P Platform.Bukkit -Dmaven.javadoc.skip=true -P Minecraft_1_19_4_Mojang
- name: Run Bukkit unit tests across all versions (1.19.2)
continue-on-error: true
run: mvn clean package -pl :commandapi-bukkit-test-tests -P Platform.Bukkit -Dmaven.javadoc.skip=true -P Minecraft_1_19_2
- name: Run Bukkit unit tests across all versions (1.18)
continue-on-error: true
run: mvn clean package -pl :commandapi-bukkit-test-tests -P Platform.Bukkit -Dmaven.javadoc.skip=true -P Minecraft_1_18
- name: Run Bukkit unit tests across all versions (1.17)
continue-on-error: true
run: mvn clean package -pl :commandapi-bukkit-test-tests -P Platform.Bukkit -Dmaven.javadoc.skip=true -P Minecraft_1_17
- name: Run Bukkit unit tests across all versions (1.16.5)
continue-on-error: true
run: mvn clean package -pl :commandapi-bukkit-test-tests -P Platform.Bukkit -Dmaven.javadoc.skip=true -P Minecraft_1_16_5
# It doesn't matter which version the Kotlin DSL uses. It should be version independent
- name: Run Bukkit Kotlin DSL unit tests
continue-on-error: true
run: mvn clean package -pl :commandapi-bukkit-kotlin-test -P Platform.Bukkit -Dmaven.javadoc.skip=true -P Minecraft_1_19_2
### Upload .jar artifacts ###
- name: Upload CommandAPI (Spigot) plugin artifact
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v3
with:
name: CommandAPI (Spigot plugin)
path: |
commandapi-platforms/commandapi-spigot/commandapi-spigot-plugin/target/CommandAPI*.jar
!commandapi-platforms/commandapi-spigot/commandapi-spigot-plugin/target/*sources.jar
!commandapi-platforms/commandapi-spigot/commandapi-spigot-plugin/target/*javadoc.jar
- name: Upload CommandAPI (Paper) plugin artifact
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v3
with:
name: CommandAPI (Paper plugin)
path: |
commandapi-platforms/commandapi-paper/commandapi-paper-plugin/target/CommandAPI*.jar
!commandapi-platforms/commandapi-paper/commandapi-paper-plugin/target/*sources.jar
!commandapi-platforms/commandapi-paper/commandapi-paper-plugin/target/*javadoc.jar
- name: Upload CommandAPI (Velocity) plugin artifact
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v3
with:
name: CommandAPI (Velocity plugin)
path: |
commandapi-platforms/commandapi-velocity/commandapi-velocity-plugin/target/CommandAPI*.jar
!commandapi-platforms/commandapi-velocity/commandapi-velocity-plugin/target/*sources.jar
!commandapi-platforms/commandapi-velocity/commandapi-velocity-plugin/target/*javadoc.jar
### Examples ###
- name: Build CommandAPI example plugins in examples/ folder
run: cd ./examples; ./build.sh;
### Save PR information for 'SonarAnalyze'
- name: Save PR number to file
if: github.event_name == 'pull_request' && ${{ matrix.os }} == 'ubuntu-latest' && ${{ matrix.java_version }} == '21'
run: echo ${{ github.event.number }} > PR_NUMBER.txt
- name: Archive PR number
if: github.event_name == 'pull_request' && ${{ matrix.os }} == 'ubuntu-latest' && ${{ matrix.java_version }} == '21'
uses: actions/upload-artifact@v3
with:
name: PR_NUMBER
path: PR_NUMBER.txt
snapshot-deploy:
needs: build # Only run if "build" succeeds
runs-on: ubuntu-latest
if: github.repository == 'JorelAli/CommandAPI' && github.ref == 'refs/heads/dev/dev'
steps:
- name: Checkout the CommandAPI repository
uses: actions/checkout@v3
- name: Setup JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
server-id: ossrh # Needs to match the id in the main pom.xml file
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
java-version: 21
cache: maven
- name: Deploy snapshot version of the CommandAPI (Bukkit+Velocity) to the Sonatype snapshot repository
run: |
if mvn help:evaluate -Dexpression=project.version -q -DforceStdout | grep -E -q '\-SNAPSHOT$'; then
echo "SNAPSHOT version detected: $(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)"
mvn deploy --batch-mode -P Platform.Bukkit,Platform.Velocity -DskipTests=true
else
echo "Version is not a SNAPSHOT version, not deploying to Sonatype Snapshot repo"
fi
env:
MAVEN_USERNAME: ${{ secrets.OSS_SONATYPE_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSS_SONATYPE_PASSWORD }}