Skip to content

Commit

Permalink
Merge branch 'main' into ci-stack
Browse files Browse the repository at this point in the history
  • Loading branch information
philderbeast committed Jun 4, 2024
2 parents 4428db1 + fa70fff commit 24ee33d
Show file tree
Hide file tree
Showing 64 changed files with 219 additions and 83 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/cabal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,18 @@ jobs:
- name: Updo
run: GHC_VERSION=${{ matrix.vers.ghc }} STACKAGE_VERSION=${{ matrix.vers.stackage }} make -f project-files.mk cabal.project

# Generate a file to cache dependencies.
- name: Build dry run
run: cabal build all --enable-tests --enable-benchmarks --dry-run

- name: Restore cached dependencies
uses: actions/cache/restore@v4
id: cache
env:
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
key: ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
key: ${{ env.key }}-plan-${{ hashFiles('dist-newstyle/cache/plan.json') }}
restore-keys: ${{ env.key }}-

- name: Install dependencies
Expand Down
139 changes: 139 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# NOTE: Dependencies are intentionally not listed.

.PHONY: delete-golden
delete-golden: \
delete-cabal-golden \
delete-json-golden \
delete-yaml-golden

.PHONY: delete-cabal-golden
delete-cabal-golden:
cd test-suite-golden \
&& find -type f \
| grep --perl-regexp ".*\.cabal\.golden$$" \
| xargs --no-run-if-empty --max-args=1 --verbose rm

.PHONY: delete-json-golden
delete-json-golden:
cd test-suite-golden \
&& find -type f \
| grep --perl-regexp ".*\.json\.golden$$" \
| xargs --no-run-if-empty --max-args=1 --verbose rm

.PHONY: delete-yaml-golden
delete-yaml-golden:
cd test-suite-golden \
&& find -type f \
| grep --perl-regexp ".*\.yaml\.golden$$" \
| xargs --no-run-if-empty --max-args=1 --verbose rm

.PHONY: delete-generated
.PHONY: delete-generated-cabal
.PHONY: delete-generated-json
.PHONY: delete-generated-yaml
delete-generated: \
delete-generated-cabal \
delete-generated-json \
delete-generated-yaml

delete-generated-cabal:
cd test-suite-golden \
&& find -type f \
| grep --perl-regexp ".*(?<!\.yaml)\.cabal$$" \
| xargs --no-run-if-empty --max-args=1 --verbose rm

delete-generated-json:
cd test-suite-golden \
&& find -type f \
| grep --perl-regexp ".*\.json$$" \
| xargs --no-run-if-empty --max-args=1 --verbose rm

delete-generated-yaml:
cd test-suite-golden \
&& find -type f \
| grep --perl-regexp ".*(?<!package)\.yaml$$" \
| xargs --no-run-if-empty --max-args=1 --verbose rm

KY := test-suite-golden/test-files/key
RW := test-suite-golden/test-files/real-world

.PHONY: generate-cabal
generate-cabal: \
$(KY)/empty-inferred/empty-inferred.cabal \
$(KY)/empty-package.cabal \
$(KY)/with-GHC2021.cabal \
$(KY)/when-dependencies.cabal \
$(KY)/import-relative/import-relative.cabal \
$(KY)/import-local/import-local.cabal \
$(KY)/empty-inferred/empty-inferred.cabal \
$(RW)/stack/stack.cabal \
$(RW)/hpack/hpack.cabal

$(KY)/empty-package.cabal:
dhall-hpack-cabal --package-dhall=$(@:.cabal=.dhall)

$(KY)/when-dependencies.cabal:
dhall-hpack-cabal --package-dhall=$(@:.cabal=.dhall)

$(KY)/with-GHC2021.cabal:
dhall-hpack-cabal --package-dhall=$(@:.cabal=.dhall)

$(KY)/%.cabal:
cd $(@D) && dhall-hpack-cabal

$(RW)/%.cabal:
dhall-hpack-cabal --package-dhall=$(@:.cabal=.dhall)

.PHONY: generate-json
generate-json: \
$(KY)/empty-inferred/package.json \
$(KY)/empty-package.json \
$(KY)/with-GHC2021.json \
$(KY)/when-dependencies.json \
$(KY)/import-relative/package.json \
$(KY)/import-local/package.json \
$(KY)/empty-inferred/package.json \
$(RW)/stack/stack.json \
$(RW)/hpack/hpack.json

$(KY)/empty-package.json:
dhall-hpack-json --package-dhall=$(@:.json=.dhall) > $@

$(KY)/when-dependencies.json:
dhall-hpack-json --package-dhall=$(@:.json=.dhall) > $@

$(KY)/with-GHC2021.json:
dhall-hpack-json --package-dhall=$(@:.json=.dhall) > $@

