Skip to content
Open
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
48 changes: 48 additions & 0 deletions .github/workflows/doctest/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: "Run doctest on a Cabal package"

inputs:
ghc:
description: 'Which GHC version to use for doctest'
type: string
required: true
version:
description: 'Which version of doctest to use'
type: string
required: false
default: 'latest'

outputs:
path:
description: "The path to the doctest executable"
value: ${{ steps.result.outputs.result }}

runs:
using: "composite"
steps:
- name: "Check for cached executable"
id: cache
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const tc = require('@actions/tool-cache');
return null;

- name: "Setup Haskell environment"
id: setup
uses: haskell-actions/[email protected]
with:
ghc-version: "${{ inputs.ghc }}"
cabal-update: true

- name: "Result"
id: result
uses: actions/github-script@v7
with:
result-encoding: string
script: |
if (${{ steps.cache.outputs.result }}) {
return ${{ steps.cache.outputs.result }};
} else {
return null;
}
51 changes: 51 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Run linters

on:
pull_request: {}
push:
branches:
- "main"

jobs:
cabal-gild:
runs-on: ubuntu-latest
steps:
- name: 'Set up cabal-gild'
uses: tfausak/cabal-gild-setup-action@v2

- name: 'Checkout the repository'
uses: actions/checkout@v4

- name: 'Check package'
run: cabal-gild --mode check --input os-string-aeson.cabal

fourmolu:
runs-on: ubuntu-latest
steps:
- name: 'Checkout the repository'
uses: actions/checkout@v4

- name: 'Check that the source code is formatted'
uses: fourmolu/fourmolu-action@v10
with:
pattern: |
src/**/*.hs
os-string-aeson-internal/**/*.hs
examples/**/*.hs
test/**/*.hs

hlint:
runs-on: ubuntu-latest
steps:
- name: 'Checkout the repository'
uses: actions/checkout@v4

- name: 'Set up HLint'
uses: haskell-actions/hlint-setup@v2

- name: 'Run HLint'
uses: haskell-actions/hlint-run@v2
with:
path: '["src", "os-string-aeson-internal", "examples", "test"]'
fail-on: warning

54 changes: 43 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,39 @@ jobs:
ghc-version: "${{ matrix.ghc }}"
cabal-update: true

- name: "Install doctest"
id: install-doctest
shell: bash
run: |
if [[ "${RUNNER_TEMP}" == '' ]]; then
echo 'Expected $RUNNER_TEMP to be defined'
exit 1
fi

if [[ "${RUNNER_TOOL_CACHE}" == '' ]]; then
echo 'Expected $RUNNER_TOOL_CACHE to be defined'
exit 1
fi

doctest="doctest-${{ steps.setup.outputs.ghc-version }}"
if [[ "${{ runner.os }}" == 'Windows' ]]; then
doctest="${doctest}.exe"
fi
result="${RUNNER_TOOL_CACHE}/${doctest}"

if [[ ! -x "${result}" ]]; then
tmpdir="$(mktemp -d "${RUNNER_TEMP}/doctest.XXXX")"
cabal install --ignore-project --installdir "${tmpdir}" --install-method copy doctest
installed="${tmpdir}/doctest"
if [[ "${{ runner.os }}" == 'Windows' ]]; then
installed="${installed}.exe"
fi
cp "${installed}" "${result}"
fi
"${result}" --version

echo "path=${result}" >> "${GITHUB_OUTPUT}"

- name: "Configure the build"
run: |
cabal configure --enable-tests --enable-benchmarks --disable-documentation
Expand All @@ -58,7 +91,9 @@ jobs:
- name: "Install dependencies"
# If we had an exact cache hit, the dependencies will be up to date.
if: steps.cache.outputs.cache-hit != 'true'
run: cabal build all --only-dependencies --enable-documentation
run: |
cabal build all --only-dependencies
cabal build all --only-dependencies --enable-documentation

- name: "Save cached dependencies"
# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
Expand All @@ -78,16 +113,13 @@ jobs:
- name: "Run doctests"
shell: bash
run: |
if [[ "${{ runner.os }}" == 'Windows' ]]
then
doctest="$HOME/.local/bin/doctest.exe"
else
doctest="$HOME/.local/bin/doctest"
fi
cabal install --ignore-project --installdir "$HOME/.local/bin" doctest
"${doctest}" --version
cabal repl --with-compiler "${doctest}" 'os-string-aeson:lib:os-string-aeson-internal'
cabal repl --with-compiler "${doctest}" 'os-string-aeson:lib:os-string-aeson'
targets=(
'os-string-aeson:lib:os-string-aeson-internal'
'os-string-aeson:lib:os-string-aeson'
)
for target in "${targets[@]}"; do
cabal repl --with-compiler "${{ steps.install-doctest.outputs.path }}" --build-depends aeson "${target}"
done

