From 349a237b6d95c86625d0b1e6b0142c4c930e3694 Mon Sep 17 00:00:00 2001 From: Sebastian Graf Date: Mon, 15 Jul 2024 12:52:49 +0200 Subject: [PATCH] Simplify CI workflow to standard `haskell-ci` workflow --- .github/workflows/haskell-ci.yml | 48 ++++++++++++++--------------- DEVELOPER.md | 52 ++------------------------------ tests/Makefile | 34 ++++++++++----------- 3 files changed, 41 insertions(+), 93 deletions(-) diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index 45cb9c09..ffd733a0 100644 --- a/.github/workflows/haskell-ci.yml +++ b/.github/workflows/haskell-ci.yml @@ -111,7 +111,6 @@ jobs: echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV" HCDIR=/opt/$HCKIND/$HCVER HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER") - echo "$HOME/.ghcup/bin" >> "$GITHUB_PATH" HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#') HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#') echo "HC=$HC" >> "$GITHUB_ENV" @@ -181,11 +180,11 @@ jobs: run: | touch cabal.project echo "packages: $GITHUB_WORKSPACE/source/packages/tabular" >> cabal.project - echo "packages: $GITHUB_WORKSPACE/source/packages/backend-glr" >> cabal.project - echo "packages: $GITHUB_WORKSPACE/source/packages/backend-lalr" >> cabal.project + echo "packages: $GITHUB_WORKSPACE/source/packages/frontend" >> cabal.project echo "packages: $GITHUB_WORKSPACE/source/packages/codegen-common" >> cabal.project + echo "packages: $GITHUB_WORKSPACE/source/packages/backend-lalr" >> cabal.project + echo "packages: $GITHUB_WORKSPACE/source/packages/backend-glr" >> cabal.project echo "packages: $GITHUB_WORKSPACE/source/packages/grammar" >> cabal.project - echo "packages: $GITHUB_WORKSPACE/source/packages/frontend" >> cabal.project echo "packages: $GITHUB_WORKSPACE/source/." >> cabal.project cat cabal.project - name: sdist @@ -200,40 +199,40 @@ jobs: run: | PKGDIR_happy_tabular="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/happy-tabular-[0-9.]*')" echo "PKGDIR_happy_tabular=${PKGDIR_happy_tabular}" >> "$GITHUB_ENV" - PKGDIR_happy_backend_glr="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/happy-backend-glr-[0-9.]*')" - echo "PKGDIR_happy_backend_glr=${PKGDIR_happy_backend_glr}" >> "$GITHUB_ENV" - PKGDIR_happy_backend_lalr="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/happy-backend-lalr-[0-9.]*')" - echo "PKGDIR_happy_backend_lalr=${PKGDIR_happy_backend_lalr}" >> "$GITHUB_ENV" + PKGDIR_happy_frontend="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/happy-frontend-[0-9.]*')" + echo "PKGDIR_happy_frontend=${PKGDIR_happy_frontend}" >> "$GITHUB_ENV" PKGDIR_happy_codegen_common="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/happy-codegen-common-[0-9.]*')" echo "PKGDIR_happy_codegen_common=${PKGDIR_happy_codegen_common}" >> "$GITHUB_ENV" + PKGDIR_happy_backend_lalr="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/happy-backend-lalr-[0-9.]*')" + echo "PKGDIR_happy_backend_lalr=${PKGDIR_happy_backend_lalr}" >> "$GITHUB_ENV" + PKGDIR_happy_backend_glr="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/happy-backend-glr-[0-9.]*')" + echo "PKGDIR_happy_backend_glr=${PKGDIR_happy_backend_glr}" >> "$GITHUB_ENV" PKGDIR_happy_grammar="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/happy-grammar-[0-9.]*')" echo "PKGDIR_happy_grammar=${PKGDIR_happy_grammar}" >> "$GITHUB_ENV" - PKGDIR_happy_frontend="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/happy-frontend-[0-9.]*')" - echo "PKGDIR_happy_frontend=${PKGDIR_happy_frontend}" >> "$GITHUB_ENV" PKGDIR_happy="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/happy-[0-9.]*')" echo "PKGDIR_happy=${PKGDIR_happy}" >> "$GITHUB_ENV" rm -f cabal.project cabal.project.local touch cabal.project touch cabal.project.local echo "packages: ${PKGDIR_happy_tabular}" >> cabal.project - echo "packages: ${PKGDIR_happy_backend_glr}" >> cabal.project - echo "packages: ${PKGDIR_happy_backend_lalr}" >> cabal.project + echo "packages: ${PKGDIR_happy_frontend}" >> cabal.project echo "packages: ${PKGDIR_happy_codegen_common}" >> cabal.project + echo "packages: ${PKGDIR_happy_backend_lalr}" >> cabal.project + echo "packages: ${PKGDIR_happy_backend_glr}" >> cabal.project echo "packages: ${PKGDIR_happy_grammar}" >> cabal.project - echo "packages: ${PKGDIR_happy_frontend}" >> cabal.project echo "packages: ${PKGDIR_happy}" >> cabal.project if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package happy-tabular" >> cabal.project ; fi if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi - if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package happy-backend-glr" >> cabal.project ; fi + if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package happy-frontend" >> cabal.project ; fi + if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi + if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package happy-codegen-common" >> cabal.project ; fi if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package happy-backend-lalr" >> cabal.project ; fi if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi - if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package happy-codegen-common" >> cabal.project ; fi + if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package happy-backend-glr" >> cabal.project ; fi if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package happy-grammar" >> cabal.project ; fi if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi - if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package happy-frontend" >> cabal.project ; fi - if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package happy" >> cabal.project ; fi if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi cat >> cabal.project < .github/haskell-ci.patch - -6. Now the patch will apply cleanly. - - patch --input=.github/haskell-ci.patch .github/workflows/haskell-ci.yml - -7. Commit the updated files (no extra files need to be committed). diff --git a/tests/Makefile b/tests/Makefile index 399126d1..eec49747 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,5 +1,15 @@ +# NOTE: This assumes that a working `ghc` is on $PATH; this may not +# necessarily be the same GHC used by `cabal` for building `happy`. +# +# Again, if HC has been set in the environment (e.g. by the CI), we keep this setting. +# [2021-07-14, PR #196](https://github.com/haskell/happy/pull/196) +# +HC ?= ghc +HC_OPTS=-package array -Wall -Werror + # NOTE: `cabal test` will take care to build the local `happy` # executable and place it into $PATH for us to pick up. +# (This is ensured by setting build-tool-depends.) # # If it doesn't look like the alex binary in $PATH comes from the # build tree, then we'll fall back to pointing to @@ -11,21 +21,7 @@ # without danger of it being "fixed" by the logic below. # [2021-07-14, PR #196](https://github.com/haskell/happy/pull/196) # -ifndef HAPPY -HAPPY=$(shell which happy) -ifeq "$(filter $(dir $(shell pwd))%,$(HAPPY))" "" -HAPPY=../dist/build/happy/happy -endif -endif - -# NOTE: This assumes that a working `ghc` is on $PATH; this may not -# necessarily be the same GHC used by `cabal` for building `happy`. -# -# Again, if HC has been set in the environment (e.g. by the CI), we keep this setting. -# [2021-07-14, PR #196](https://github.com/haskell/happy/pull/196) -# -HC ?= ghc -HC_OPTS=-package array -Wall -Werror +HAPPY ?= happy .PRECIOUS: %.n.hs %.c.hs %.o %.exe %.bin @@ -78,6 +74,10 @@ HC_OPTS += -fforce-recomp @echo "--> Checking $<..." ./$< +path.run : # simply a test to output the path of the built happy executable, useful in CI + @echo "--> Printing happy path..." + which $(HAPPY) + check.%.y : %.y @echo "--> Checking $<..." $(HAPPY) $(TEST_HAPPY_OPTS) $< 1>$*.run.stdout 2>$*.run.stderr || true @@ -88,7 +88,7 @@ check.%.y : %.y %$(HS_PROG_EXT) : %.hs $(HC) $(HC_OPTS) $($*_LD_OPTS) $< -o $@ -all :: $(CHECK_ERROR_TESTS) $(ALL_TESTS) +all :: $(CHECK_ERROR_TESTS) $(ALL_TESTS) path.run check-todo:: $(HAPPY) $(TEST_HAPPY_OPTS) -d Test.ly @@ -100,7 +100,7 @@ check-todo:: ./happy_test -rm -f ./happy_test -.PHONY: clean +.PHONY: clean all check-todo path.run clean: $(RM) $(CLEAN_FILES)