CI: check for removed goal_src code that we want or need to perserve (#2987)

This commit is contained in:
Tyler Wilding 2023-09-13 23:31:08 -06:00 committed by GitHub
parent ed6782d11b
commit 3252136c1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 80 additions and 33 deletions

View file

@ -25,11 +25,12 @@ jobs:
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Install Package Dependencies - name: Install Package Dependencies
run: > run: |
sudo apt install build-essential cmake sudo apt update
clang gcc g++ lcov make nasm libxrandr-dev sudo apt install build-essential cmake \
libxinerama-dev libxcursor-dev libpulse-dev clang gcc g++ lcov make nasm libxrandr-dev \
libxi-dev zip ninja-build libxinerama-dev libxcursor-dev libpulse-dev \
libxi-dev zip ninja-build libgl1-mesa-dev
- name: Setup Buildcache - name: Setup Buildcache
uses: mikehardy/buildcache-action@v2.1.0 uses: mikehardy/buildcache-action@v2.1.0

View file

@ -40,6 +40,16 @@ jobs:
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Install Python Dependencies
run: pip install unidiff colorama
- name: Check for Removed goal_src/ Code
# FYI - if you run this `git diff` on windows, it creates a utf-16 LE file
run: |
git fetch origin
git diff origin/master > lint-changes.diff
python ./scripts/ci/lint-gsrc-removals.py
- name: Check for Unresolved Conflicts - name: Check for Unresolved Conflicts
run: python ./scripts/gsrc/check-for-conflicts.py run: python ./scripts/gsrc/check-for-conflicts.py

View file

@ -32,11 +32,12 @@ jobs:
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Install Package Dependencies - name: Install Package Dependencies
run: > run: |
sudo apt install build-essential cmake sudo apt update
clang gcc g++ lcov make nasm libxrandr-dev sudo apt install build-essential cmake \
libxinerama-dev libxcursor-dev libpulse-dev clang gcc g++ lcov make nasm libxrandr-dev \
libxi-dev zip ninja-build libgl1-mesa-dev libxinerama-dev libxcursor-dev libpulse-dev \
libxi-dev zip ninja-build libgl1-mesa-dev
- name: Setup Buildcache - name: Setup Buildcache
uses: mikehardy/buildcache-action@v2.1.0 uses: mikehardy/buildcache-action@v2.1.0

View file

@ -28,11 +28,12 @@ jobs:
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Install Package Dependencies - name: Install Package Dependencies
run: > run: |
sudo apt install build-essential cmake sudo apt update
clang gcc g++ lcov make nasm libxrandr-dev sudo apt install build-essential cmake \
libxinerama-dev libxcursor-dev libpulse-dev clang gcc g++ lcov make nasm libxrandr-dev \
libxi-dev zip ninja-build libgl1-mesa-dev libxinerama-dev libxcursor-dev libpulse-dev \
libxi-dev zip ninja-build libgl1-mesa-dev
- name: Setup Buildcache - name: Setup Buildcache
uses: mikehardy/buildcache-action@v2.1.0 uses: mikehardy/buildcache-action@v2.1.0

1
.gitignore vendored
View file

@ -75,3 +75,4 @@ __pycache__/
/jak2-*.json /jak2-*.json
/TODO.md /TODO.md
unifont-15.0.03.ttf unifont-15.0.03.ttf
*.diff

View file

@ -17,12 +17,6 @@
"body": [";; og:ignore-form:${1:substr}"], "body": [";; og:ignore-form:${1:substr}"],
"description": "If the provided substr is found in the starting line of a form, the entire form will be omitted when copying decompiled code into the file" "description": "If the provided substr is found in the starting line of a form, the entire form will be omitted when copying decompiled code into the file"
}, },
"og:update-with-merge": {
"scope": "opengoal",
"prefix": ["og:update-with-merge"],
"body": [";; og:update-with-merge"],
"description": "The file will be updated with a git merge-file instead of naive copy-paste"
},
"og:preserve-this": { "og:preserve-this": {
"scope": "opengoal", "scope": "opengoal",
"prefix": ["og:preserve-this"], "prefix": ["og:preserve-this"],

View file

@ -25,8 +25,6 @@ a single mesh, so it's limited to tests like single foreground mesh vs. sphere.
Another limitation is that triangles don't have per-tri pat info. Another limitation is that triangles don't have per-tri pat info.
|# |#
;; og:update-with-merge
;; DECOMP BEGINS ;; DECOMP BEGINS

View file

@ -5,8 +5,6 @@
;; name in dgo: castle-obs ;; name in dgo: castle-obs
;; dgos: CAS ;; dgos: CAS
;; og:update-with-merge:substr
;; DECOMP BEGINS ;; DECOMP BEGINS
(define *cas-conveyor-room-id* 0) (define *cas-conveyor-room-id* 0)

View file

@ -13,8 +13,6 @@
) )
) )
;; og:update-with-merge
;; DECOMP BEGINS ;; DECOMP BEGINS
(defmethod draw hud-helldog ((obj hud-helldog)) (defmethod draw hud-helldog ((obj hud-helldog))

View file

@ -5,8 +5,6 @@
;; name in dgo: ctypal-obs ;; name in dgo: ctypal-obs
;; dgos: CPA ;; dgos: CPA
;; og:update-with-merge:substr
;; DECOMP BEGINS ;; DECOMP BEGINS
(deftype water-anim-ctypal (water-anim) (deftype water-anim-ctypal (water-anim)

View file

@ -5,8 +5,6 @@
;; name in dgo: airlock ;; name in dgo: airlock
;; dgos: GAME, COMMON ;; dgos: GAME, COMMON
;; og:update-with-merge
;; DECOMP BEGINS ;; DECOMP BEGINS
(deftype com-airlock (process-drawable) (deftype com-airlock (process-drawable)

View file

@ -5,8 +5,6 @@
;; name in dgo: pal-obs ;; name in dgo: pal-obs
;; dgos: PAE, PAC ;; dgos: PAE, PAC
;; og:update-with-merge:substr
;; DECOMP BEGINS ;; DECOMP BEGINS
(deftype pal-falling-plat (process-drawable) (deftype pal-falling-plat (process-drawable)

View file

@ -0,0 +1,51 @@
# Gets the diff between this PR and `origin/master`
# If there are any 'og:preserve-this' lines removed, the script returns 1
import unidiff
from colorama import Fore
with open("lint-changes.diff", encoding="utf-8") as f:
diff = f.read()
patch_set = unidiff.PatchSet.from_string(diff)
flagged_deletions = []
for patched_file in patch_set:
file_path = patched_file.path
for hunk in patched_file:
for line in hunk:
if line.is_removed and "og:preserve-this" in line.value.strip():
flagged_deletions.append(
{
"file": file_path,
"line_num": line.source_line_no,
"deletion": line.value.strip(),
}
)
print(flagged_deletions)
if len(flagged_deletions) > 0:
print(
Fore.RED
+ "Flagged goal_src code has been deleted, either you made a mistake or you better know what you're doing!" + Fore.RESET
)
for flagged_deletion in flagged_deletions:
print(
" - {}{}{}:{}{}{} - {}{}{}".format(
Fore.CYAN,
flagged_deletion["file"],
Fore.RESET,
Fore.GREEN,
flagged_deletion["line_num"],
Fore.RESET,
Fore.RED,
flagged_deletion["deletion"],
Fore.RESET,
)
)
print(Fore.RESET)
exit(1)
print("No flagged goal_src code was deleted (hopefully!)")
exit(0)