Skip to content
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
174 changes: 132 additions & 42 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@ on:

jobs:
cabal:
env:
MANUAL_RESET: v5
name: cabal / ghc-${{matrix.ghc}} / ${{ matrix.os }}
continue-on-error: ${{ matrix.ghc == '9.14.1'}}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
env:
MANUAL_RESET: "v5"
continue-on-error: ${{ matrix.ghc == '9.14.1' || matrix.os == 'macos-latest' }}
strategy:
matrix:
os:
- ubuntu-latest
# - macOS-latest # Is giving issues for some reason
cabal: ["latest"]
- macos-latest # Is giving issues for some reason
cabal: ["3.16.1.0"] # we set a concrete cabal so we can cache correctly
ghc:
- "9.6.7"
- "9.8.4"
Expand All @@ -36,38 +39,61 @@ jobs:
- "9.14.1"

steps:
- uses: actions/checkout@v4
- name: "Set ENV / PATH"
id: env-vars
run: |
if [[ "${{ matrix.os }}" == 'macos-latest' ]]; then
echo "${HOME}/.ghcup/bin" >> $GITHUB_PATH
fi

echo "GHCUP_PATH=${HOME}/.ghcup" >> $GITHUB_ENV

- name: Clone Project
uses: actions/checkout@v6

- name: Cache GHCup
uses: actions/cache@v6
id: ghcup-cache
with:
path: |
~/.ghcup/bin/*
~/.ghcup/cache/*
~/.ghcup/config.yaml
~/.ghcup/ghc/${{ matrix.ghc }}
~/.ghcup/cabal/**/cabal
key: CI-ghcup-cabal-${{ env.MANUAL_RESET }}-${{ matrix.ghc }}
${{ env.GHCUP_PATH }}/bin/*
${{ env.GHCUP_PATH }}/cabal/${{ matrix.cabal }}/*
${{ env.GHCUP_PATH }}/config.yaml
${{ env.GHCUP_PATH }}/ghc/${{ matrix.ghc }}/bin
${{ env.GHCUP_PATH }}/ghc/${{ matrix.ghc }}/lib
key: CI-ghcup-cabal-${{ env.MANUAL_RESET }}-${{ matrix.os }}-${{ matrix.ghc }}

- name: Setup Haskell
if: steps.ghcup-cache.outputs.cache-hit != 'true'
uses: haskell-actions/setup@v2
id: setup-haskell-cabal
if: steps.ghcup-cache.outputs.cache-hit != 'true'
id: ghcup-install
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
cabal-update: true

- name: Cache cabal
uses: actions/cache@v6
- uses: actions/cache@v6
name: Cache cabal-store
id: deps-cache
with:
path: ~/.cabal
key: ${{ matrix.ghc }}-cabal
key: CI-deps-cache-${{ env.MANUAL_RESET }}-${{ matrix.os }}-${{ matrix.ghc }}

- name: Build Dependencies
if: steps.deps-cache.outputs.cache-hit != 'true'
id: build-deps
run: |
cabal update
cabal build all --only-dependencies \
--enable-tests --enable-benchmarks \
--write-ghc-environment-files=always \
--ghc-option='-Wall'

- name: Build
run: |
cabal build all --enable-tests --enable-benchmarks --write-ghc-environment-files=always --ghc-option='-Wall'
cabal build all \
--enable-tests --enable-benchmarks \
--write-ghc-environment-files=always \
--ghc-option='-Wall'
- name: Test
run: |
cabal test test:spec --enable-tests --ghc-option='-Wall'
Expand All @@ -79,11 +105,12 @@ jobs:
# - name: Bench
# run: |
# cabal bench --enable-benchmarks

stack:
name: stack ${{ matrix.resolver }}
runs-on: ubuntu-latest
env:
MANUAL_RESET: v3
runs-on: ubuntu-latest
# This makes the CI jobs not all be cancelled if nightly fails to build.
# However, if nightly fails to build, CI still gets a red X in the GitHub UI.
# Ideally we want CI as a whole to pass even if nightly fails.
Expand All @@ -108,18 +135,32 @@ jobs:
ghc: "9.12.4"

steps:
- uses: actions/checkout@v4
- name: "Set ENV vars per LTS"
id: env-vars
run: |
STACK_ROOT="$HOME/.stack"
GHCUP_PATH="~/.ghcup"
GHCUP_GHC_PATH="${GHCUP_PATH}/ghc/${{ matrix.ghc }}"

# And then we expose these variables in the 'env'
echo "GHC_VERSION=$GHC_VERSION" >> $GITHUB_ENV
echo "GHCUP_PATH=$GHCUP_PATH" >> $GITHUB_ENV
echo "GHCUP_GHC_PATH=$GHCUP_GHC_PATH" >> $GITHUB_ENV
echo "STACK_ROOT=$STACK_ROOT" >> $GITHUB_ENV

- name: Clone project
uses: actions/checkout@v6

- name: Cache GHCup
uses: actions/cache@v6
id: ghcup-cache
with:
path: |
~/.ghcup/bin/*
~/.ghcup/cache/*
~/.ghcup/config.yaml
~/.ghcup/ghc/${{ matrix.ghc }}
~/.ghcup/stack/*
${{ env.GHCUP_PATH }}/bin/*
${{ env.GHCUP_PATH }}/config.yaml
${{ env.GHCUP_GHC_PATH }}/bin
${{ env.GHCUP_GHC_PATH }}/lib
${{ env.GHCUP_PATH }}/stack/*
key: CI-ghcup-stack-${{ env.MANUAL_RESET }}-${{ matrix.ghc }}

- name: Setup Haskell Stack
Expand All @@ -132,44 +173,93 @@ jobs:
stack-setup-ghc: false

- name: Cache Pantry (Stackage package index)
id: pantry
id: pantry-cache
uses: actions/cache@v6
with:
path: ~/.stack/pantry
key: CI-pantry-${{ env.MANUAL_RESET }}-${{ matrix.resolver }}
path: |
${{ env.STACK_ROOT }}/pantry
!${{ env.STACK_ROOT }}/pantry/hackage/00-index.tar
!${{ env.STACK_ROOT }}/pantry/hackage/00-index.tar.gz
key: CI-pantry-${{ env.MANUAL_RESET }}

- name: Recompute Stackage package index
if: steps.pantry.outputs.cache-hit != 'true'
run: stack update # populates ~/.stack/pantry
if: steps.pantry-cache.outputs.cache-hit != 'true'
id: pantry-install
run: |
# Populates $STACK_ROOT/pantry
#
# The extra arguments are probably superfluous, but stack's caching
# is weird sometimes, so we keep everything equal when possible.
stack update \
--system-ghc --no-terminal \
--resolver="${{ matrix.resolver }}"

- name: Cache Dependencies
id: deps-cache
uses: actions/cache@v6
with:
path: |
~/.stack/stack.sqlite3
~/.stack/snapshots
key: ${{ runner.os }}-${{ matrix.resolver }}-stack
${{ env.STACK_ROOT }}/stack.sqlite3
${{ env.STACK_ROOT }}/snapshots
# [EXCLUDES]
# Don't cache any haddocks or other docs
!${{ env.STACK_ROOT }}/snapshots/**/doc
key: CI-deps-cache-${{ env.MANUAL_RESET }}-${{ matrix.resolver }}-${{ hashFiles('stack.yaml', 'http-types.cabal') }}
restore-keys: |
CI-deps-cache-${{ env.MANUAL_RESET }}-${{ matrix.resolver }}-

