From 6e0d67f9ec1f0c2279fa29781b57e273161f60b5 Mon Sep 17 00:00:00 2001 From: cadmic Date: Mon, 29 Jan 2024 04:25:58 -0800 Subject: [PATCH] Check formatting in CI (#1652) * Check formatting in CI * Move deleteDir() to cleanup section * Revert "Move deleteDir() to cleanup section" This reverts commit 4b0dd80cacf60e603077ea1d3669ca3511d366dd. * Give up on check_format.txt * Fix formatting --- Jenkinsfile | 6 ++++++ src/code/main.c | 4 ++-- tools/check_format.sh | 23 +++++++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100755 tools/check_format.sh diff --git a/Jenkinsfile b/Jenkinsfile index 958b46590f..24988b6812 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,6 +4,12 @@ pipeline { } stages { + stage('Check formatting') { + steps { + echo 'Checking formatting...' + sh 'tools/check_format.sh' + } + } stage('Setup') { steps { sh 'cp /usr/local/etc/roms/baserom_oot.z64 baseroms/gc-eu-mq-dbg/baserom.z64' diff --git a/src/code/main.c b/src/code/main.c index 15a17084f4..b7407c3bf5 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -54,7 +54,7 @@ void Main(void* arg) { // "System heap initalization" PRINTF("システムヒープ初期化 %08x-%08x %08x\n", systemHeapStart, fb, gSystemHeapSize); SystemHeap_Init((void*)systemHeapStart, gSystemHeapSize); // initializes the system heap - + #ifdef OOT_DEBUG { void* debugHeapStart; @@ -67,7 +67,7 @@ void Main(void* arg) { debugHeapSize = 0x400; debugHeapStart = SYSTEM_ARENA_MALLOC(debugHeapSize, "../main.c", 565); } - + PRINTF("debug_InitArena(%08x, %08x)\n", debugHeapStart, debugHeapSize); DebugArena_Init(debugHeapStart, debugHeapSize); } diff --git a/tools/check_format.sh b/tools/check_format.sh new file mode 100755 index 0000000000..1195a9c593 --- /dev/null +++ b/tools/check_format.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +STATUSOLD=`git status --porcelain` +./format.py -j +if [ $? -ne 0 ] +then + echo "Formatter failed. Exiting." + exit -1 +fi +STATUSNEW=`git status --porcelain` + +if [ "${STATUSOLD}" != "${STATUSNEW}" ]; +then + echo "" + echo "Misformatted files found. Run ./format.py and verify codegen is not impacted." + echo "" + diff --unified=0 --label "Old git status" <(echo "${STATUSOLD}") --label "New git status" <(echo "${STATUSNEW}") + echo "" + echo "Exiting." + exit 1 +fi + +exit 0