Skip to content

Commit

Permalink
Merge branch 'dev/feature' into ench/update-player-parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
AyhamAl-Ali authored Sep 21, 2023
2 parents 5d1e248 + 1ffe86f commit 7a8ec24
Show file tree
Hide file tree
Showing 104 changed files with 2,591 additions and 2,473 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/cleanup-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Cleanup nightly documentation
on: delete
jobs:
cleanup-nightly-docs:
if: github.event.ref_type == 'branch'
runs-on: ubuntu-latest
steps:
- name: Configure workflow
id: configuration
env:
DELETED_BRANCH: ${{ github.event.ref }}
run: |
BRANCH_NAME="${DELETED_BRANCH#refs/*/}"
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT
echo "DOCS_OUTPUT_DIR=${GITHUB_WORKSPACE}/skript-docs/docs/nightly/${BRANCH_NAME}" >> $GITHUB_OUTPUT
echo "DOCS_REPO_DIR=${GITHUB_WORKSPACE}/skript-docs" >> $GITHUB_OUTPUT
- name: Checkout Skript
uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
submodules: recursive
path: skript
- name: Setup documentation environment
uses: ./skript/.github/workflows/docs/setup-docs
with:
docs_deploy_key: ${{ secrets.DOCS_DEPLOY_KEY }}
docs_output_dir: ${{ steps.configuration.outputs.DOCS_OUTPUT_DIR }}
- name: Cleanup nightly documentation
env:
DOCS_OUTPUT_DIR: ${{ steps.configuration.outputs.DOCS_OUTPUT_DIR }}
run: |
rm -rf ${DOCS_OUTPUT_DIR} || true
- name: Push nightly documentation cleanup
uses: ./skript/.github/workflows/docs/push-docs
with:
docs_repo_dir: ${{ steps.configuration.outputs.DOCS_REPO_DIR }}
git_name: Nightly Docs Bot
git_email: [email protected]
git_commit_message: "Delete ${{ steps.configuration.outputs.BRANCH_NAME }} branch nightly docs"
64 changes: 61 additions & 3 deletions .github/workflows/docs/generate-docs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,82 @@ inputs:
required: false
default: false
type: boolean
cleanup_pattern:
description: "A pattern designating which files to delete when cleaning the documentation output directory"
required: false
default: "*"
type: string

outputs:
DOCS_CHANGED:
description: "Whether or not the documentation has changed since the last push"
value: ${{ steps.generate.outputs.DOCS_CHANGED }}

runs:
using: 'composite'
steps:
- name: generate-docs
id: generate
shell: bash
env:
DOCS_OUTPUT_DIR: ${{ inputs.docs_output_dir }}
DOCS_REPO_DIR: ${{ inputs.docs_repo_dir }}
SKRIPT_REPO_DIR: ${{ inputs.skript_repo_dir }}
IS_RELEASE: ${{ inputs.is_release }}
CLEANUP_PATTERN: ${{ inputs.cleanup_pattern }}
run: |
export SKRIPT_DOCS_TEMPLATE_DIR=${DOCS_REPO_DIR}/doc-templates
export SKRIPT_DOCS_OUTPUT_DIR=${DOCS_OUTPUT_DIR}/
replace_in_directory() {
find $1 -type f -exec sed -i -e "s/$2/$3/g" {} \;
}
# this should be replaced with a more reliable jq command,
# but it can't be right now because docs.json is actually not valid json.
get_skript_version_of_directory() {
grep skriptVersion "$1/docs.json" | cut -d\" -f 4
}
if [ -d "${DOCS_REPO_DIR}/docs/templates" ]
then
export SKRIPT_DOCS_TEMPLATE_DIR=${DOCS_REPO_DIR}/docs/templates
else
export SKRIPT_DOCS_TEMPLATE_DIR=${DOCS_REPO_DIR}/doc-templates
fi
export SKRIPT_DOCS_OUTPUT_DIR=/tmp/generated-docs
cd $SKRIPT_REPO_DIR
if [[ "${IS_RELEASE}" == "true" ]]; then
./gradlew genReleaseDocs releaseJavadoc
else
./gradlew genNightlyDocs javadoc
fi
cp -a "./build/docs/javadoc/." "${DOCS_OUTPUT_DIR}/javadocs"
if [ -d "${DOCS_OUTPUT_DIR}" ]; then
mkdir -p "${SKRIPT_DOCS_OUTPUT_DIR}/javadocs" && cp -a "./build/docs/javadoc/." "$_"
mkdir -p "/tmp/normalized-output-docs" && cp -a "${DOCS_OUTPUT_DIR}/." "$_"
mkdir -p "/tmp/normalized-generated-docs" && cp -a "${SKRIPT_DOCS_OUTPUT_DIR}/." "$_"

