Skip to content

Handling for cabal.project.local #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
65 changes: 27 additions & 38 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
strategy:
fail-fast: false
matrix:
ghc: ["9.0.1", "8.10.7", "8.8.4", "8.6.5"]
os: [ubuntu-latest]
ghc: ["9.2.2", "9.0.2", "8.10.7", "8.8.4", "8.6.5"]
os: [ubuntu-latest, macOS-latest, windows-latest]

steps:
- uses: actions/checkout@v2
Expand All @@ -27,57 +27,46 @@ jobs:
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: 3.4.0.0
cabal-version: 3.6.2.0

- name: Set some window specific things
if: matrix.os == 'windows-latest'
run: echo 'EXE_EXT=.exe' >> $GITHUB_ENV

- name: Configure project
run: cabal configure --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+
run: |
cabal configure --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+
APPEND=1 ./scripts/gen-cabal-project-local.sh
echo "cabal.project.local:"
cat cabal.project.local

- name: Restore cabal cache
uses: haskell-works/cabal-cache-action@v1
- name: Cabal cache over S3
uses: action-works/cabal-cache-s3@v1
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
BINARY_CACHE_REGION: ${{ secrets.BINARY_CACHE_REGION }}
BINARY_CACHE_THREADS: ${{ secrets.BINARY_CACHE_THREADS }}
BINARY_CACHE_URI: ${{ secrets.BINARY_CACHE_URI }}
with:
args: |
sync-from-archive \
--threads "$BINARY_CACHE_THREADS" \
--archive-uri "$BINARY_CACHE_URI" \
--region "$BINARY_CACHE_REGION" \
--store-path "${{ steps.setup-haskell.outputs.cabal-store }}"
region: us-west-2
dist-dir: dist-newstyle
store-path: ${{ steps.setup-haskell.outputs.cabal-store }}
threads: 16
archive-uri: ${{ secrets.BINARY_CACHE_URI }}
skip: "${{ secrets.BINARY_CACHE_URI == '' }}"

- name: Cabal cache over HTTPS
uses: action-works/cabal-cache-s3@v1
with:
dist-dir: dist-newstyle
store-path: ${{ steps.setup-haskell.outputs.cabal-store }}
threads: 16
archive-uri: https://cache.haskellworks.io/archive
skip: "${{ secrets.BINARY_CACHE_URI != '' }}"

- name: Build
# Try building it twice in case of flakey builds on Windows
run: |
cabal build all --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+ || \
cabal build all --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+ -j1
run: cabal build all --enable-tests --enable-benchmarks

- name: Test
run: |
cabal test all --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+