- name: "Check cabal file"
run: cabal check
Expand Down
6 changes: 4 additions & 2 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ queue_rules:
# See https://docs.mergify.io/conditions/#validating-all-status-checks
- 'check-success~=.* on ubuntu-latest'
- 'check-success~=.* on windows-latest'
merge_method: squash

pull_request_rules:
- name: 'Automatically merge pull requests'
conditions:
Expand All @@ -13,9 +15,9 @@ pull_request_rules:
actions:
queue:
name: default
method: squash

- name: 'Delete head branch after merge'
conditions:
- merged
- 'merged'
actions:
delete_head_branch: {}
65 changes: 19 additions & 46 deletions os-string-aeson.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extra-doc-files:
tested-with:
ghc ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.8 || ==9.6.6 || ==9.8.2 || ==9.10.1

flag old-os-string
flag os-string
description: Use an older version of the os-string library.
manual: False
default: False
Expand All @@ -51,6 +51,20 @@ common language

default-language: Haskell2010

common os-string-compat
if flag(os-string)
-- We don't actually need filepath, but we want to make sure that it is not
-- <1.5 if it brought into scope by some tool (Looking at you, doctest).
build-depends:
filepath >=1.5,
os-string >=2.0.0 && <2.1,
else
build-depends:
filepath >=1.4.100.0 && <1.6,
os-string <2,

ghc-options: -Wno-deprecations

common rts
ghc-options:
-threaded
Expand All @@ -59,34 +73,21 @@ common rts

library
import: language
import: os-string-compat
hs-source-dirs: src/
build-depends:
base,
os-string-aeson-internal,

-- Dependencies for doctests
build-depends:
aeson

-- cabal-gild: discover ./src/ --exclude=Setup.hs --exclude=**/Include.hs
exposed-modules:
System.OsString.Aeson
System.OsString.Aeson.Posix
System.OsString.Aeson.Windows

-- Only needed for doctests
if flag(old-os-string)
build-depends:
filepath >=1.4.100.0 && <1.5,
os-string <2,

ghc-options: -Wno-deprecations
else
build-depends:
os-string >=2.0.0 && <2.1

library os-string-aeson-internal
import: language
import: os-string-compat
visibility: public
hs-source-dirs: os-string-aeson-internal/
build-depends:
Expand All @@ -105,18 +106,9 @@ library os-string-aeson-internal
System.OsString.Aeson.Internal.Types
System.OsString.Aeson.Internal.Windows

if flag(old-os-string)
build-depends:
filepath >=1.4.100.0 && <1.5,
os-string <2,

ghc-options: -Wno-deprecations
else
build-depends:
os-string >=2.0.0 && <2.1

test-suite examples
import: language
import: os-string-compat
import: rts
type: exitcode-stdio-1.0
hs-source-dirs: examples
Expand All @@ -135,18 +127,9 @@ test-suite examples
HKD2
Utils

if flag(old-os-string)
build-depends:
filepath >=1.4.100.0 && <1.5,
os-string <2,

ghc-options: -Wno-deprecations
else
build-depends:
os-string >=2.0.0 && <2.1

test-suite test
import: language
import: os-string-compat
import: rts
type: exitcode-stdio-1.0
hs-source-dirs: test
Expand All @@ -170,16 +153,6 @@ test-suite test
Units.Posix
Units.Windows

if flag(old-os-string)
build-depends:
filepath >=1.4.100.0 && <1.5,
os-string <2,

ghc-options: -Wno-deprecations
else
build-depends:
os-string >=2.0.0 && <2.1

source-repository head
type: git
location: https://github.com/mmhat/os-string-aeson
10 changes: 0 additions & 10 deletions stack.ghc-9.2.yaml

This file was deleted.

33 changes: 0 additions & 33 deletions stack.ghc-9.2.yaml.lock

This file was deleted.

8 changes: 0 additions & 8 deletions stack.ghc-9.4.yaml

This file was deleted.

19 changes: 0 additions & 19 deletions stack.ghc-9.4.yaml.lock

This file was deleted.

Loading