Skip to content

Commit e082be1

Browse files
committed
Install goldplate through cabal file
Stack doesn't understand the new build-tool-depends so removed this for now
1 parent 72cf0cb commit e082be1

10 files changed

+43
-80
lines changed

.github/workflows/build-and-release.yml

+8-11
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,17 @@ jobs:
2020

2121
- uses: actions/checkout@v4
2222

23-
- uses: actions/cache@v3
24-
with:
25-
path: ~/.stack
26-
key: "${{ runner.os }}-${{ matrix.ghc }}-v8-${{ hashFiles('patat.cabal', 'stack.yaml', 'stack.yaml.lock') }}"
27-
restore-keys: |
28-
${{ runner.os }}-${{ matrix.ghc }}-v8-
29-
3023
- uses: haskell-actions/setup@v2
24+
id: setup
3125
with:
3226
ghc-version: ${{ matrix.ghc }}
33-
enable-stack: true
34-
stack-version: 'latest'
35-
stack-no-global: true
36-
stack-setup-ghc: true
27+
28+
- uses: actions/cache@v3
29+
with:
30+
path: ${{ steps.setup.outputs.cabal-store }}
31+
key: ${{ runner.os }}-${{ matrix.ghc }}-v9-${{ hashFiles('patat.cabal') }}
32+
restore-keys: |
33+
${{ runner.os }}-${{ matrix.ghc }}-v9-
3734
3835
- run: make build
3936
id: build

Makefile

+5-16
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,7 @@ ARCHIVE_CREATE=tar czf
1919
ARCHIVE_EXTRACT=tar xvzf
2020
endif
2121

22-
ifeq ($(UNAME), darwin)
23-
# We use `?=` to set SOURCE_DATE_EPOCH only if it is not present. Unfortunately
24-
# we can't use `git --date=unix` since only very recent git versions support
25-
# that, so we need to make a round trip through `date`.
2622
SOURCE_DATE_EPOCH?=$(shell git log -1 --format=%cd --date=unix)
27-
else
28-
SOURCE_DATE_EPOCH?=$(shell date '+%s' \
29-
--date="$(shell git log -1 --format=%cd --date=rfc)")
30-
endif
3123

3224
ifeq ($(UNAME), darwin)
3325
COMPRESS_BIN_DEPS=
@@ -37,8 +29,6 @@ COMPRESS_BIN_DEPS=$(UPX_BINARY)
3729
COMPRESS_BIN=upx
3830
endif
3931

40-
STACK=stack
41-
4232
# Default target.
4333
.PHONY: build
4434
build: $(PATAT_BINARY)
@@ -60,7 +50,7 @@ $(PATAT_PACKAGE).$(ARCHIVE): $(PATAT_BINARY) extra/patat.1 $(COMPRESS_BIN_DEPS)
6050
$(ARCHIVE_CREATE) $(PATAT_PACKAGE).$(ARCHIVE) $(PATAT_PACKAGE)
6151

6252
$(PATAT_BINARY):
63-
$(STACK) build --copy-bins
53+
cabal install --installdir="$(dir $(PATAT_BINARY))"
6454

6555
# UPX is used to compress the resulting binary. We currently don't use this on
6656
# Mac OS.
@@ -73,11 +63,11 @@ $(UPX_BINARY):
7363

7464
# Man page.
7565
extra/patat.1: README.md $(PATAT_BINARY)
76-
SOURCE_DATE_EPOCH="$(SOURCE_DATE_EPOCH)" patat-make-man >$@
66+
SOURCE_DATE_EPOCH="$(SOURCE_DATE_EPOCH)" cabal exec -- patat-make-man >$@
7767

7868
# Bash completion.
79-
extra/patat.bash-completion:
80-
patat --bash-completion-script patat >$@
69+
extra/patat.bash-completion: $(PATAT_BINARY)
70+
cabal exec -- patat --bash-completion-script patat >$@
8171

