Skip to content

Ports TG's icon merge conflict tool #23922

Ports TG's icon merge conflict tool

Ports TG's icon merge conflict tool #23922

Workflow file for this run

name: CI
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the Bleeding-Edge branch
push:
branches: [ Bleeding-Edge ]
paths-ignore:
- 'html/changelogs/**'
pull_request:
branches: [ Bleeding-Edge ]
paths:
- '**.dm'
- '**.dmm'
- '**.dmi'
- 'vgstation13.dme'
- '.github/workflows/**'
pull_request_target:
branches: [ Bleeding-Edge ]
paths:
- '**.dmi'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
BYOND_MAJOR: 516
BYOND_MINOR: 1659
#This can be declared here because build.py will ignore it if DM_UNIT_TESTS is true.
ALL_MAPS: tgstation metaclub defficiency packedstation roidstation test_tiny test_vault snaxi tgstation-sec tgstation-snow LampreyStation xoq synergy bagelstation lowfatbagel Dorfstation waystation line horizon wheelstation
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
lint:
name: Run linters
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Don't run this job if the commit message contains that string.
if: "!contains(github.event.head_commit.message, '[ci skip]')"
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# - uses: actions/setup-python@v4
# with:
# python-version: '3.x'
- name: Setup Python
run: |
tools/bootstrap/python -c ''
#TODO: Cache Dreamchecker install
- name: Run dreamchecker
run: |
SPACEMAN_DMM_GIT_TAG="suite-1.11" tools/travis/install_spaceman_dmm.sh dreamchecker
~/dreamchecker 2>&1 | bash tools/ci/annotate_dm.sh
- name: Run map checker
run: python tools/travis/check_map_files.py maps/
#TODO: Cache pip directory
- name: Validhunt DMIs
run: |
pip install Pillow
python tools/dmi-validhunt/dmi-validhunt.py icons/ || true
- name: Make sure test maps or vaults aren't ticked
run: find -name '*.dme' -exec cat {} \; | awk '/maps\\test.*|\.dmm/ { exit 1 }'
# OpenDream linting
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4.2.0
with:
dotnet-version: 9.x
- name: Install OpenDream
uses: robinraju/release-downloader@v1.9
with:
repository: "OpenDreamProject/OpenDream"
tag: "latest"
fileName: "DMCompiler_linux-x64.tar.gz"
extract: true
- name: Run OpenDream
run: ./DMCompiler_linux-x64/DMCompiler vgstation13.dme --suppress-unimplemented --define=CIBUILDING --version=516.1655 | bash tools/ci/annotate_od.sh
check-dmi-conflicts:
name: Check DMI conflicts
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Setup Python
run: tools/bootstrap/python -c ''
- name: Detect conflicting DMIs
id: merge
run: |
git fetch origin ${{ github.base_ref }}
MERGE_BASE=$(git merge-base HEAD origin/${{ github.base_ref }})
# changed in PR branch
PR_DMIS=$(git diff --name-only "$MERGE_BASE" HEAD -- '*.dmi' | sort)
# changed in Bleeding-Edge
BASE_DMIS=$(git diff --name-only "$MERGE_BASE" origin/${{ github.base_ref }} -- '*.dmi' | sort)
# find union of above
CONFLICTING_DMIS=$(comm -12 <(echo "$PR_DMIS") <(echo "$BASE_DMIS"))
if [ -n "$CONFLICTING_DMIS" ]; then
echo "The following DMIs are in conflict:"
echo "$CONFLICTING_DMIS"
echo "has_dmi_conflicts=true" >> $GITHUB_OUTPUT
echo "conflicting_files<<EOF" >> $GITHUB_OUTPUT
echo "$CONFLICTING_DMIS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
else
echo "No DMI conflicts detected"
echo "has_dmi_conflicts=false" >> $GITHUB_OUTPUT
fi
- name: Test DMI conflict resolution
if: steps.merge.outputs.has_dmi_conflicts == 'true'
id: resolve
env:
PYTHONPATH: ${{ github.workspace }}/tools
run: |
cd ${{ github.workspace }}
if tools/bootstrap/python -m dmi.merge_driver --posthoc 2>&1 | tee /tmp/dmi_output.txt; then
echo "resolvable=true" >> $GITHUB_OUTPUT
else
echo "resolvable=false" >> $GITHUB_OUTPUT
fi
echo "output<<EOF" >> $GITHUB_OUTPUT
cat /tmp/dmi_output.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Comment on PR (resolvable)
if: steps.merge.outputs.has_dmi_conflicts == 'true' && steps.resolve.outputs.resolvable == 'true'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `## DMI Conflict Check: Auto-resolvable
This PR has DMI conflicts that can be automatically resolved.
To resolve locally, run:
\`\`\`
git fetch origin ${{ github.base_ref }}
git merge origin/${{ github.base_ref }}
tools\\dmi\\\"Resolve Icon Conflicts.bat\"
# Then commit the DMIs, e.g.:
git add -A
git commit -m "Resolve DMI conflicts"
\`\`\`
<details>
<summary>Merge driver output</summary>
\`\`\`
${{ steps.resolve.outputs.output }}
\`\`\`
</details>`
})
- name: Comment on PR (unresolvable)
if: steps.merge.outputs.has_dmi_conflicts == 'true' && steps.resolve.outputs.resolvable == 'false'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `## DMI Conflict Check: Manual Resolution Required
This PR has DMI conflicts that **can not** be automatically resolved.
You will need to manually resolve these conflicts by:
1. Backing up your local modified DMI
2. Downloading the latest DMI from Bleeding-Edge
3. Redoing your changes to the latest DMI
<details>
<summary>Conflict details</summary>
\`\`\`
${{ steps.resolve.outputs.output }}
\`\`\`
</details>`
})
- name: Fail on DMI conflicts
if: steps.merge.outputs.has_dmi_conflicts == 'true'
run: |
if [ "${{ steps.resolve.outputs.resolvable }}" == "true" ]; then
echo "::error::DMI conflicts detected. Run the resolution commands above, then push."
else
echo "::error::DMI conflicts can not be automatically resolved, you have to resolve them manually the hard way"
fi
echo "Conflict details:"
cat /tmp/dmi_output.txt
exit 1
build:
name: ${{matrix.job-name}}
runs-on: ubuntu-latest
# Don't run this job if the commit message contains that string.
if: "!contains(github.event.head_commit.message, '[ci skip]')"
strategy:
matrix:
include:
- dm-unit-tests: 0
job-name: Compile all maps
- dm-unit-tests: 1
job-name: Compile and run tests
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
name: Cache BYOND installation
with:
path: ~/BYOND-${{env.BYOND_MAJOR}}.${{env.BYOND_MINOR}}
key: BYOND-${{runner.os}}-${{env.BYOND_MAJOR}}.${{env.BYOND_MINOR}}
- name: ${{matrix.job-name}}
env:
DM_UNIT_TESTS: ${{matrix.dm-unit-tests}}
run: |
tools/travis/install-byond.sh
source $HOME/BYOND-${BYOND_MAJOR}.${BYOND_MINOR}/byond/bin/byondsetup
tools/travis/build.py 2>&1 | tee /dev/stderr | awk '/warning:|error:/ { exit 1 }'
cp tools/travis/config/config.txt config/
tools/travis/run_tests.py 2>&1 | tee /dev/stderr | awk '/UNIT TEST FAIL/ { exit 1 }'