From d2e3abb4f2db60d90a077370bc20059cef5b7ac3 Mon Sep 17 00:00:00 2001 From: Simon Liu Date: Thu, 6 Mar 2025 09:54:47 +0000 Subject: [PATCH 1/2] Group github action log lines Previously, the workflow used to test the code does not group log messages, possibly making the output too lengthy and hard to scroll on the web. Especially the logs generated by dudect/fixture.c, although it shows perfectly fine on local machines by rewriting previous lines in the terminal, github actions does not seem to support it. The log grouping is done by adding "::group::{title}" and "::endgroup::" which are mentioned in github docs. Another argument "--group-output" is added to "scripts/driver.py" to optionally enable grouping. Added another target "test_ga" in "Makefile" and replaced "make test" with it in github workflow. ("ga" is the abbreviation for "github actions") Link: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#grouping-log-lines Change-Id: I77d4455967b6d7e1d118049d91e67346f6dcdc1a --- .github/workflows/main.yml | 2 +- Makefile | 4 ++++ scripts/driver.py | 19 +++++++++++++++---- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f4f081822..dca88e865 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,7 +27,7 @@ jobs: cat scripts/kirby.raw - name: make test run: | - make test || (cat scripts/weeping.raw ; exit 1) + make test_ga || (cat scripts/weeping.raw ; exit 1) cat scripts/kirby.raw coding-style: diff --git a/Makefile b/Makefile index dc613fd07..7e104f202 100644 --- a/Makefile +++ b/Makefile @@ -60,6 +60,10 @@ test: qtest scripts/driver.py $(Q)scripts/check-repo.sh scripts/driver.py -c +test_ga: qtest scripts/driver.py + $(Q)scripts/check-repo.sh + scripts/driver.py -c --group-output + valgrind_existence: @which valgrind 2>&1 > /dev/null || (echo "FATAL: valgrind not found"; exit 1) diff --git a/scripts/driver.py b/scripts/driver.py index a333b01c2..ff6ed1942 100755 --- a/scripts/driver.py +++ b/scripts/driver.py @@ -17,6 +17,7 @@ class Tracer: autograde = False useValgrind = False colored = False + groupOutput = False traceDict = { 1: "trace-01-ops", @@ -69,13 +70,15 @@ def __init__(self, verbLevel=0, autograde=False, useValgrind=False, - colored=False): + colored=False, + groupOutput=False): if qtest != "": self.qtest = qtest self.verbLevel = verbLevel self.autograde = autograde self.useValgrind = useValgrind self.colored = colored + self.groupOutput = groupOutput def printInColor(self, text, color): if self.colored == False: @@ -117,9 +120,13 @@ def run(self, tid=0): tname = self.traceDict[t] if self.verbLevel > 0: print("+++ TESTING trace %s:" % tname) + if self.groupOutput: + print("::group::Trace %s" % tname, flush=True) ok = self.runTrace(t) maxval = self.maxScores[t] tval = maxval if ok else 0 + if self.groupOutput: + print("::endgroup::", flush=True) if tval < maxval: self.printInColor("---\t%s\t%d/%d" % (tname, tval, maxval), self.RED) else: @@ -146,7 +153,7 @@ def run(self, tid=0): sys.exit(1) def usage(name): - print("Usage: %s [-h] [-p PROG] [-t TID] [-v VLEVEL] [--valgrind] [-c]" % name) + print("Usage: %s [-h] [-p PROG] [-t TID] [-v VLEVEL] [--valgrind] [-c] [--group-output]" % name) print(" -h Print this message") print(" -p PROG Program to test") print(" -t TID Trace ID to test") @@ -163,8 +170,9 @@ def run(name, args): autograde = False useValgrind = False colored = False + groupOutput = False - optlist, args = getopt.getopt(args, 'hp:t:v:A:c', ['valgrind']) + optlist, args = getopt.getopt(args, 'hp:t:v:A:c', ['valgrind', 'group-output']) for (opt, val) in optlist: if opt == '-h': usage(name) @@ -181,6 +189,8 @@ def run(name, args): useValgrind = True elif opt == '-c': colored = True + elif opt == '--group-output': + groupOutput = True else: print("Unrecognized option '%s'" % opt) usage(name) @@ -190,7 +200,8 @@ def run(name, args): verbLevel=vlevel, autograde=autograde, useValgrind=useValgrind, - colored=colored) + colored=colored, + groupOutput=groupOutput) t.run(tid) From 46cad736fff73a6ac68c686029fa43f376f6b4f6 Mon Sep 17 00:00:00 2001 From: Simon Liu Date: Wed, 12 Mar 2025 07:08:25 +0000 Subject: [PATCH 2/2] Remove dedicated test target to CI pipeline Target "test_ga" for dedicated test workflow is removed. Instead, check if environment variable GITHUB_ACTIONS is set to detect which environment is running the test. GITHUB_ACTIONS is set to "true" automatically when running CI workflow on github actions. It is documented in the link below. Link: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables Change-Id: I9359514623d96dfa387524a67c9de34d94b87c5c --- .github/workflows/main.yml | 2 +- Makefile | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dca88e865..f4f081822 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,7 +27,7 @@ jobs: cat scripts/kirby.raw - name: make test run: | - make test_ga || (cat scripts/weeping.raw ; exit 1) + make test || (cat scripts/weeping.raw ; exit 1) cat scripts/kirby.raw coding-style: diff --git a/Makefile b/Makefile index 7e104f202..b4d9c984c 100644 --- a/Makefile +++ b/Makefile @@ -58,11 +58,11 @@ check: qtest test: qtest scripts/driver.py $(Q)scripts/check-repo.sh - scripts/driver.py -c - -test_ga: qtest scripts/driver.py - $(Q)scripts/check-repo.sh - scripts/driver.py -c --group-output + $(Q)if [ -n "$$GITHUB_ACTIONS" ]; then \ + scripts/driver.py -c --group-output; \ + else \ + scripts/driver.py -c; \ + fi valgrind_existence: @which valgrind 2>&1 > /dev/null || (echo "FATAL: valgrind not found"; exit 1)