diff --git a/.checkov.yml b/.checkov.yml new file mode 100644 index 0000000..2cb3edf --- /dev/null +++ b/.checkov.yml @@ -0,0 +1,2 @@ +skip-check: + - CKV2_GHA_1 # FIXME: comply with this check diff --git a/.github/actionlint.yml b/.github/actionlint.yml new file mode 100644 index 0000000..0488a83 --- /dev/null +++ b/.github/actionlint.yml @@ -0,0 +1,9 @@ +--- +self-hosted-runner: + labels: + - blacksmith-2vcpu-ubuntu-2204 + +paths: + .github/workflows/lifecycle.yml: + ignore: + - '.+ is not defined in object type .+' diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 22dfa62..e9ee9aa 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -5,9 +5,12 @@ ":enablePreCommit", "config:best-practices" ], - "platform": "github", - "onboarding": false, - "requireConfig": "optional", + "gradle": { // FIXME: renovate runs gradle builds, leading to timeout + "enabled": false + } + "platform": "github", // global + "onboarding": false, // global + "requireConfig": "optional", // global "timezone": "UTC", "dependencyDashboard": true, "platformCommit": true, diff --git a/.github/workflows/flex-build.yml b/.github/workflows/flex-build.yml index 8e978be..8764097 100644 --- a/.github/workflows/flex-build.yml +++ b/.github/workflows/flex-build.yml @@ -60,12 +60,10 @@ jobs: - if: steps.cache.outputs.cache-hit != 'true' name: Setup Gradle uses: useblacksmith/setup-gradle/setup-gradle@v5 - with: - workflow-job-context: '{}' # FIXME: avoid this cache duplication workaround - if: | steps.cache.outputs.cache-hit != 'true' - && !inputs.release + && !inputs.publish name: Gradle build run: > ./gradlew build --stacktrace @@ -74,7 +72,7 @@ jobs: -Pneoforge_version=${{ inputs.neo }} working-directory: ${{ inputs.dir }} - - if: inputs.release + - if: inputs.publish name: Gradle publish env: IS_MAVEN_PUB: true diff --git a/.github/workflows/lifecycle.yml b/.github/workflows/lifecycle.yml index fcea2d9..84756d0 100644 --- a/.github/workflows/lifecycle.yml +++ b/.github/workflows/lifecycle.yml @@ -13,6 +13,7 @@ name: Lifecycle - reopened workflow_dispatch: inputs: + # checkov:skip=CKV_GHA_7:These inputs are used to construct the build matrix dirs: description: Comma-delimited directories to build and run (i.e. api,1_20,1_21 ) default: "all" @@ -29,6 +30,7 @@ concurrency: # FIXME: prevent release commit cancellation jobs: release-please: + if: github.event.action != 'closed' name: Release Please runs-on: blacksmith-2vcpu-ubuntu-2204 outputs: @@ -45,9 +47,109 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} + lint: + name: Linters + runs-on: blacksmith-2vcpu-ubuntu-2204 + # if: | + # github.event.action != 'closed' + # && !contains(github.actor, 'darcusk') + env: + APPLY_FIXES: all + APPLY_FIXES_EVENT: all + APPLY_FIXES_MODE: commit + outputs: + changes_detected: ${{ steps.autocommit.outputs.changes_detected }} + commit_hash: ${{ steps.autocommit.outputs.commit_hash }} + permissions: + contents: write + issues: write + pull-requests: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + ref: ${{ github.head_ref }} + + - name: Paths filter + uses: dorny/paths-filter@v3.0.2 + id: filter + with: + list-files: shell + filters: | + addedOrModified: + - added|modified: '**' + + - name: Setup Python + uses: useblacksmith/setup-python@v6 + with: + python-version: "3.12" + + - name: Cache pre-commit + uses: useblacksmith/cache@v5 + with: + path: ~/.cache/pre-commit + key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} + + - name: Install pre-commit + shell: bash + run: | + python -m pip install pre-commit==4.0.1 + python -m pip freeze --local + + - name: Run pre-commit + id: precommit + shell: bash + run: | + # Run against changes if addedOrModified is true, else run against all files + if [[ "${{ steps.filter.outputs.addedOrModified }}" == "true" ]]; then + pre-commit run --show-diff-on-failure --color=always --files "${{ steps.filter.outputs.addedOrModified_files }}" || RETRY="changes" + else + pre-commit run --show-diff-on-failure --color=always --all-files || RETRY="allfiles" + fi + + # Retry logic + if [[ "$RETRY" == "changes" ]]; then + pre-commit run --show-diff-on-failure --color=always --files "${{ steps.filter.outputs.addedOrModified_files }}" + elif [[ "$RETRY" == "allfiles" ]]; then + pre-commit run --show-diff-on-failure --color=always --all-files + fi + + - name: Run Mega-Linter + if: ${{ !cancelled() }} + uses: oxsecurity/megalinter/flavors/java@v8.3.0 + + - name: Archive production artifacts + if: ${{ !cancelled() }} + uses: actions/upload-artifact@v4 + with: + name: Mega-Linter reports + path: | + megalinter-reports + mega-linter.log + + - name: Add reports directory to gitignore + if: ${{ !cancelled() }} + run: | + touch .gitignore; grep -qxF 'megalinter-reports/' .gitignore || + echo 'megalinter-reports/' >> .gitignore + wget https://raw.githubusercontent.com/packwiz/packwiz/refs/heads/main/go.sum + + - name: Prepare commit + if: ${{ !cancelled() }} + run: sudo chown -Rc $UID .git/ + + - name: Commit and push applied linter fixes + id: autocommit + if: ${{ !cancelled() }} + uses: stefanzweifel/git-auto-commit-action@v5.0.1 + with: + branch: ${{ github.head_ref }} + commit_message: "chore: apply linter fixes" + matrices: - if: github.event.action != 'closed' name: Construct matrices + if: github.job == 'notajob' needs: release-please runs-on: blacksmith-2vcpu-ubuntu-2204 outputs: diff --git a/.github/workflows/run-gametests.yml b/.github/workflows/run-gametests.yml index 6b782c1..949ce22 100644 --- a/.github/workflows/run-gametests.yml +++ b/.github/workflows/run-gametests.yml @@ -1,7 +1,7 @@ --- name: Run gametests -"on": +on: workflow_dispatch: # TODO: add relevant inputs jobs: # TODO: add cleanup job @@ -10,8 +10,16 @@ jobs: # TODO: add cleanup job strategy: matrix: include: - - { dir: gametest, mc: 1.20.4, lex: 49.0.38, neo: 219, java: 17 } - - { dir: 1_20, mc: 1.20.4, lex: 49.0.38, neo: 219, java: 17 } + - dir: gametest + mc: 1.20.4 + lex: 49.0.38 + neo: 219 + java: 17 + - dir: 1_20 + mc: 1.20.4 + lex: 49.0.38 + neo: 219 + java: 17 uses: ./.github/workflows/flex-build.yml with: dir: ${{ matrix.dir }} @@ -22,7 +30,7 @@ jobs: # TODO: add cleanup job merge: # TODO: simplify away this job name: Merge - needs: [build] + needs: build runs-on: blacksmith-2vcpu-ubuntu-2204 steps: - name: Merge artifacts @@ -32,13 +40,25 @@ jobs: # TODO: add cleanup job run: name: Run tests - needs: [merge] + needs: merge strategy: matrix: include: - - { mc: 1.20.4, type: lexforge, modloader: forge, regex: .*forge.*, java: 17 } - - { mc: 1.20.4, type: neoforge, modloader: neoforge, regex: .*neoforge.*, java: 17 } - - { mc: 1.20.4, type: fabric, modloader: fabric, regex: .*fabric.*, java: 17 } + - mc: 1.20.4 + type: lexforge + modloader: forge + regex: .*forge.* + java: 17 + - mc: 1.20.4 + type: neoforge + modloader: neoforge + regex: .*neoforge.* + java: 17 + - mc: 1.20.4 + type: fabric + modloader: fabric + regex: .*fabric.* + java: 17 runs-on: blacksmith-2vcpu-ubuntu-2204 steps: - name: Download artifacts diff --git a/.github/workflows/test-local-action.yml b/.github/workflows/test-local-action.yml index 30e469b..1d3b4c7 100644 --- a/.github/workflows/test-local-action.yml +++ b/.github/workflows/test-local-action.yml @@ -4,6 +4,7 @@ name: Test local action "on": workflow_dispatch: inputs: + # checkov:skip=CKV_GHA_7:The is a test workflow ref: description: Git ref to checkout before build (i.e. my-feature-branch ) default: "main" diff --git a/.mega-linter.yml b/.mega-linter.yml new file mode 100644 index 0000000..6127436 --- /dev/null +++ b/.mega-linter.yml @@ -0,0 +1,12 @@ +--- +DEFAULT_BRANCH: main +JSON_PRETTIER_FILTER_REGEX_EXCLUDE: ".release-please-manifest.json" +MARKDOWN_FILTER_REGEX_EXCLUDE: "CHANGELOG.md" +VALIDATE_ALL_CODEBASE: false +DISABLE: + - COPYPASTE + - SPELL +FILEIO_REPORTER: false +FLAVOR_SUGGESTIONS: false +SHOW_ELAPSED_TIME: true +APPLY_FIXES: all diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..6d13b59 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,33 @@ +--- +# See https://pre-commit.com for more information +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: fix-byte-order-marker + - id: mixed-line-ending + - id: check-merge-conflict + - id: check-case-conflict + - id: check-executables-have-shebangs + - id: check-shebang-scripts-are-executable + - id: check-symlinks + - id: check-json + - id: check-toml + - id: check-vcs-permalinks + - id: check-yaml + - repo: https://github.com/Lucas-C/pre-commit-hooks + rev: v1.5.5 + hooks: + - id: remove-crlf + - id: remove-tabs + - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks + rev: v2.14.0 + hooks: + - id: pretty-format-java + args: [--autofix] + - id: pretty-format-kotlin + args: [--autofix] + - id: pretty-format-toml + args: [--autofix] diff --git a/1_12/gradle.properties b/1_12/gradle.properties index ce9aae5..760c635 100644 --- a/1_12/gradle.properties +++ b/1_12/gradle.properties @@ -1,4 +1,5 @@ org.gradle.jvmargs = -Xmx2G +org.gradle.caching = true minecraft_version = 1.12.2 lexforge_version = 14.23.5.2860 diff --git a/1_16/gradle.properties b/1_16/gradle.properties index 6ab3798..0fd4304 100644 --- a/1_16/gradle.properties +++ b/1_16/gradle.properties @@ -1,8 +1,8 @@ org.gradle.jvmargs = -Xmx2G +org.gradle.caching = true minecraft_version = 1.16.5 mapping_version = 1 lexforge_version = 36.2.42 fabric_version = 0.14.24 -# Whether to use the headlessmc lwjgl agent or not -hmc.lwjgl=true +hmc.lwjgl = true diff --git a/1_17/gradle.properties b/1_17/gradle.properties index d2c134a..1e0fef2 100644 --- a/1_17/gradle.properties +++ b/1_17/gradle.properties @@ -1,8 +1,8 @@ org.gradle.jvmargs = -Xmx2G +org.gradle.caching = true minecraft_version = 1.17.1 mapping_version = 1 lexforge_version = 37.1.1 fabric_version = 0.14.24 -# Whether to use the headlessmc lwjgl agent or not -hmc.lwjgl=true +hmc.lwjgl = true diff --git a/1_18/gradle.properties b/1_18/gradle.properties index de2bca7..4d0bc24 100644 --- a/1_18/gradle.properties +++ b/1_18/gradle.properties @@ -1,8 +1,8 @@ org.gradle.jvmargs = -Xmx2G +org.gradle.caching = true minecraft_version = 1.18.2 mapping_version = 1 lexforge_version = 40.2.18 fabric_version = 0.14.24 -# Whether to use the headlessmc lwjgl agent or not -hmc.lwjgl=true +hmc.lwjgl = true diff --git a/1_19/gradle.properties b/1_19/gradle.properties index f94a7cb..fbed5c0 100644 --- a/1_19/gradle.properties +++ b/1_19/gradle.properties @@ -1,8 +1,8 @@ org.gradle.jvmargs = -Xmx2G +org.gradle.caching = true minecraft_version = 1.19.4 mapping_version = 1 lexforge_version = 45.2.9 fabric_version = 0.14.24 -# Whether to use the headlessmc lwjgl agent or not -hmc.lwjgl=true +hmc.lwjgl = true diff --git a/1_20/gradle.properties b/1_20/gradle.properties index f2988d6..3699b8d 100644 --- a/1_20/gradle.properties +++ b/1_20/gradle.properties @@ -1,9 +1,9 @@ org.gradle.jvmargs = -Xmx2G +org.gradle.caching = true minecraft_version = 1.20.4 mapping_version = 1 neoforge_version = 1-beta lexforge_version = 49.0.30 fabric_version = 0.15.9 -# Whether to use the headlessmc lwjgl agent or not -hmc.lwjgl=false +hmc.lwjgl = false diff --git a/1_20_1/gradle.properties b/1_20_1/gradle.properties index 0d9661d..f68f7ba 100644 --- a/1_20_1/gradle.properties +++ b/1_20_1/gradle.properties @@ -1,8 +1,8 @@ org.gradle.jvmargs = -Xmx2G +org.gradle.caching = true minecraft_version = 1.20.1 mapping_version = 1 lexforge_version = 47.2.23 fabric_version = 0.14.24 -# Whether to use the headlessmc lwjgl agent or not -hmc.lwjgl=true +hmc.lwjgl = true diff --git a/1_20_6/gradle.properties b/1_20_6/gradle.properties index 766c608..4a204aa 100644 --- a/1_20_6/gradle.properties +++ b/1_20_6/gradle.properties @@ -1,9 +1,9 @@ org.gradle.jvmargs = -Xmx2G +org.gradle.caching = true minecraft_version = 1.20.6 mapping_version = 1 neoforge_version = 119 lexforge_version = 50.1.10 fabric_version = 0.15.9 -# Whether to use the headlessmc lwjgl agent or not -hmc.lwjgl=false +hmc.lwjgl = false diff --git a/1_21/gradle.properties b/1_21/gradle.properties index 67ba661..49b8a41 100644 --- a/1_21/gradle.properties +++ b/1_21/gradle.properties @@ -1,4 +1,5 @@ org.gradle.jvmargs = -Xmx2G +org.gradle.caching = true minecraft_version = 1.21.3 # TODO: can this be removed? @@ -6,5 +7,4 @@ mapping_version = 1 neoforge_version = 11-beta lexforge_version = 53.0.7 fabric_version = 0.15.9 -# Whether to use the headlessmc lwjgl agent or not -hmc.lwjgl=false +hmc.lwjgl = false diff --git a/1_7_10/gradle.properties b/1_7_10/gradle.properties index a1ec878..1f9a80c 100644 --- a/1_7_10/gradle.properties +++ b/1_7_10/gradle.properties @@ -1,5 +1,6 @@ org.gradle.jvmargs = -Xmx2G +org.gradle.caching = true minecraft_version = 1.7.10 lexforge_version = 10.13.4.1614-1.7.10 -fabric_version = 0.14.20 \ No newline at end of file +fabric_version = 0.14.20 diff --git a/1_8_9/gradle.properties b/1_8_9/gradle.properties index 1e1808c..87733f3 100644 --- a/1_8_9/gradle.properties +++ b/1_8_9/gradle.properties @@ -1,4 +1,5 @@ org.gradle.jvmargs = -Xmx2G +org.gradle.caching = true minecraft_version = 1.8.9 lexforge_version = 11.15.1.2318-1.8.9 diff --git a/README.md b/README.md index 4b2f5f3..e92c0f4 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![CodeFactor](https://www.codefactor.io/repository/github/headlesshq/mc-runtime-test/badge/main)](https://www.codefactor.io/repository/github/headlesshq/mc-runtime-test/overview/main) [![GitHub All Releases](https://img.shields.io/github/downloads/headlesshq/mc-runtime-test/total.svg)](https://github.com/headlesshq/mc-runtime-test/releases) -![](https://github.com/headlesshq/mc-runtime-test/actions/workflows/run-matrix.yml/badge.svg) +![Lifecycle](https://github.com/headlesshq/mc-runtime-test/actions/workflows/lifecycle.yml/badge.svg) ![GitHub](https://img.shields.io/github/license/headlesshq/mc-runtime-test) ![Github last-commit](https://img.shields.io/github/last-commit/headlesshq/mc-runtime-test) @@ -86,12 +86,11 @@ jobs: java: ${{ env.java_version }} ``` -An example workflow in action can be found -[here](https://github.com/3arthqu4ke/hmc-optimizations/blob/1.20.4/.github/workflows/run-fabric.yml). + An example for a large matrix workflow which tests 20 different versions of Minecraft at once can be found -[here](https://github.com/3arthqu4ke/hmc-specifics/blob/main/.github/workflows/run-matrix.yml). +[here](https://github.com/3arthqu4ke/hmc-optimizations/blob/1592865073edf99c76184d7832f0f498c1299c7a/.github/workflows/run-matrix.yml). # Inputs - `mc`: The MC version to use, e.g. `1.20.4`. diff --git a/action.yml b/action.yml index 51131c6..aae06e2 100644 --- a/action.yml +++ b/action.yml @@ -1,3 +1,4 @@ +--- name: MC-Runtime-Test description: Runs the MC client inside your CI author: HeadlessHQ diff --git a/api/gradle.properties b/api/gradle.properties index d83d66c..7232997 100644 --- a/api/gradle.properties +++ b/api/gradle.properties @@ -1,3 +1,6 @@ +org.gradle.jvmargs = -Xmx2G +org.gradle.caching = true + # x-release-please-start-version project_version = 3.0.0 # x-release-please-end diff --git a/gametest/gradle.properties b/gametest/gradle.properties index ebda79d..de83e23 100644 --- a/gametest/gradle.properties +++ b/gametest/gradle.properties @@ -1,11 +1,11 @@ org.gradle.jvmargs = -Xmx2G +org.gradle.caching = true minecraft_version = 1.20.4 mapping_version = 1 neoforge_version = 1-beta lexforge_version = 49.0.30 fabric_version = 0.15.9 -# Whether to use the headlessmc lwjgl agent or not -hmc.lwjgl=true -fabric_api_version=0.96.11+1.20.4 -fabric_gametest_api_version=1.3.5+85d85a934f +hmc.lwjgl = true +fabric_api_version = 0.96.11+1.20.4 +fabric_gametest_api_version = 1.3.5+85d85a934f diff --git a/snapshots/gradle.properties b/snapshots/gradle.properties index 46d295e..d67d20b 100644 --- a/snapshots/gradle.properties +++ b/snapshots/gradle.properties @@ -1,6 +1,6 @@ org.gradle.jvmargs = -Xmx2G +org.gradle.caching = true minecraft_version = 1.20.5-pre1 fabric_version = 0.15.9 -# Whether to use the headlessmc lwjgl agent or not -hmc.lwjgl=true +hmc.lwjgl = true