From c6a93daeb84fe14ddc8cac1676412cc870c75f6a Mon Sep 17 00:00:00 2001 From: George Higashiyama Date: Fri, 14 Jun 2024 15:44:43 -0700 Subject: [PATCH 1/6] Add xmake ci --dump command --- tools/xmakescripts/plugins/ci/dump/modes.lua | 11 ++++++++++ .../xmakescripts/plugins/ci/dump/targets.lua | 20 +++++++++++++++++++ tools/xmakescripts/plugins/ci/main.lua | 10 ++++++++++ tools/xmakescripts/plugins/ci/xmake.lua | 13 ++++++++++++ xmake.lua | 3 +++ 5 files changed, 57 insertions(+) create mode 100644 tools/xmakescripts/plugins/ci/dump/modes.lua create mode 100644 tools/xmakescripts/plugins/ci/dump/targets.lua create mode 100644 tools/xmakescripts/plugins/ci/main.lua create mode 100644 tools/xmakescripts/plugins/ci/xmake.lua diff --git a/tools/xmakescripts/plugins/ci/dump/modes.lua b/tools/xmakescripts/plugins/ci/dump/modes.lua new file mode 100644 index 000000000..77d73f279 --- /dev/null +++ b/tools/xmakescripts/plugins/ci/dump/modes.lua @@ -0,0 +1,11 @@ +import("core.project.project") +import("core.base.json") + +function main() + local modes = {} + for _, mode in pairs(project.modes()) do + table.append(modes, mode) + end + local jsonString = json.encode(modes) + io.write(jsonString) +end \ No newline at end of file diff --git a/tools/xmakescripts/plugins/ci/dump/targets.lua b/tools/xmakescripts/plugins/ci/dump/targets.lua new file mode 100644 index 000000000..b8e0faed0 --- /dev/null +++ b/tools/xmakescripts/plugins/ci/dump/targets.lua @@ -0,0 +1,20 @@ +import("core.project.config") +import("core.project.project") +import("core.base.json") +import("core.base.task") + +function main() + project.lock() + -- Check to ensure that config has been run. This will not trample the existing config if it exists. + task.run("config", {yes=true}, {disable_dump = true}) + project.load_targets() + project.unlock() + + local targets = {} + for targetname, target in pairs(project.targets()) do + targets[targetname] = {target = target:targetfile(), symbol = target:symbolfile()} + end + + local jsonString = json.encode(targets) + io.write(jsonString) +end \ No newline at end of file diff --git a/tools/xmakescripts/plugins/ci/main.lua b/tools/xmakescripts/plugins/ci/main.lua new file mode 100644 index 000000000..e00766a3c --- /dev/null +++ b/tools/xmakescripts/plugins/ci/main.lua @@ -0,0 +1,10 @@ +import("core.base.option") + +function main() + if option.get("dump") then + local module_name = string.format("dump.%s", string.lower(option.get("dump"))) + assert(import(module_name, {try = true, anonymous = true}))() + else + raise("No options provided to the xmake ci command.") + end +end \ No newline at end of file diff --git a/tools/xmakescripts/plugins/ci/xmake.lua b/tools/xmakescripts/plugins/ci/xmake.lua new file mode 100644 index 000000000..db8add598 --- /dev/null +++ b/tools/xmakescripts/plugins/ci/xmake.lua @@ -0,0 +1,13 @@ +task("ci") + set_category("plugins") + on_run("main") + + set_menu { + usage = "xmake ci [options]", + description = "Pass build information to external tools.", + options = + { + {'d', "dump", "kv", nil, "Dump the specified information in JSON format.", + values = {"modes", "targets"} } + } + } \ No newline at end of file diff --git a/xmake.lua b/xmake.lua index 5c3ee1296..fc7bc08a7 100644 --- a/xmake.lua +++ b/xmake.lua @@ -12,6 +12,9 @@ set_config("buildir", "Intermediates") -- /modules/rules/my_module.lua import("rules.my_module") add_moduledirs("tools/xmakescripts/modules") +-- Add the plugins dir to support custom xmake . +add_plugindirs("tools/xmakescripts/plugins") + -- Load our rule files into the global scope. includes("tools/xmakescripts/rules/**.lua") From 8ecc13d155eb990d3c4aa14ddf7a3f979cd05099 Mon Sep 17 00:00:00 2001 From: George Higashiyama Date: Fri, 14 Jun 2024 22:16:18 -0700 Subject: [PATCH 2/6] Initial xmake setup --- .github/actions/ci-tool-setup/action.yml | 46 +++++++++++++++++++++++ .github/actions/xmake-setup/action.yml | 48 ++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 .github/actions/ci-tool-setup/action.yml create mode 100644 .github/actions/xmake-setup/action.yml diff --git a/.github/actions/ci-tool-setup/action.yml b/.github/actions/ci-tool-setup/action.yml new file mode 100644 index 000000000..378340165 --- /dev/null +++ b/.github/actions/ci-tool-setup/action.yml @@ -0,0 +1,46 @@ +name: 'Setup CI Tools' +description: 'Setup various toolsets for use in CI workflows.' +inputs: + xmake: + description: 'Install xmake' + default: true +outputs: + random-number: + description: "Random number" + value: ${{ steps.random-number-generator.outputs.random-number }} +runs: + using: "composite" + steps: + # Force xmake to a specific folder (for cache) + - name: Set xmake env + run: echo "XMAKE_GLOBALDIR=${{ runner.tool_cache }}/xmake-global" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + shell: powershell + + - name: Install VS2022 BuildTools 17.9.7 + run: choco install -y visualstudio2022buildtools --version=117.9.7.0 --params "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --installChannelUri https://aka.ms/vs/17/release/180911598_-255012421/channel" + shell: powershell + + - name: Setup xmake + uses: xmake-io/github-action-setup-xmake@v1 + with: + xmake-version: '2.9.2' + + - name: Update xmake repository + run: xmake repo --update + shell: powershell + + # Fetch xmake dephash + - name: Retrieve dependencies hash + id: dep_hash + run: echo "hash=$(xmake l utils.ci.packageskey)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + shell: powershell + + # Cache xmake dependencies + - name: Restore cached xmake dependencies + id: restore-depcache + uses: actions/cache/restore@v4 + with: + path: ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages + # Example key: MSVC-Game__Shipping__Win64-42d5ac22284a460e96b6cab018d6b7b5-W23 + key: MSVC-${{ inputs.build-mode }}-${{ steps.dep_hash.outputs.hash }}-W${{ steps.cache_key.outputs.key }} + diff --git a/.github/actions/xmake-setup/action.yml b/.github/actions/xmake-setup/action.yml new file mode 100644 index 000000000..ec51a04ce --- /dev/null +++ b/.github/actions/xmake-setup/action.yml @@ -0,0 +1,48 @@ +name: 'Setup xmake' +description: 'Setup xmake for use in CI scripts' +inputs: + version: + description: 'xmake version to install' + required: true + package-cache-key: + description: 'cache key' + +outputs: + random-number: + description: "Random number" + value: ${{ steps.random-number-generator.outputs.random-number }} +runs: + using: "composite" + steps: + # Force xmake to a specific folder (for cache) + - name: Set xmake env + run: echo "XMAKE_GLOBALDIR=${{ runner.tool_cache }}/xmake-global" >> $GITHUB_OUTPUT + shell: bash + + - name: Install VS2022 BuildTools 17.9.7 + run: choco install -y visualstudio2022buildtools --version=117.9.7.0 --params "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --installChannelUri https://aka.ms/vs/17/release/180911598_-255012421/channel" + shell: powershell + + - name: Setup xmake + uses: xmake-io/github-action-setup-xmake@v1 + with: + xmake-version: '2.9.2' + + - name: Update xmake repository + run: xmake repo --update + shell: powershell + + # Fetch xmake dephash + - name: Retrieve dependencies hash + id: dep_hash + run: echo "hash=$(xmake l utils.ci.packageskey)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + shell: powershell + + # Cache xmake dependencies + - name: Restore cached xmake dependencies + id: restore-depcache + uses: actions/cache/restore@v4 + with: + path: ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages + # Example key: MSVC-Game__Shipping__Win64-42d5ac22284a460e96b6cab018d6b7b5-W23 + key: MSVC-${{ inputs.build-mode }}-${{ steps.dep_hash.outputs.hash }}-W${{ steps.cache_key.outputs.key }} From 79659451ffc83442143e8ae5bbd0431f9ace9793 Mon Sep 17 00:00:00 2001 From: George Higashiyama Date: Sat, 15 Jun 2024 13:29:28 -0700 Subject: [PATCH 3/6] Add JSON linter and workflow linter --- .../problem-matchers/actionlint-matcher.json | 17 ++++++++++ .../problem-matchers/jsonlint-matcher.json | 21 ++++++++++++ .github/workflows/json-validation.yml | 34 +++++++++++++++++++ .github/workflows/workflow-validation.yml | 17 ++++++++++ 4 files changed, 89 insertions(+) create mode 100644 .github/problem-matchers/actionlint-matcher.json create mode 100644 .github/problem-matchers/jsonlint-matcher.json create mode 100644 .github/workflows/json-validation.yml create mode 100644 .github/workflows/workflow-validation.yml diff --git a/.github/problem-matchers/actionlint-matcher.json b/.github/problem-matchers/actionlint-matcher.json new file mode 100644 index 000000000..00c320db5 --- /dev/null +++ b/.github/problem-matchers/actionlint-matcher.json @@ -0,0 +1,17 @@ +{ + "problemMatcher": [ + { + "owner": "actionlint", + "pattern": [ + { + "regexp": "^(?:\\x1b\\[\\d+m)?(.+?)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*: (?:\\x1b\\[\\d+m)*(.+?)(?:\\x1b\\[\\d+m)* \\[(.+?)\\]$", + "file": 1, + "line": 2, + "column": 3, + "message": 4, + "code": 5 + } + ] + } + ] +} \ No newline at end of file diff --git a/.github/problem-matchers/jsonlint-matcher.json b/.github/problem-matchers/jsonlint-matcher.json new file mode 100644 index 000000000..e53490e6c --- /dev/null +++ b/.github/problem-matchers/jsonlint-matcher.json @@ -0,0 +1,21 @@ +{ + "problemMatcher": [ + { + "owner": "jsonlint", + "pattern": [ + { + "regexp": "^(.*[\\/\\\\])?([.\\w\\-_]*)$", + "fromPath": 1, + "file": 2 + }, + { + "regexp": "^jq:\\sparse\\serror:\\s(.*)\\sat\\sline\\s(\\d*),\\scolumn\\s(\\d*)$", + "message": 1, + "line": 2, + "column": 3, + "loop": true + } + ] + } + ] + } \ No newline at end of file diff --git a/.github/workflows/json-validation.yml b/.github/workflows/json-validation.yml new file mode 100644 index 000000000..e71e5048b --- /dev/null +++ b/.github/workflows/json-validation.yml @@ -0,0 +1,34 @@ +name: Validate JSON Files +on: + pull_request: + branches: ['main'] + paths: + - "**.json" + push: +jobs: + jsonlint: + runs-on: ubuntu-latest + steps: + - name: Checkout the Repository + uses: actions/checkout@v4 + with: + submodules: recursive + token: ${{ secrets.UEPSEUDO_PAT }} + - name: Get all changed JSON files + id: changed-json-files + uses: tj-actions/changed-files@v44 + with: + files: | + **.json + - name: Lint all changed JSON files + if: steps.changed-json-files.outputs.any_changed == 'true' + shell: bash + env: + ALL_CHANGED_FILES: ${{ steps.changed-json-files.outputs.all_changed_files }} + run: | + echo "::add-matcher::.github/problem-matchers/jsonlint-matcher.json" + for file in ${ALL_CHANGED_FILES}; do + echo "$file" + jq . "$file" 1> /dev/null + done + diff --git a/.github/workflows/workflow-validation.yml b/.github/workflows/workflow-validation.yml new file mode 100644 index 000000000..39712d082 --- /dev/null +++ b/.github/workflows/workflow-validation.yml @@ -0,0 +1,17 @@ +name: Validate GitHub Workflow Files +on: + pull_request: + branches: ['main'] + paths: + - ".github/**" +jobs: + actionlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Check workflow files + run: | + echo "::add-matcher::.github/problem-matchers/actionlint-matcher.json" + bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) + ./actionlint -color + shell: bash \ No newline at end of file From 15e1e84b42fa275154dcf267cb7ef39c3f7f9779 Mon Sep 17 00:00:00 2001 From: George Higashiyama Date: Sat, 15 Jun 2024 13:33:31 -0700 Subject: [PATCH 4/6] Broken json --- assets/Mods/mods.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/Mods/mods.json b/assets/Mods/mods.json index d79717fa9..138548373 100644 --- a/assets/Mods/mods.json +++ b/assets/Mods/mods.json @@ -18,7 +18,7 @@ { "mod_name": "SplitScreenMod", "mod_enabled": false - }, + } { "mod_name": "LineTraceMod", "mod_enabled": true From 85e2ab0beee744cb24f22d4eeea643437da71e48 Mon Sep 17 00:00:00 2001 From: George Higashiyama Date: Sat, 15 Jun 2024 13:34:03 -0700 Subject: [PATCH 5/6] Branch test --- .github/workflows/json-validation.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/json-validation.yml b/.github/workflows/json-validation.yml index e71e5048b..99d8da39b 100644 --- a/.github/workflows/json-validation.yml +++ b/.github/workflows/json-validation.yml @@ -1,7 +1,6 @@ name: Validate JSON Files on: pull_request: - branches: ['main'] paths: - "**.json" push: From 2e157dfe2b5fd632a9f699458723ecf6dca20b15 Mon Sep 17 00:00:00 2001 From: George Higashiyama Date: Sat, 15 Jun 2024 17:32:45 -0700 Subject: [PATCH 6/6] add bad changes --- .github/workflows/pushdocs.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pushdocs.yml b/.github/workflows/pushdocs.yml index 93a2f66a1..07783c500 100644 --- a/.github/workflows/pushdocs.yml +++ b/.github/workflows/pushdocs.yml @@ -16,7 +16,7 @@ jobs: fetch-depth: 0 - name: Setup Python - uses: actions/setup-python@v4 + us actions/setup-python@v4 with: python-version: '3.x' @@ -32,8 +32,7 @@ jobs: python docs-repo/build.py - uses: actions/upload-pages-artifact@v1 - with: - path: docs-repo/docs + wit deploy: needs: build @@ -43,7 +42,7 @@ jobs: environment: name: github-pages - url: ${{ steps.deployment.outputs.page_url }} + url: ${{ stepss.deployment.outputs.page_url }} runs-on: ubuntu-latest steps: