Skip to content

Commit

Permalink
make checkdiff does CI documentation checks (#900)
Browse files Browse the repository at this point in the history
Fixes #744
  • Loading branch information
Rangi42 authored Jun 24, 2021
1 parent 9868a01 commit 6d2db2e
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 3 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/checkdiff.yml
Original file line number Diff line number Diff line change
@@ -0,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
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ YFLAGS ?= -Wall
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
Expand Down Expand Up @@ -189,16 +192,20 @@ checkcodebase:
# 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" \
-- 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
# compilation and make the continous integration infrastructure return failure.
Expand Down
77 changes: 77 additions & 0 deletions contrib/checkdiff.bash
Original file line number Diff line number Diff line change
@@ -0,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?"
2 changes: 1 addition & 1 deletion include/asm/rpn.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct Expression {
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
};

/*
Expand Down

0 comments on commit 6d2db2e

Please sign in to comment.