shithub: rgbds

Download patch

ref: 6d2db2ef642310d7dc39679489adb79ebca5c18f
parent: 9868a01163b03117ce426d41983606e4751cc0bf
author: Rangi <35663410+Rangi42@users.noreply.github.com>
date: Thu Jun 24 13:49:08 EDT 2021

`make checkdiff` does CI documentation checks (#900)

Fixes #744

--- /dev/null
+++ b/.github/workflows/checkdiff.yml
@@ -1,0 +1,17 @@
+name: "Code coverage checking"
+on: pull_request
+
+jobs:
+  checkdiff:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Set up repo
+        run: |
+          git clone -b "${{ github.event.pull_request.head.ref }}" "${{ github.event.pull_request.head.repo.clone_url }}" rgbds
+          cd rgbds
+          git remote add upstream "${{ github.event.pull_request.base.repo.clone_url }}"
+          git fetch upstream
+      - name: Checkdiff
+        working-directory: rgbds
+        run: |
+          make checkdiff "BASE_REF=${{ github.event.pull_request.base.sha }}" Q= | tee log
--- a/Makefile
+++ b/Makefile
@@ -49,6 +49,9 @@
 BISON		:= bison
 RM		:= rm -rf
 
+# Used for checking pull requests
+BASE_REF	:= origin/master
+
 # Rules to build the RGBDS binaries
 
 all: rgbasm rgblink rgbfix rgbgfx
@@ -189,9 +192,8 @@
 # the first common commit between the HEAD and origin/master.
 # `.y` files aren't checked, unfortunately...
 
-BASE_REF:= origin/master
 checkpatch:
-	$Qeval COMMON_COMMIT=$$(git merge-base HEAD ${BASE_REF});	\
+	$QCOMMON_COMMIT=`git merge-base HEAD ${BASE_REF}`;		\
 	for commit in `git rev-list $$COMMON_COMMIT..HEAD`; do		\
 		echo "[*] Analyzing commit '$$commit'";			\
 		git format-patch --stdout "$$commit~..$$commit"		\
@@ -198,6 +200,11 @@
 			-- src include '!src/extern' '!include/extern'	\
 			| ${CHECKPATCH} - || true;			\
 	done
+
+# Target used to check for suspiciously missing changed files.
+
+checkdiff:
+	$Qcontrib/checkdiff.bash `git merge-base HEAD ${BASE_REF}`
 
 # This target is used during development in order to prevent adding new issues
 # to the source code. All warnings are treated as errors in order to block the
--- /dev/null
+++ b/contrib/checkdiff.bash
@@ -1,0 +1,77 @@
+#!/bin/bash
+
+# SPDX-License-Identifier: MIT
+#
+# Copyright (c) 2021 Rangi
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+declare -A FILES
+while read -r -d '' file; do
+	FILES["$file"]="true"
+done < <(git diff --name-only -z $1 HEAD)
+
+edited () {
+	${FILES["$1"]:-"false"}
+}
+
+dependency () {
+	if edited "$1" && ! edited "$2"; then
+		echo "'$1' was modified, but not '$2'! $3" | xargs
+	fi
+}
+
+# Pull requests that edit the first file without the second may be correct,
+# but are suspicious enough to require review.
+
+dependency include/linkdefs.h    src/rgbds.5 \
+           "Was the object file format changed?"
+
+dependency src/asm/parser.y      src/asm/rgbasm.5 \
+           "Was the rgbasm grammar changed?"
+
+dependency include/asm/warning.h src/asm/rgbasm.1 \
+           "Were the rgbasm warnings changed?"
+
+dependency src/asm/object.c      include/linkdefs.h \
+           "Should the object file revision be bumped?"
+dependency src/link/object.c     include/linkdefs.h \
+           "Should the object file revision be bumped?"
+
+dependency Makefile              CMakeLists.txt \
+           "Did the build process change?"
+dependency Makefile              src/CMakeLists.txt \
+           "Did the build process change?"
+
+dependency src/asm/main.c        src/asm/rgbasm.1 \
+           "Did the rgbasm CLI change?"
+dependency src/asm/main.c        contrib/zsh_compl/_rgbasm \
+           "Did the rgbasm CLI change?"
+dependency src/link/main.c       src/link/rgblink.1 \
+           "Did the rgblink CLI change?"
+dependency src/link/main.c       contrib/zsh_compl/_rgblink \
+           "Did the rgblink CLI change?"
+dependency src/fix/main.c        src/fix/rgbfix.1 \
+           "Did the rgbfix CLI change?"
+dependency src/fix/main.c        contrib/zsh_compl/_rgbfix \
+           "Did the rgbfix CLI change?"
+dependency src/gfx/main.c        src/gfx/rgbgfx.1 \
+           "Did the rgbgfx CLI change?"
+dependency src/gfx/main.c        contrib/zsh_compl/_rgbgfx \
+           "Did the rgbgfx CLI change?"
--- a/include/asm/rpn.h
+++ b/include/asm/rpn.h
@@ -24,7 +24,7 @@
 	uint8_t  *rpn;         // Array of bytes serializing the RPN expression
 	uint32_t rpnCapacity;  // Size of the `rpn` buffer
 	uint32_t rpnLength;    // Used size of the `rpn` buffer
-	uint32_t rpnPatchSize; // Size the expression will take in the obj file
+	uint32_t rpnPatchSize; // Size the expression will take in the object file
 };
 
 /*