Skip to content

chore(ci): enable gradle cache #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .checkov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
skip-check:
- CKV2_GHA_1 # FIXME: comply with this check
9 changes: 9 additions & 0 deletions .github/actionlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
self-hosted-runner:
labels:
- blacksmith-2vcpu-ubuntu-2204

paths:
.github/workflows/lifecycle.yml:
ignore:
- '.+ is not defined in object type .+'
9 changes: 6 additions & 3 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/flex-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
104 changes: 103 additions & 1 deletion .github/workflows/lifecycle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand 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:
Expand All @@ -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:
Expand Down
36 changes: 28 additions & 8 deletions .github/workflows/run-gametests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: Run gametests

"on":
on:
workflow_dispatch: # TODO: add relevant inputs

jobs: # TODO: add cleanup job
Expand All @@ -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 }}
Expand All @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-local-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 12 additions & 0 deletions .mega-linter.yml
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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]
1 change: 1 addition & 0 deletions 1_12/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
org.gradle.jvmargs = -Xmx2G
org.gradle.caching = true

minecraft_version = 1.12.2
lexforge_version = 14.23.5.2860
Expand Down
4 changes: 2 additions & 2 deletions 1_16/gradle.properties
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions 1_17/gradle.properties
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions 1_18/gradle.properties
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions 1_19/gradle.properties
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions 1_20/gradle.properties
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions 1_20_1/gradle.properties
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions 1_20_6/gradle.properties
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions 1_21/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
org.gradle.jvmargs = -Xmx2G
org.gradle.caching = true

minecraft_version = 1.21.3
# TODO: can this be removed?
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
Loading