From e082be16bf6899aefc112824972ddd06afd09223 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Tue, 22 Oct 2024 21:03:48 +0200 Subject: [PATCH] Install goldplate through cabal file Stack doesn't understand the new build-tool-depends so removed this for now --- .github/workflows/build-and-release.yml | 19 ++++++-------- Makefile | 21 ++++----------- README.md | 26 +++---------------- cabal.project | 4 +++ patat.cabal | 12 +++++++++ stack.yaml | 15 ----------- stack.yaml.lock | 12 --------- tests/golden/Main.hs | 8 ++++++ tests/golden/inputs/syntax-definitions.md | 2 +- .../spec.goldplate} | 4 +-- 10 files changed, 43 insertions(+), 80 deletions(-) create mode 100644 cabal.project delete mode 100644 stack.yaml delete mode 100644 stack.yaml.lock create mode 100644 tests/golden/Main.hs rename tests/{golden.goldplate => golden/spec.goldplate} (64%) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 4d728cb..7af4459 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -20,20 +20,17 @@ jobs: - uses: actions/checkout@v4 - - uses: actions/cache@v3 - with: - path: ~/.stack - key: "${{ runner.os }}-${{ matrix.ghc }}-v8-${{ hashFiles('patat.cabal', 'stack.yaml', 'stack.yaml.lock') }}" - restore-keys: | - ${{ runner.os }}-${{ matrix.ghc }}-v8- - - uses: haskell-actions/setup@v2 + id: setup with: ghc-version: ${{ matrix.ghc }} - enable-stack: true - stack-version: 'latest' - stack-no-global: true - stack-setup-ghc: true + + - uses: actions/cache@v3 + with: + path: ${{ steps.setup.outputs.cabal-store }} + key: ${{ runner.os }}-${{ matrix.ghc }}-v9-${{ hashFiles('patat.cabal') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.ghc }}-v9- - run: make build id: build diff --git a/Makefile b/Makefile index 1caa971..e9e0054 100644 --- a/Makefile +++ b/Makefile @@ -19,15 +19,7 @@ ARCHIVE_CREATE=tar czf ARCHIVE_EXTRACT=tar xvzf endif -ifeq ($(UNAME), darwin) -# We use `?=` to set SOURCE_DATE_EPOCH only if it is not present. Unfortunately -# we can't use `git --date=unix` since only very recent git versions support -# that, so we need to make a round trip through `date`. SOURCE_DATE_EPOCH?=$(shell git log -1 --format=%cd --date=unix) -else -SOURCE_DATE_EPOCH?=$(shell date '+%s' \ - --date="$(shell git log -1 --format=%cd --date=rfc)") -endif ifeq ($(UNAME), darwin) COMPRESS_BIN_DEPS= @@ -37,8 +29,6 @@ COMPRESS_BIN_DEPS=$(UPX_BINARY) COMPRESS_BIN=upx endif -STACK=stack - # Default target. .PHONY: build build: $(PATAT_BINARY) @@ -60,7 +50,7 @@ $(PATAT_PACKAGE).$(ARCHIVE): $(PATAT_BINARY) extra/patat.1 $(COMPRESS_BIN_DEPS) $(ARCHIVE_CREATE) $(PATAT_PACKAGE).$(ARCHIVE) $(PATAT_PACKAGE) $(PATAT_BINARY): - $(STACK) build --copy-bins + cabal install --installdir="$(dir $(PATAT_BINARY))" # UPX is used to compress the resulting binary. We currently don't use this on # Mac OS. @@ -73,11 +63,11 @@ $(UPX_BINARY): # Man page. extra/patat.1: README.md $(PATAT_BINARY) - SOURCE_DATE_EPOCH="$(SOURCE_DATE_EPOCH)" patat-make-man >$@ + SOURCE_DATE_EPOCH="$(SOURCE_DATE_EPOCH)" cabal exec -- patat-make-man >$@ # Bash completion. -extra/patat.bash-completion: - patat --bash-completion-script patat >$@ +extra/patat.bash-completion: $(PATAT_BINARY) + cabal exec -- patat --bash-completion-script patat >$@ .PHONY: completion completion: extra/patat.bash-completion @@ -88,8 +78,7 @@ man: extra/patat.1 # Also check if we can generate the manual. .PHONY: test test: man - $(STACK) install goldplate - goldplate --pretty-diff tests + cabal test .PHONY: clean clean: diff --git a/README.md b/README.md index 5ff9030..88ff090 100644 --- a/README.md +++ b/README.md @@ -81,31 +81,11 @@ You can also find generic Linux and Mac OS binaries here: ### From source -Installation from source is very easy. You can build from source using `stack -install` or `cabal install`. `patat` is also available from [Hackage]. - -[Hackage]: https://hackage.haskell.org/package/patat - -For people unfamiliar with the Haskell ecosystem, this means you can do either -of the following: - -#### Using stack - -1. Install [stack] for your platform. -2. Clone this repository. -3. Run `stack setup` (if you're running stack for the first time) and - `stack install`. -4. Make sure `$HOME/.local/bin` is in your `$PATH`. - -[stack]: https://docs.haskellstack.org/en/stable/README/ - -#### Using cabal - -1. Install [cabal] for your platform. -2. Run `cabal install patat`. -3. Make sure `$HOME/.cabal/bin` is in your `$PATH`. +`patat` is also available from [Hackage]. You can install it using [cabal] by +running `cabal install patat`. [cabal]: https://www.haskell.org/cabal/ +[Hackage]: https://hackage.haskell.org/package/patat Running ------- diff --git a/cabal.project b/cabal.project new file mode 100644 index 0000000..b85009f --- /dev/null +++ b/cabal.project @@ -0,0 +1,4 @@ +packages: *.cabal +package patat + tests: True + flags: +patat-make-man diff --git a/patat.cabal b/patat.cabal index 31a49fd..e7c4371 100644 --- a/patat.cabal +++ b/patat.cabal @@ -160,3 +160,15 @@ Test-suite patat-tests tasty-quickcheck >= 0.10 && < 0.11, text >= 1.2 && < 2.2, QuickCheck >= 2.8 && < 2.15 + +Test-suite patat-goldplate + Main-is: Main.hs + Ghc-options: -Wall + Hs-source-dirs: tests/golden + Type: exitcode-stdio-1.0 + Default-language: Haskell2010 + Build-tool-depends: patat:patat + + Build-depends: + base >= 4.8 && < 5, + goldplate >= 0.2.2.1 && < 0.3 diff --git a/stack.yaml b/stack.yaml deleted file mode 100644 index 9104ae5..0000000 --- a/stack.yaml +++ /dev/null @@ -1,15 +0,0 @@ -resolver: 'lts-22.3' -compiler: 'ghc-9.6.3' -save-hackage-creds: false - -packages: -- '.' - -flags: - patat: - patat-make-man: true - -nix: - packages: - - 'pkg-config' - - 'zlib' diff --git a/stack.yaml.lock b/stack.yaml.lock deleted file mode 100644 index 9e00502..0000000 --- a/stack.yaml.lock +++ /dev/null @@ -1,12 +0,0 @@ -# This file was autogenerated by Stack. -# You should not edit this file by hand. -# For more information, please see the documentation at: -# https://docs.haskellstack.org/en/stable/lock_files - -packages: [] -snapshots: -- completed: - sha256: 53a2800f7fe0c4628af0e7d5e985707dd3af9863ac3983a43c835dbaa8ed5f35 - size: 714094 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/3.yaml - original: lts-22.3 diff --git a/tests/golden/Main.hs b/tests/golden/Main.hs new file mode 100644 index 0000000..d98165a --- /dev/null +++ b/tests/golden/Main.hs @@ -0,0 +1,8 @@ +import Goldplate (Options (..), defaultOptions, mainWith) +import System.Exit (exitWith) + +main :: IO () +main = mainWith options >>= exitWith + where + options = defaultOptions + { oPrettyDiff = True, oPaths = ["tests/golden"] } diff --git a/tests/golden/inputs/syntax-definitions.md b/tests/golden/inputs/syntax-definitions.md index 1a4b667..753046c 100644 --- a/tests/golden/inputs/syntax-definitions.md +++ b/tests/golden/inputs/syntax-definitions.md @@ -1,7 +1,7 @@ --- patat: syntaxDefinitions: - - 'golden/syntax-definitions/impurescript.xml' + - 'syntax-definitions/impurescript.xml' ... Hello diff --git a/tests/golden.goldplate b/tests/golden/spec.goldplate similarity index 64% rename from tests/golden.goldplate rename to tests/golden/spec.goldplate index 4181f80..29e168b 100644 --- a/tests/golden.goldplate +++ b/tests/golden/spec.goldplate @@ -1,12 +1,12 @@ { "command": "patat", - "input_files": "golden/inputs/*", + "input_files": "inputs/*", "arguments": ["--dump", "--force", "${GOLDPLATE_INPUT_FILE}"], "environment": { "HOME": "/dev/null" }, "asserts": [ {"exit_code": 0}, - {"stdout": "golden/outputs/${GOLDPLATE_INPUT_BASENAME}.dump"} + {"stdout": "outputs/${GOLDPLATE_INPUT_BASENAME}.dump"} ] }