$(KY)/%/package.json:
cd $(@D) && dhall-hpack-json > $(@F)

$(RW)/%.json:
dhall-hpack-json --package-dhall=$(@:.json=.dhall) > $@

.PHONY: generate-yaml
generate-yaml: \
$(KY)/empty-inferred/package.yaml \
$(KY)/empty-package.yaml \
$(KY)/with-GHC2021.yaml \
$(KY)/when-dependencies.yaml \
$(KY)/import-relative/package.yaml \
$(KY)/import-local/package.yaml \
$(KY)/empty-inferred/package.yaml \
$(RW)/stack/stack.yaml \
$(RW)/hpack/hpack.yaml

$(KY)/empty-package.yaml:
dhall-hpack-yaml --package-dhall=$(@:.yaml=.dhall) > $@

$(KY)/when-dependencies.yaml:
dhall-hpack-yaml --package-dhall=$(@:.yaml=.dhall) > $@

$(KY)/with-GHC2021.yaml:
dhall-hpack-yaml --package-dhall=$(@:.yaml=.dhall) > $@

$(KY)/%/package.yaml:
cd $(@D) && dhall-hpack-yaml > $(@F)

$(RW)/%.yaml:
dhall-hpack-yaml --package-dhall=$(@:.yaml=.dhall) > $@
1 change: 1 addition & 0 deletions fix-whitespace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ included-files:
- "**/*.cabal"
- "**/*.dhall"
- "**/*.hs"
- "**/*.json"
- "**/*.md"
- "**/*.project"
- "**/*.yaml"
Expand Down
6 changes: 3 additions & 3 deletions hpack-dhall.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack

name: hpack-dhall
version: 0.5.7
version: 0.5.8
synopsis: hpack's dhalling
description: Use hpack phrasing in dhall to write cabal files.
.
Expand All @@ -22,12 +22,12 @@ category: Development
homepage: https://github.com/cabalism/hpack-dhall#readme
bug-reports: https://github.com/cabalism/hpack-dhall/issues
maintainer: Phil de Joux <phil.dejoux@blockscope.com>
copyright: © 2018 - 2022 Phil de Joux, © 2018 - 2022 Block Scope Limited
copyright: © 2018 - 2024 Phil de Joux, © 2018 - 2024 Block Scope Limited
license: BSD3
license-file: LICENSE
build-type: Simple
tested-with:
GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.2, GHC == 9.2.2
GHC == 9.2.8, GHC == 9.4.8, GHC == 9.6.5, GHC == 9.8.2
extra-source-files:
package.dhall
changelog.md
Expand Down
6 changes: 3 additions & 3 deletions package.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ let deps =
in let exe-deps = [ "optparse-applicative" ]