output_skript_version=$(get_skript_version_of_directory "/tmp/normalized-output-docs")
generated_skript_version=$(get_skript_version_of_directory "/tmp/normalized-generated-docs")

replace_in_directory "/tmp/normalized-output-docs" "${output_skript_version}" "Skript"
replace_in_directory "/tmp/normalized-generated-docs" "${generated_skript_version}" "Skript"

diff -qbr /tmp/normalized-output-docs /tmp/normalized-generated-docs || diff_exit_code=$?
# If diff exits with exit code 1, that means there were some differences
if [[ ${diff_exit_code} -eq 1 ]]; then
echo "DOCS_CHANGED=true" >> $GITHUB_OUTPUT
echo "Documentation has changed since last push"
else
echo "Documentation hasn't changed since last push"
fi
else
echo "DOCS_CHANGED=true" >> $GITHUB_OUTPUT
echo "No existing documentation found"
fi

rm -rf ${DOCS_OUTPUT_DIR}/${CLEANUP_PATTERN} || true
mkdir -p "${DOCS_OUTPUT_DIR}/" && cp -a "${SKRIPT_DOCS_OUTPUT_DIR}/." "$_"


14 changes: 8 additions & 6 deletions .github/workflows/docs/push-docs/action.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: Generate documentation
name: Push documentation

inputs:
docs_output_dir:
description: "The directory to generate the documentation into"
required: true
type: string
docs_repo_dir:
description: "The skript-docs repository directory"
required: true
Expand Down Expand Up @@ -38,4 +34,10 @@ runs:
git config user.email "${GIT_EMAIL}"
git add -A
git commit -m "${GIT_COMMIT_MESSAGE}" || (echo "Nothing to push!" && exit 0)
git push origin main
# Attempt rebasing and pushing 5 times in case another job pushes before us
for i in 1 2 3 4 5
do
git pull --rebase -X theirs origin main
git push origin main && break
sleep 5
done
1 change: 0 additions & 1 deletion .github/workflows/docs/setup-docs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ runs:
CLEANUP_PATTERN: ${{ inputs.cleanup_pattern }}
run: |
eval `ssh-agent`
rm -rf ${DOCS_OUTPUT_DIR}/${CLEANUP_PATTERN} || true
echo "$DOCS_DEPLOY_KEY" | tr -d '\r' | ssh-add - > /dev/null
mkdir ~/.ssh
ssh-keyscan www.github.com >> ~/.ssh/known_hosts
4 changes: 3 additions & 1 deletion .github/workflows/java-17-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ jobs:
if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/java-8-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ jobs:
if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/junit-17-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ jobs:
if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/junit-8-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ jobs:
if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/nightly-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,48 @@ on:

