diff --git a/.gitattributes b/.gitattributes index 07a337b2f3c..3bb0f8b6071 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,6 @@ -## Merger hooks, run tools/hooks/install.bat or install.sh to set up +## Merge hooks, run tools/hooks/install.bat or install.sh to set up *.dmm text eol=lf merge=dmm *.dmi binary merge=dmi +## TGUI bundle merge drivers +*.bundle.* binary merge=tgui-merge-bundle +*.chunk.* binary merge=tgui-merge-bundle diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a99eeb854cb..3adae3a9ab8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,24 +14,34 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 + - name: Setup Cache uses: actions/cache@v4 with: path: $HOME/SpacemanDMM key: ${{ runner.os }}-spacemandmm + - name: Install Tools run: | bash tools/ci/install_build_deps.sh bash tools/ci/install_dreamchecker.sh + - uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: '3.11' cache: 'pip' + + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'yarn' + cache-dependency-path: ./tgui/yarn.lock + - run: pip install -r tools/requirements.txt - name: Run Linters run: | tools/ci/check_json.sh - tools/ci/build_tgui.sh + tgui/bin/tgui --ci python tools/ci/check_grep2.py python tools/ci/check_line_endings.py python tools/ci/check_file_names.py @@ -41,6 +51,7 @@ jobs: python -m tools.ci.check_icon_conflicts python -m tools.ci.check_icon_dupenames python -m tools.maplint.source --github + - name: Run DreamChecker shell: bash run: ~/dreamchecker 2>&1 | bash tools/ci/annotate_dm.sh diff --git a/.github/workflows/merge_upstream_master.yml b/.github/workflows/merge_upstream_master.yml index 4d010e90281..fab0950222f 100644 --- a/.github/workflows/merge_upstream_master.yml +++ b/.github/workflows/merge_upstream_master.yml @@ -20,9 +20,16 @@ jobs: ref: ${{ env.PR_BRANCH }} fetch-depth: 0 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'yarn' + cache-dependency-path: ./tgui/yarn.lock + - uses: actions/setup-python@v5 with: python-version: '3.11' + cache: 'pip' - name: Perform Merge run: | diff --git a/tgui/.gitattributes b/tgui/.gitattributes index 6f5199e9809..80aed506737 100644 --- a/tgui/.gitattributes +++ b/tgui/.gitattributes @@ -17,7 +17,5 @@ yarn.lock text eol=lf bin/tgui text eol=lf ## Treat bundles as binary and ignore them during conflicts -*.bundle.* binary merge=tgui-merge-bundle -*.chunk.* binary merge=tgui-merge-bundle .yarn/releases/**/* binary .yarn/plugins/**/* binary diff --git a/tgui/bin/tgui b/tgui/bin/tgui index 30e59c05213..2c29346289f 100755 --- a/tgui/bin/tgui +++ b/tgui/bin/tgui @@ -125,18 +125,24 @@ task-install-git-hooks() { git_root="$(git rev-parse --show-toplevel)" git_base_dir="${base_dir/${git_root}/.}" git config --replace-all merge.tgui-merge-bundle.driver \ - "${git_base_dir}/bin/tgui --merge=bundle %O %A %B %L" + "${git_base_dir}/tgui/bin/tgui --merge=bundle %P %O %A %B %L" echo "tgui: Merge drivers have been successfully installed!" } ## Bundle merge driver task-merge-bundle() { - local file_ancestor="${1}" - local file_current="${2}" - local file_other="${3}" - local conflict_marker_size="${4}" - echo "tgui: Discarding a local tgui build" - ## Do nothing (file_current will be merged and is what we want to keep). + local file_path="${1}" + local file_ancestor="${2}" + local file_current="${3}" + local file_other="${4}" + local conflict_marker_size="${5}" + echo "----------------------" + echo "tgui: rebuilding a conflicted tgui bundle, ${file_path}" + task-install + task-webpack --mode=production + echo "tgui: replacing conflicted bundle with newly compiled bundle" + cd ../ + cat $file_path > $file_current exit 0 } diff --git a/tgui/bin/tgui_.ps1 b/tgui/bin/tgui_.ps1 index c310007a70a..b0047894aab 100644 --- a/tgui/bin/tgui_.ps1 +++ b/tgui/bin/tgui_.ps1 @@ -104,6 +104,13 @@ function task-validate-build { Write-Output "tgui: build is ok" } +## Installs merge drivers and git hooks +function task-install-git-hooks () { + Set-Location $global:basedir + git config --replace-all merge.tgui-merge-bundle.driver "tgui/bin/tgui --merge=bundle %P %O %A %B %L" + Write-Output "tgui: Merge drivers have been successfully installed!" +} + ## Main ## -------------------------------------------------------- @@ -113,6 +120,11 @@ if ($Args.Length -gt 0) { exit 0 } + if ($Args[0] -eq "--install-git-hooks") { + task-install-git-hooks + exit 0 + } + if ($Args[0] -eq "--dev") { $Rest = $Args | Select-Object -Skip 1 task-install diff --git a/tools/ci/build_tgui.sh b/tools/ci/build_tgui.sh deleted file mode 100755 index ea75c01b4c4..00000000000 --- a/tools/ci/build_tgui.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -set -euo pipefail - -source _build_dependencies.sh - -source ~/.nvm/nvm.sh -nvm use $NODE_VERSION -cd tgui -bin/tgui --ci -cd .. diff --git a/tools/ci/install_build_deps.sh b/tools/ci/install_build_deps.sh index 9118316d28c..0e1f1135258 100755 --- a/tools/ci/install_build_deps.sh +++ b/tools/ci/install_build_deps.sh @@ -1,11 +1,4 @@ #!/bin/bash set -euo pipefail -source _build_dependencies.sh - -source ~/.nvm/nvm.sh -nvm install $NODE_VERSION -nvm use $NODE_VERSION -npm install --global yarn python3 -m pip install json5 - diff --git a/tools/hooks/Install.bat b/tools/hooks/Install.bat index 1bfc1b50d5c..1c8324e3f1d 100644 --- a/tools/hooks/Install.bat +++ b/tools/hooks/Install.bat @@ -1,2 +1,18 @@ @call "%~dp0\..\bootstrap\python" -m hooks.install %* -@pause +@echo off +set /p choice=Do you want to install TGUI hooks (requires Node.js)? (Y/N): + +if /i "%choice%"=="Y" ( + @echo off + rem Copyright (c) 2020 Aleksej Komarov + rem SPDX-License-Identifier: MIT + call powershell.exe -NoLogo -ExecutionPolicy Bypass -File "%~dp0\..\..\tgui\bin\tgui_.ps1" --install-git-hooks %* + rem Pause if launched in a separate shell unless initiated from powershell + echo %PSModulePath% | findstr %USERPROFILE% >NUL + if %errorlevel% equ 0 ( + pause + exit 0 + ) + echo %cmdcmdline% | find /i "/c" +) +pause diff --git a/tools/hooks/Uninstall.bat b/tools/hooks/Uninstall.bat index 862cbaf8bc4..66c02d3672d 100644 --- a/tools/hooks/Uninstall.bat +++ b/tools/hooks/Uninstall.bat @@ -1,2 +1,3 @@ @call "%~dp0\..\bootstrap\python" -m hooks.install --uninstall %* +git config --unset merge.tgui-merge-bundle.driver @pause