Skip to content

Commit

Permalink
Fix TGUI deconflict hooks, makes them work on windows (#24686)
Browse files Browse the repository at this point in the history
* Lets us install tgui merge drivers on windows

* test this

* gamer mode

* debug

* do it like this

* test

* test this

* stop it being weirdly relative

* more relative fixes

* try cat

* indentation

* update CI stuff to cache

* correct this

* yarn

* yarn consistency

* do we even need to do this? (no we don't)

* properly cache yarn deps in ci

* Why do we even have that step

---------

Co-authored-by: github-actions <[email protected]>
  • Loading branch information
S34NW and github-actions authored Mar 20, 2024
1 parent 85792c0 commit be9a8c8
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 30 deletions.
5 changes: 4 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -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
15 changes: 13 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/merge_upstream_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 0 additions & 2 deletions tgui/.gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 13 additions & 7 deletions tgui/bin/tgui
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
12 changes: 12 additions & 0 deletions tgui/bin/tgui_.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
## --------------------------------------------------------

Expand All @@ -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
Expand Down
10 changes: 0 additions & 10 deletions tools/ci/build_tgui.sh

This file was deleted.

7 changes: 0 additions & 7 deletions tools/ci/install_build_deps.sh
Original file line number Diff line number Diff line change
@@ -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

18 changes: 17 additions & 1 deletion tools/hooks/Install.bat
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions tools/hooks/Uninstall.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
@call "%~dp0\..\bootstrap\python" -m hooks.install --uninstall %*
git config --unset merge.tgui-merge-bundle.driver
@pause

0 comments on commit be9a8c8

Please sign in to comment.