8272
.PHONY: completion
8373
completion: extra/patat.bash-completion
@@ -88,8 +78,7 @@ man: extra/patat.1
8878
# Also check if we can generate the manual.
8979
.PHONY: test
9080
test: man
91-
$(STACK) install goldplate
92-
goldplate --pretty-diff tests
81+
cabal test
9382

9483
.PHONY: clean
9584
clean:

README.md

+3-23
Original file line numberDiff line numberDiff line change
@@ -81,31 +81,11 @@ You can also find generic Linux and Mac OS binaries here:
8181

8282
### From source
8383

84-
Installation from source is very easy. You can build from source using `stack
85-
install` or `cabal install`. `patat` is also available from [Hackage].
86-
87-
[Hackage]: https://hackage.haskell.org/package/patat
88-
89-
For people unfamiliar with the Haskell ecosystem, this means you can do either
90-
of the following:
91-
92-
#### Using stack
93-
94-
1. Install [stack] for your platform.
95-
2. Clone this repository.
96-
3. Run `stack setup` (if you're running stack for the first time) and
97-
`stack install`.
98-
4. Make sure `$HOME/.local/bin` is in your `$PATH`.
99-
100-
[stack]: https://docs.haskellstack.org/en/stable/README/
101-
102-
#### Using cabal
103-
104-
1. Install [cabal] for your platform.
105-
2. Run `cabal install patat`.
106-
3. Make sure `$HOME/.cabal/bin` is in your `$PATH`.
84+
`patat` is also available from [Hackage]. You can install it using [cabal] by
85+
running `cabal install patat`.
10786

10887
[cabal]: https://www.haskell.org/cabal/
88+
[Hackage]: https://hackage.haskell.org/package/patat
10989

11090
Running
11191
-------

cabal.project

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
packages: *.cabal
2+
package patat
3+
tests: True
4+
flags: +patat-make-man

patat.cabal

+12
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,15 @@ Test-suite patat-tests
160160
tasty-quickcheck >= 0.10 && < 0.11,
161161
text >= 1.2 && < 2.2,
162162
QuickCheck >= 2.8 && < 2.15
163+
164+
Test-suite patat-goldplate
165+
Main-is: Main.hs
166+
Ghc-options: -Wall
167+
Hs-source-dirs: tests/golden
168+
Type: exitcode-stdio-1.0
169+
Default-language: Haskell2010
170+
Build-tool-depends: patat:patat
171+
172+
Build-depends:
173+
base >= 4.8 && < 5,
174+
goldplate >= 0.2.2.1 && < 0.3

stack.yaml

-15
This file was deleted.

stack.yaml.lock

-12
This file was deleted.

tests/golden/Main.hs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Goldplate (Options (..), defaultOptions, mainWith)
2+
import System.Exit (exitWith)
3+
4+
main :: IO ()
5+
main = mainWith options >>= exitWith
6+
where
7+
options = defaultOptions
8+
{ oPrettyDiff = True, oPaths = ["tests/golden"] }

tests/golden/inputs/syntax-definitions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
patat:
33
syntaxDefinitions:
4-
- 'golden/syntax-definitions/impurescript.xml'
4+
- 'syntax-definitions/impurescript.xml'
55
...
66

77
Hello
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"command": "patat",
3-
"input_files": "golden/inputs/*",
3+
"input_files": "inputs/*",
44
"arguments": ["--dump", "--force", "${GOLDPLATE_INPUT_FILE}"],
55
"environment": {
66
"HOME": "/dev/null"
77
},
88
"asserts": [
99
{"exit_code": 0},
10-
{"stdout": "golden/outputs/${GOLDPLATE_INPUT_BASENAME}.dump"}
10+
{"stdout": "outputs/${GOLDPLATE_INPUT_BASENAME}.dump"}
1111
]
1212
}

0 commit comments

Comments
 (0)