Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify CI workflow to standard haskell-ci workflow #284

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions .github/haskell-ci.patch

This file was deleted.

48 changes: 22 additions & 26 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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 <<EOF
Expand All @@ -255,32 +254,29 @@ jobs:
run: |
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --dependencies-only -j2 all
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dependencies-only -j2 all
- name: build w/o tests and install
- name: build w/o tests
run: |
$CABAL v2-install --reinstall --overwrite-policy=always $ARG_COMPILER --disable-tests --disable-benchmarks happy
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
- name: build
run: |
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always
- name: tests
run: |
export HAPPY=$HOME/.cabal/bin/happy
export HC
export CABAL
$CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct
- name: cabal check
run: |
cd ${PKGDIR_happy_tabular} || false
${CABAL} -vnormal check
cd ${PKGDIR_happy_backend_glr} || false
cd ${PKGDIR_happy_frontend} || false
${CABAL} -vnormal check
cd ${PKGDIR_happy_codegen_common} || false
${CABAL} -vnormal check
cd ${PKGDIR_happy_backend_lalr} || false
${CABAL} -vnormal check
cd ${PKGDIR_happy_codegen_common} || false
cd ${PKGDIR_happy_backend_glr} || false
${CABAL} -vnormal check
cd ${PKGDIR_happy_grammar} || false
${CABAL} -vnormal check
cd ${PKGDIR_happy_frontend} || false
${CABAL} -vnormal check
cd ${PKGDIR_happy} || false
${CABAL} -vnormal check
- name: haddock
Expand Down
52 changes: 2 additions & 50 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,9 @@ This document holds some useful information for developing Happy.
CI on GitHub Actions
====================

2021-07-14
2024-07-15
----------

The GHC workflow file `.github/workflows/haskell-ci.yml` is generated by:

haskell-ci regenerate
patch --input=.github/haskell-ci.patch .github/workflows/haskell-ci.yml

The patch introduces happy specifics to the build and test process that
are not covered by a vanilla instance of the haskell-ci workflow.

When new GHC versions become available, CI can be updated by

- adding these versions to the `tested-with` field in `happy.cabal`
(possibly removing obsolete minor versions)

- generate the `haskell-ci.yml` by the steps above.

This should work as long as `haskell-ci` does not change its generated
workflow too much. Otherwise, the patch might not apply cleanly and
the workflow has to be patched manually.

2023-02-06 Updating to a new version of Haskell-CI
--------------------------------------------------

1. Install Haskell-CI from its source repo:

pushd /tmp
git clone https://github.com/haskell-CI/haskell-ci.git
cd haskell-ci
cabal install
popd

2. Update the `tested-with` fields in the `.cabal` files.

3. Follow the instructions to regenerate the Haskell CI workflow, which are:

haskell-ci regenerate
patch --input=.github/haskell-ci.patch .github/workflows/haskell-ci.yml

If some hunks fail to apply in the last step, the patch as to be updated.

4. Apply the remaining hunks manually.

5. Save the patched workflow, regenerate the original workflow, regenerate the patch

cp .github/workflows/haskell-ci.yml .github/workflows/haskell-ci.yml-patched
haskell-ci regenerate
diff -u .github/workflows/haskell-ci.yml .github/workflows/haskell-ci.yml-patched > .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).
34 changes: 17 additions & 17 deletions tests/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -88,7 +88,7 @@ check.%.y : %.y
%$(HS_PROG_EXT) : %.hs
$(HC) $(HC_OPTS) $($*_LD_OPTS) $< -o $@

all :: $(CHECK_ERROR_TESTS) $(ALL_TESTS)
all :: path.run $(CHECK_ERROR_TESTS) $(ALL_TESTS)

check-todo::
$(HAPPY) $(TEST_HAPPY_OPTS) -d Test.ly
Expand All @@ -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)