- name: Save cabal cache
uses: haskell-works/cabal-cache-action@v1
if: ${{ always() }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
BINARY_CACHE_REGION: ${{ secrets.BINARY_CACHE_REGION }}
BINARY_CACHE_THREADS: ${{ secrets.BINARY_CACHE_THREADS }}
BINARY_CACHE_URI: ${{ secrets.BINARY_CACHE_URI }}
with:
args: |
sync-to-archive \
--threads "$BINARY_CACHE_THREADS" \
--archive-uri "$BINARY_CACHE_URI" \
--region "$BINARY_CACHE_REGION" \
--store-path "${{ steps.setup-haskell.outputs.cabal-store }}"
run: cabal test all --enable-tests --enable-benchmarks

check:
needs: build
Expand Down
6 changes: 3 additions & 3 deletions bench/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module Main where
import Control.Monad
import Criterion.Main
import Data.Char
import Data.List
import Data.Word
import HaskellWorks.Data.Vector.AsVector64s

import qualified Data.ByteString.Lazy as LBS
import qualified Data.List as L
import qualified Data.Vector.Storable as DVS
import qualified HaskellWorks.Data.Simd.Capabilities as CAP
import qualified HaskellWorks.Data.Simd.Comparison.Avx2 as AVX2
Expand Down Expand Up @@ -41,7 +41,7 @@ runAndBitsStock bs = do
benchcmpEqWord8s :: IO [Benchmark]
benchcmpEqWord8s = do
entries <- IO.listDirectory "data/bench"
let files = ("data/bench/" ++) <$> (".csv" `isSuffixOf`) `filter` entries
let files = ("data/bench/" ++) <$> (".csv" `L.isSuffixOf`) `filter` entries
benchmarks <- forM files $ \file -> return $
[ env (LBS.readFile file) $ \bs -> bgroup file
[ bench ("hw-simd/cmpEqWord8s/avx2/" <> file) (nfIO (runCmpEqWord8sAvx2 bs))
Expand All @@ -53,7 +53,7 @@ benchcmpEqWord8s = do
benchAndBits :: IO [Benchmark]
benchAndBits = do
entries <- IO.listDirectory "data/bench"
let files = ("data/bench/" ++) <$> (".csv" `isSuffixOf`) `filter` entries
let files = ("data/bench/" ++) <$> (".csv" `L.isSuffixOf`) `filter` entries
benchmarks <- forM files $ \file -> return $
[ env (LBS.readFile file) $ \bs -> bgroup file
[ bench ("hw-simd/andBits/avx2/" <> file) (nfIO (runAndBitsAvx2 bs))
Expand Down
12 changes: 0 additions & 12 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
packages: .

optimization: 2

package bits-extra
flags: +bmi2

package hw-rankselect
flags: +bmi2

package hw-rankselect-base
flags: +bmi2

package hw-simd
flags: +bmi2
10 changes: 5 additions & 5 deletions hw-simd.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ maintainer: newhoggy@gmail.com
copyright: 2018-2021 John Ky
license: BSD-3-Clause
license-file: LICENSE
tested-with: GHC == 9.0.1, GHC == 8.10.7, GHC == 8.8.4, GHC == 8.6.5
tested-with: GHC == 9.2.2, GHC == 9.0.2, GHC == 8.10.7, GHC == 8.8.4, GHC == 8.6.5
build-type: Simple
extra-source-files: README.md
ChangeLog.md
Expand Down Expand Up @@ -47,9 +47,9 @@ common containers { build-depends: containers >=
common criterion { build-depends: criterion >= 1.4.1.0 && < 1.6 }
common deepseq { build-depends: deepseq >= 1.4 && < 1.5 }
common directory { build-depends: directory >= 1.2.2 && < 1.4 }
common doctest { build-depends: doctest >= 0.16.2 && < 0.19 }
common doctest { build-depends: doctest >= 0.16.2 && < 0.21 }
common doctest-discover { build-depends: doctest-discover >= 0.2 && < 0.3 }
common hedgehog { build-depends: hedgehog >= 0.5 && < 1.1 }
common hedgehog { build-depends: hedgehog >= 0.5 && < 1.2 }
common hspec { build-depends: hspec >= 2.4 && < 3 }
common hw-bits { build-depends: hw-bits >= 0.7.0.2 && < 0.8 }
common hw-hedgehog { build-depends: hw-hedgehog >= 0.1.0.1 && < 0.2 }
Expand All @@ -59,8 +59,8 @@ common hw-rankselect { build-depends: hw-rankselect >=
common hw-rankselect-base { build-depends: hw-rankselect-base >= 0.3.2.0 && < 0.4 }
common lens { build-depends: lens >= 4 && < 6 }
common mmap { build-depends: mmap >= 0.5.9 && < 0.6 }
common text { build-depends: text >= 1.2.2 && < 2.0 }
common transformers { build-depends: transformers >= 0.4 && < 0.6 }
common text { build-depends: text >= 1.2.2 && < 2.1 }
common transformers { build-depends: transformers >= 0.4 && < 0.7 }
common vector { build-depends: vector >= 0.12.0.1 && < 0.13 }

common config
Expand Down
38 changes: 38 additions & 0 deletions scripts/gen-cabal-project-local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
OS=$(uname -s)

echo "OS=$OS"

[ "APPEND" != "1" ] && rm -f cabal.project.local

bmi_enabled() {
case "$(uname -s)" in
Darwin)
sysctl -a | grep 'cpu\..*features' | grep BMI2 > /dev/null
;;
Linux)
cat /proc/cpuinfo | grep '^flags' | grep bmi2 > /dev/null
;;
WinNT)
return 0
;;
*)
echo "Unrecognised OS" 1>&2
return 1
;;
esac
}

(
echo 'package bits-extra'
bmi_enabled && echo ' flags: +bmi2'
echo
echo 'package hw-rankselect'
bmi_enabled && echo 'flags: +bmi2'
echo
echo 'package hw-rankselect-base'
bmi_enabled && echo 'flags: +bmi2'
echo
echo 'package hw-simd'
bmi_enabled && echo 'flags: +bmi2'
echo
) >> cabal.project.local