# This gets it's own build, since the test suite doesn't build on LTS-12
- name: Build dependencies lts-12 [no test suite]
if: matrix.resolver == 'lts-12' && steps.deps-cache.outputs.cache-hit != 'true'
id: deps-install-lts-12
run: |
stack build \
--system-ghc --no-terminal \
--resolver="${{ matrix.resolver }}" \
--only-dependencies \
--ghc-options='-j -Wall'

- name: Build dependencies
if: matrix.resolver != 'lts-12' && steps.deps-cache.outputs.cache-hit != 'true'
id: deps-install
run: |
stack build --test \
--system-ghc --no-terminal \
--resolver="${{ matrix.resolver }}" \
--only-dependencies --no-run-tests \
--ghc-options='-j -Wall'

- name: Build lts-12
# This gets it's own build, since the test suite doesn't build on LTS-12
- name: Build lts-12 [no test suite]
if: "${{ matrix.resolver == 'lts-12' }}"
run: |
stack config set system-ghc true --global
stack build --resolver=${{ matrix.resolver }} --ghc-options='-Wall'
stack build \
--system-ghc --no-terminal \
--resolver="${{ matrix.resolver }}" \
--ghc-options='-j -Wall'

- name: Build
if: "${{ matrix.resolver != 'lts-12' }}"
run: |
stack config set system-ghc true --global
stack build --resolver=${{ matrix.resolver }} --test --bench \
--no-run-tests --no-run-benchmarks --ghc-options='-Wall'
stack build \
--system-ghc --no-terminal \
--resolver=${{ matrix.resolver }} \
--test --bench \
--no-run-tests --no-run-benchmarks \
--ghc-options='-Wall'
- name: Test
if: "${{ matrix.resolver != 'lts-12' }}"
run: |
stack test --no-rerun-tests http-types:test:spec --resolver=${{ matrix.resolver }}
stack test http-types:test:spec \
--system-ghc --no-terminal \
--no-rerun-tests \
--resolver=${{ matrix.resolver }}
- name: Test Docs
if: "${{ matrix.resolver != 'lts-12' }}"
run: |
stack test http-types:test:doctests --resolver=${{ matrix.resolver }}
stack test http-types:test:doctests \
--system-ghc --no-terminal \
--resolver=${{ matrix.resolver }}

