From c2efe31640025d9549745fc80c60d08a3a5823cb Mon Sep 17 00:00:00 2001 From: Selis <12716288+ItsSelis@users.noreply.github.com> Date: Fri, 3 Jan 2025 15:12:34 +0100 Subject: [PATCH] Nanomaps CI update (#16827) * Some CI updates * Update CODEOWNERS file --- .github/CODEOWNERS | 8 +-- .github/workflows/remove_guide_comments.yml | 18 +++++ .github/workflows/render_nanomaps.yml | 15 ++++- tools/github-actions/README.MD | 7 +- .../nanomap-renderer-invoker.sh | 65 ++++++++++--------- 5 files changed, 73 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/remove_guide_comments.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 1b5698ba5ef..3fcaf2691e8 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -4,9 +4,7 @@ # In the event that multiple org members are to be informed of changes # to the same file or dir, add them to the end under Multiple Owners -# ItsSelis +# Username -/code/__DEFINES/tgui.dm @ItsSelis -/code/controllers/subsystem/tgui.dm @ItsSelis -/code/modules/tgui @ItsSelis -/tgui @ItsSelis +# /path/to/file.dm @Username +# /path/to/directory @Username diff --git a/.github/workflows/remove_guide_comments.yml b/.github/workflows/remove_guide_comments.yml new file mode 100644 index 00000000000..621d860c5cd --- /dev/null +++ b/.github/workflows/remove_guide_comments.yml @@ -0,0 +1,18 @@ +# Removes guide comments from PRs when opened, so that when we merge them +# and reuse the pull request description, the clutter is not left behind +name: Remove guide comments +on: + pull_request_target: + types: [opened] +jobs: + remove_guide_comments: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Remove guide comments + uses: actions/github-script@v7 + with: + script: | + const { removeGuideComments } = await import('${{ github.workspace }}/tools/pull_request_hooks/removeGuideComments.js') + await removeGuideComments({ github, context }) diff --git a/.github/workflows/render_nanomaps.yml b/.github/workflows/render_nanomaps.yml index ec05c188cbb..692e9b827b7 100644 --- a/.github/workflows/render_nanomaps.yml +++ b/.github/workflows/render_nanomaps.yml @@ -10,6 +10,7 @@ on: - master paths: - 'maps/**' + workflow_dispatch: permissions: {} jobs: @@ -19,7 +20,7 @@ jobs: pull-requests: write # to create pull requests (repo-sync/pull-request) name: 'Generate NanoMaps' - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Clone uses: actions/checkout@v4 @@ -30,7 +31,17 @@ jobs: git branch -f nanomaps_generation git checkout nanomaps_generation git reset --hard origin/master - + - name: Restore SpacemanDMM cache + uses: actions/cache@v4 + with: + path: ~/SpacemanDMM + key: ${{ runner.os }}-spacemandmm-${{ hashFiles('dependencies.sh') }} + restore-keys: | + ${{ runner.os }}-spacemandmm- + - name: Install Tools + run: | + bash tools/ci/install_spaceman_dmm.sh dmm-tools + sudo apt install -y imagemagick - name: Ensure +x on github-actions directory run: chmod -R +x ./tools/github-actions diff --git a/tools/github-actions/README.MD b/tools/github-actions/README.MD index b6a3542a884..1f208e13c6f 100755 --- a/tools/github-actions/README.MD +++ b/tools/github-actions/README.MD @@ -1,7 +1,6 @@ # GitHub Actions Scripts -This folder contains all the script and tools required for GitHub actions. If you add something to this directory, **PLEASE** document it in here +This folder contains all the script and tools required for GitHub actions. If you add something to this directory, **PLEASE** document it in here (also this is actually only used for nanomap generation) -- `nanomap-renderer` - A linux application to render NanoMap images of the ingame maps automatically. Based off of SpacemanDMM (Modified source [here](https://github.com/AffectedArc07/ParaSpacemanDMM), original source [here](https://github.com/Spacemaniac/SpacemanDMM)) -- `nanomap-renderer-invoker.sh` - A script which invokes the render tool and clones the maps to the correct directory -- `doc-generator` - A linux application to generate documentation of game code automatically. Based off of SpacemanDMM (Modified source [here](https://github.com/AffectedArc07/ParaSpacemanDMM), original source [here](https://github.com/Spacemaniac/SpacemanDMM)) +- `nanomap-renderer` - No longer used due to being out of date. A linux application to render NanoMap images of the ingame maps automatically. Based off of SpacemanDMM (Modified source [here](https://github.com/AffectedArc07/ParaSpacemanDMM), original source [here](https://github.com/Spacemaniac/SpacemanDMM)) +- `nanomap-renderer-invoker.sh` - A script which invokes dmm-tools from [SpacemanDMM](https://github.com/Spacemaniac/SpacemanDMM) to dynamically render maps in specified directories and [ImageMagick](https://imagemagick.org/index.php) to resize and compress them before moving them to the correct directory. To change which map directories are rendered, edit the mapdir variable as directed in the file. diff --git a/tools/github-actions/nanomap-renderer-invoker.sh b/tools/github-actions/nanomap-renderer-invoker.sh index 4aea8cbf558..92686311d80 100755 --- a/tools/github-actions/nanomap-renderer-invoker.sh +++ b/tools/github-actions/nanomap-renderer-invoker.sh @@ -1,35 +1,42 @@ #!/bin/bash -# Generate maps -map_files=( - "./maps/tether/tether-01-surface1.dmm" - "./maps/tether/tether-02-surface2.dmm" - "./maps/tether/tether-03-surface3.dmm" - "./maps/tether/tether-04-transit.dmm" - "./maps/tether/tether-05-station1.dmm" - "./maps/tether/tether-06-station2.dmm" - "./maps/tether/tether-07-station3.dmm" - "./maps/tether/tether-08-mining.dmm" - "./maps/tether/tether-09-solars.dmm" - "./maps/offmap_vr/talon/talon1.dmm" - "./maps/offmap_vr/talon/talon2.dmm" +BASEDIR=$PWD +#Put directories to get maps from here. One per line. +mapdirs=( + "maps/groundbase" + "maps/stellar_delight" + "maps/tether" + "maps/offmap_vr/talon" ) +#DO NOT TOUCH THIS VARIABLE. It will automatically fill with any maps in mapdirs that are form MAPNAME-n.dmm where n is the z level. +map_files=() -tools/github-actions/nanomap-renderer minimap -w 2240 -h 2240 "${map_files[@]}" +#Fill up mapfiles list +for mapdir in ${mapdirs[@]}; do + echo "Scanning $mapdir..." + FULLMAPDIR=$BASEDIR/$mapdir + map_files+=($FULLMAPDIR/*-*[0-9].dmm) +done -# Move and rename files so the game understands them -cd "data/nanomaps" +#Print full map list +echo "Full map list:" +for map in ${map_files[@]}; do + echo $map +done -mv "talon1_nanomap_z1.png" "tether_nanomap_z13.png" -mv "talon2_nanomap_z1.png" "tether_nanomap_z14.png" -mv "tether-01-surface1_nanomap_z1.png" "tether_nanomap_z1.png" -mv "tether-02-surface2_nanomap_z1.png" "tether_nanomap_z2.png" -mv "tether-03-surface3_nanomap_z1.png" "tether_nanomap_z3.png" -mv "tether-04-transit_nanomap_z1.png" "tether_nanomap_z4.png" -mv "tether-05-station1_nanomap_z1.png" "tether_nanomap_z5.png" -mv "tether-06-station2_nanomap_z1.png" "tether_nanomap_z6.png" -mv "tether-07-station3_nanomap_z1.png" "tether_nanomap_z7.png" -mv "tether-08-mining_nanomap_z1.png" "tether_nanomap_z8.png" -mv "tether-09-solars_nanomap_z1.png" "tether_nanomap_z9.png" +printf "\n\n\n" +echo "Rendering maps..." -cd "../../" -cp data/nanomaps/* "icons/_nanomaps/" \ No newline at end of file +#Render maps to initial images +~/dmm-tools minimap "${map_files[@]}" + +cd data/minimaps + +printf "\n\n\n" +echo "Starting image resizing..." + +#Resize images to proper size and move them to the correct place +for map in ./*.png; do + j=$(echo $map | sed -n "s/^\.\/\(.*\)-\([0-9]*\)\-1.png$/\1_nanomap_z\2.png/p") + echo "Resizing $map and moving to icons/_nanomaps/$j" + convert $map -resize 2240x2240 "$BASEDIR/icons/_nanomaps/$j" +done