jobs:
nightly-docs:
if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
if: "!contains(toJSON(github.event.commits.*.message), '[ci skip]')"
runs-on: ubuntu-latest
steps:
- name: Configure workflow
id: configuration
env:
DOCS_DEPLOY_KEY: ${{ secrets.DOCS_DEPLOY_KEY }}
run: |
if [ -n "$DOCS_DEPLOY_KEY" ]
then
echo "DOCS_DEPLOY_KEY_PRESENT=true" >> $GITHUB_OUTPUT
else
echo "Secret 'DOCS_DEPLOY_KEY' not present. Exiting job."
fi
BRANCH_NAME="${GITHUB_REF#refs/*/}"
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT
echo "DOCS_OUTPUT_DIR=${GITHUB_WORKSPACE}/skript-docs/docs/nightly/${BRANCH_NAME}" >> $GITHUB_OUTPUT
echo "DOCS_REPO_DIR=${GITHUB_WORKSPACE}/skript-docs" >> $GITHUB_OUTPUT
echo "SKRIPT_REPO_DIR=${GITHUB_WORKSPACE}/skript" >> $GITHUB_OUTPUT
- name: Checkout Skript
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
path: skript
- name: Setup documentation environment
if: steps.configuration.outputs.DOCS_DEPLOY_KEY_PRESENT == 'true'
uses: ./skript/.github/workflows/docs/setup-docs
with:
docs_deploy_key: ${{ secrets.DOCS_DEPLOY_KEY }}
docs_output_dir: ${{ steps.configuration.outputs.DOCS_OUTPUT_DIR }}
- name: Generate documentation
id: generate
if: steps.configuration.outputs.DOCS_DEPLOY_KEY_PRESENT == 'true'
uses: ./skript/.github/workflows/docs/generate-docs
with:
docs_output_dir: ${{ steps.configuration.outputs.DOCS_OUTPUT_DIR }}
docs_repo_dir: ${{ steps.configuration.outputs.DOCS_REPO_DIR }}
skript_repo_dir: ${{ steps.configuration.outputs.SKRIPT_REPO_DIR }}
- name: Push nightly documentation
if: steps.generate.outputs.DOCS_CHANGED == 'true'
uses: ./skript/.github/workflows/docs/push-docs
with:
docs_output_dir: ${{ steps.configuration.outputs.DOCS_OUTPUT_DIR }}
docs_repo_dir: ${{ steps.configuration.outputs.DOCS_REPO_DIR }}
git_name: Nightly Docs Bot
git_email: [email protected]
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/release-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
echo "DOCS_REPO_DIR=${GITHUB_WORKSPACE}/skript-docs" >> $GITHUB_OUTPUT
echo "SKRIPT_REPO_DIR=${GITHUB_WORKSPACE}/skript" >> $GITHUB_OUTPUT
- name: Checkout Skript
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
path: skript
Expand All @@ -26,14 +26,14 @@ jobs:
with:
docs_deploy_key: ${{ secrets.DOCS_DEPLOY_KEY }}
docs_output_dir: ${{ steps.configuration.outputs.DOCS_OUTPUT_DIR }}
cleanup_pattern: "!(nightly|archives)"
- name: Generate documentation
uses: ./skript/.github/workflows/docs/generate-docs
with:
docs_output_dir: ${{ steps.configuration.outputs.DOCS_OUTPUT_DIR }}
docs_repo_dir: ${{ steps.configuration.outputs.DOCS_REPO_DIR }}
skript_repo_dir: ${{ steps.configuration.outputs.SKRIPT_REPO_DIR }}
is_release: true
cleanup_pattern: "!(nightly|archives|templates)"
- name: Push release documentation
uses: ./skript/.github/workflows/docs/push-docs
with:
Expand All @@ -56,7 +56,7 @@ jobs:
echo "DOCS_REPO_DIR=${GITHUB_WORKSPACE}/skript-docs" >> $GITHUB_OUTPUT
echo "SKRIPT_REPO_DIR=${GITHUB_WORKSPACE}/skript" >> $GITHUB_OUTPUT
- name: Checkout Skript
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
path: skript
Expand All @@ -68,14 +68,12 @@ jobs:
- name: Generate documentation
uses: ./skript/.github/workflows/docs/generate-docs
with:
docs_output_dir: ${{ steps.configuration.outputs.DOCS_OUTPUT_DIR }}
docs_repo_dir: ${{ steps.configuration.outputs.DOCS_REPO_DIR }}
skript_repo_dir: ${{ steps.configuration.outputs.SKRIPT_REPO_DIR }}
is_release: true
- name: Push archive documentation
uses: ./skript/.github/workflows/docs/push-docs
with:
docs_output_dir: ${{ steps.configuration.outputs.DOCS_OUTPUT_DIR }}
docs_repo_dir: ${{ steps.configuration.outputs.DOCS_REPO_DIR }}
git_name: Archive Docs Bot
git_email: [email protected]
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
Expand Down
33 changes: 24 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies {
implementation fileTree(dir: 'lib', include: '*.jar')

testShadow group: 'junit', name: 'junit', version: '4.13.2'
testShadow group: 'org.easymock', name: 'easymock', version: '5.1.0'
testShadow group: 'org.easymock', name: 'easymock', version: '5.2.0'
}

task checkAliases {
Expand Down Expand Up @@ -149,14 +149,6 @@ license {
exclude('**/*.json') // JSON files do not have headers
}

javadoc {
source = sourceSets.main.allJava
classpath = configurations.compileClasspath
options.encoding = 'UTF-8'
// currently our javadoc has a lot of errors, so we need to suppress the linter
options.addStringOption('Xdoclint:none', '-quiet')
}

task releaseJavadoc(type: Javadoc) {
title = project.property('version')
source = sourceSets.main.allJava
Expand Down Expand Up @@ -394,3 +386,26 @@ task nightlyRelease(type: ShadowJar) {
)
}
}

javadoc {
dependsOn nightlyResources

source = sourceSets.main.allJava

exclude("ch/njol/skript/conditions/**")
exclude("ch/njol/skript/expressions/**")
exclude("ch/njol/skript/effects/**")
exclude("ch/njol/skript/events/**")
exclude("ch/njol/skript/sections/**")
exclude("ch/njol/skript/structures/**")
exclude("ch/njol/skript/lang/function/EffFunctionCall.java")
exclude("ch/njol/skript/lang/function/ExprFunctionCall.java")
exclude("ch/njol/skript/hooks/**")
exclude("ch/njol/skript/test/**")

classpath = configurations.compileClasspath + sourceSets.main.output
options.encoding = 'UTF-8'
// currently our javadoc has a lot of errors, so we need to suppress the linter
options.addStringOption('Xdoclint:none', '-quiet')
}

6 changes: 5 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true

groupid=ch.njol
name=skript
version=2.7.0-beta3
version=2.8.0-dev
jarName=Skript.jar
testEnv=java17/paper-1.20.1
testEnvJavaVersion=17
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 7a8ec24

Please sign in to comment.