# # We probably want to add benchmarks at some point, just to make sure
# # functions don't regress in performance too much?
Expand Down
6 changes: 1 addition & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Changelog for `http-types`

## 0.13 [unreleased]

* Add support for the QUERY method and Accept-Query response field name from
[RFC 10008](https://www.rfc-editor.org/rfc/rfc10008.html).

## 0.12.7 [unreleased]

* Add parsing and rendering functions for `Status`
Expand All @@ -31,6 +26,7 @@
* `hForwarded`
* `hLink`
* `hStrictTransportSecurity`
* Add `hAcceptQuery` response field name from [RFC 10008](https://www.rfc-editor.org/rfc/rfc10008.html).

## 0.12.6 [2026-08-13]

Expand Down
1 change: 0 additions & 1 deletion Network/HTTP/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ module Network.HTTP.Types (
methodConnect,
methodOptions,
methodPatch,
methodQuery,
StdMethod (..),

-- ** Parsing and redering methods
Expand Down
17 changes: 1 addition & 16 deletions Network/HTTP/Types/Method.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ module Network.HTTP.Types.Method (
methodConnect,
methodOptions,
methodPatch,
methodQuery,

-- ** Standard Methods

Expand Down Expand Up @@ -90,16 +89,8 @@ methodOptions = renderStdMethod OPTIONS
methodPatch :: Method
methodPatch = renderStdMethod PATCH

-- | QUERY Method as defined in
-- <https://www.rfc-editor.org/rfc/rfc10008.html#section-2 RFC 10008, section 2>.
--
-- @since 0.13
methodQuery :: Method
methodQuery = renderStdMethod QUERY

-- | HTTP standard method (as defined by RFC 2616, and PATCH which is defined
-- by RFC 5789, and QUERY which is defined by
-- <https://www.rfc-editor.org/rfc/rfc10008.html#section-2 RFC 10008, section 2>).
-- by RFC 5789).
--
-- @since 0.2.0
data StdMethod
Expand All @@ -113,11 +104,6 @@ data StdMethod
| OPTIONS
| -- | @since 0.8.0
PATCH
| -- | QUERY as defined in
-- <https://www.rfc-editor.org/rfc/rfc10008.html#section-2 RFC 10008, section 2>.
--
-- @since 0.13
QUERY
deriving
( Read
, Show
Expand Down Expand Up @@ -168,4 +154,3 @@ renderStdMethod method =
CONNECT -> "CONNECT"
OPTIONS -> "OPTIONS"
PATCH -> "PATCH"
QUERY -> "QUERY"
2 changes: 1 addition & 1 deletion http-types.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Extra-doc-files:
Source-repository this
type: git
location: https://github.com/Vlix/http-types.git
tag: v0.13.0
tag: v0.12.7

Source-repository head
type: git
Expand Down
4 changes: 0 additions & 4 deletions test/Network/HTTP/Types/MethodSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ spec = do
it "CONNECT" $ methodConnect `shouldBe` "CONNECT"
it "OPTIONS" $ methodOptions `shouldBe` "OPTIONS"
it "PATCH " $ methodPatch `shouldBe` "PATCH"
it "QUERY " $ methodQuery `shouldBe` "QUERY"
it "StdMethod has all constants" $
let methodList =
[ methodGet
Expand All @@ -36,13 +35,10 @@ spec = do
, methodConnect
, methodOptions
, methodPatch
, methodQuery
]
in allMethods `shouldBe` methodList

describe "parse/render method" $ do
it "parses QUERY as a standard method" $
parseMethod methodQuery `shouldBe` Right QUERY
it "round trips" $ do
renderMethod . parseMethod <$> allMethods `shouldBe` allMethods
it "also round trips for any ByteString" $
Expand Down
Loading