in { name = "hpack-dhall"
, version = "0.5.7"
, version = "0.5.8"
, maintainer = "Phil de Joux <phil.dejoux@blockscope.com>"
, copyright =
"© 2018 - 2022 Phil de Joux, © 2018 - 2022 Block Scope Limited"
"© 2018 - 2024 Phil de Joux, © 2018 - 2024 Block Scope Limited"
, license = "BSD3"
, license-file = "LICENSE"
, category = "Development"
Expand All @@ -42,7 +42,7 @@ in let exe-deps = [ "optparse-applicative" ]
''
, github = "cabalism/hpack-dhall"
, tested-with =
"GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.2, GHC == 9.2.2"
"GHC == 9.2.8, GHC == 9.4.8, GHC == 9.6.5, GHC == 9.8.2"
, extra-source-files =
[ "package.dhall"
, "changelog.md"
Expand Down
2 changes: 1 addition & 1 deletion project-stackage/lts-20.26.config
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ constraints: abstract-deque ==0.3,
hourglass-orphans ==0.1.0.0,
hp2pretty ==0.10,
-- hpack ==0.35.2,
hpack-dhall ==0.5.7,
-- hpack-dhall ==0.5.7,
hpc installed,
hpc-codecov ==0.3.0.0,
hpc-lcov ==1.1.1,
Expand Down
2 changes: 1 addition & 1 deletion project-stackage/lts-21.25.config
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ constraints: abstract-deque ==0.3,
hourglass-orphans ==0.1.0.0,
hp2pretty ==0.10,
-- hpack ==0.35.2,
hpack-dhall ==0.5.7,
-- hpack-dhall ==0.5.7,
hpc installed,
hpc-codecov ==0.3.0.0,
hpc-lcov ==1.1.1,
Expand Down
17 changes: 12 additions & 5 deletions test-suite-golden/src/Golden.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,47 +55,52 @@ goldenTestSet title dhallFiles = do
[ testGroup ".dhall to .cabal"
[ goldenVsFile
(testName dhallFile)
(cabalFile -<.> goldExt Cabal)
goldenFile
cabalFile
(writeDhallCabal dhallFile)
| dhallFile <- dhallFiles
, let cabalFile = cabalFilePath dhallFile
, let goldenFile = cabalFile -<.> goldExt Cabal
]
, testGroup ".dhall to dhall"
[ goldenVsString
(testName dhallFile)
(dhallFile -<.> goldExt Dhall)
goldenFile
(fmap fromString . showDhall $ dhallFile)
| dhallFile <- dhallFiles
, let goldenFile = dhallFile -<.> goldExt Dhall
]
, testGroup ".dhall to json"
[ goldenVsFile
(testName dhallFile)
(dhallFile -<.> goldExt Json)
goldenFile
jsonFile
(writeJson dhallFile jsonFile)
| dhallFile <- dhallFiles
, let jsonFile = dhallFile -<.> ".json"
, let goldenFile = dhallFile -<.> goldExt Json
]
, testGroup ".dhall to yaml"
[ goldenVsFile
(testName dhallFile)
(dhallFile -<.> goldExt Yaml)
goldenFile
yamlFile
(writeYaml dhallFile yamlFile)
| dhallFile <- dhallFiles
, let yamlFile = dhallFile -<.> ".yaml"
, let goldenFile = dhallFile -<.> goldExt Yaml
]
, testGroup ".yaml to .cabal"
[ goldenVsFile
(testName dhallFile)
(cabalFile -<.> goldExt Cabal)
goldenFile
cabalFile
(writeYamlCabal yamlFile cabalFile yamlCabalFile)
| dhallFile <- dhallFiles
, let yamlFile = dhallFile -<.> ".yaml"
, let cabalFile = cabalFilePath dhallFile
, let yamlCabalFile = yamlFile <.> ".cabal"
, let goldenFile = cabalFile -<.> goldExt Cabal
]
]

Expand Down Expand Up @@ -145,11 +150,13 @@ writeJson :: FilePath -> FilePath -> IO ()
writeJson dhallFile jsonFile = do
s <- showJson Nothing dhallFile
writeFile jsonFile s
appendFile jsonFile $ unlines [""]

writeYaml :: FilePath -> FilePath -> IO ()
writeYaml dhallFile yamlFile = do
s <- showYaml Nothing dhallFile
writeFile yamlFile s
appendFile yamlFile $ unlines [""]

cabalFilePath :: FilePath -> FilePath
cabalFilePath p
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
cabal-version: 1.12

-- This file has been generated from package.dhall by hpack version 0.31.0.
-- This file has been generated from package.dhall by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack
--
-- hash: 9f10239d716ef4564587e29b36c0e3b74056721733790211e20061a86a0feb53

name: empty-inferred
version: 0.0.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
cabal-version: 1.12

-- This file has been generated from package.dhall by hpack version 0.31.0.
-- This file has been generated from package.dhall by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack
--
-- hash: 9f10239d716ef4564587e29b36c0e3b74056721733790211e20061a86a0feb53

name: empty-inferred
version: 0.0.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.35.0.
-- This file has been generated from package.yaml by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{}

4 changes: 1 addition & 3 deletions test-suite-golden/test-files/key/empty-package.cabal
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
cabal-version: 1.12

-- This file has been generated from empty-package.dhall by hpack version 0.31.0.
-- This file has been generated from empty-package.dhall by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack
--
-- hash: e0a74f511d829cae53cd712664781db312951dd773249603163ba1b1e32afd04

name: empty-package
version: 0.0.0
Expand Down
4 changes: 1 addition & 3 deletions test-suite-golden/test-files/key/empty-package.cabal.golden
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
cabal-version: 1.12

-- This file has been generated from empty-package.dhall by hpack version 0.31.0.
-- This file has been generated from empty-package.dhall by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack
--
-- hash: e0a74f511d829cae53cd712664781db312951dd773249603163ba1b1e32afd04

name: empty-package
version: 0.0.0
Expand Down
2 changes: 1 addition & 1 deletion test-suite-golden/test-files/key/empty-package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"name": "empty-package"
}
}
2 changes: 1 addition & 1 deletion test-suite-golden/test-files/key/empty-package.json.golden
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"name": "empty-package"
}
}
1 change: 1 addition & 0 deletions test-suite-golden/test-files/key/empty-package.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
name: empty-package

2 changes: 1 addition & 1 deletion test-suite-golden/test-files/key/empty-package.yaml.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 1.12

-- This file has been generated from empty-package.yaml by hpack version 0.35.0.
-- This file has been generated from empty-package.yaml by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack

Expand Down
Loading

0 comments on commit 24ee33d

Please sign in to comment.