Skip to content

Commit

Permalink
Merge pull request #1 from ambarltd/sqlserver
Browse files Browse the repository at this point in the history
Add sqlserver module
  • Loading branch information
lazamar authored Jan 9, 2025
2 parents 55334ab + 6d21a80 commit 1776b9e
Show file tree
Hide file tree
Showing 27 changed files with 654 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Build and Test
name: ambar-hs-utils
on:
push:
paths-ignore:
- '**.md'
paths:
- 'ambar-hs-utils/**'

# only one build per branch
concurrency:
group: build-${{ github.ref }}
group: build-hs-utils-${{ github.ref }}
cancel-in-progress: true

jobs:
Expand All @@ -33,6 +33,7 @@ jobs:

- name: Build - Configure
run: |
cd ambar-hs-utils
cabal configure --enable-tests --enable-benchmarks
cabal build all --dry-run
# The last step generates dist-newstyle/cache/plan.json for the cache key.
Expand All @@ -50,7 +51,9 @@ jobs:
- name: Build - 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
run: |
cd ambar-hs-utils
cabal build all --only-dependencies
# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
- name: Build - Save dependencies to cache
Expand All @@ -62,7 +65,11 @@ jobs:
key: ${{ steps.cache.outputs.cache-primary-key }}

- name: Build
run: cabal build all
run: |
cd ambar-hs-utils
cabal build all
- name: Test
run: cabal test
run: |
cd ambar-hs-utils
cabal run ambar-hs-utils-tests
75 changes: 75 additions & 0 deletions .github/workflows/ambar-sqlserver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: ambar-sqlserver
on:
push:
paths:
- 'ambar-sqlserver/**'

# only one build per branch
concurrency:
group: build-sqlserver-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: GHC ${{ matrix.ghc }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
ghc: ['9.10.1']
cabal: ['3.10.3.0']
steps:
- uses: actions/checkout@v4

- name: Setup - GHC ${{ matrix.ghc }}
uses: haskell-actions/setup@v2
id: setup
with:
ghc-version: ${{ matrix.ghc }}
# Defaults, added for clarity:
cabal-version: ${{ matrix.cabal }}
cabal-update: true

- name: Build - Configure
run: |
cd ambar-sqlserver
cabal configure --enable-tests --enable-benchmarks
cabal build all --dry-run
# The last step generates dist-newstyle/cache/plan.json for the cache key.

- name: Build - 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 }}
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
restore-keys: ${{ env.key }}-

- name: Build - Install dependencies
# If we had an exact cache hit, the dependencies will be up to date.
if: steps.cache.outputs.cache-hit != 'true'
run: |
cd ambar-sqlserver
cabal build all --only-dependencies
# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
- name: Build - Save dependencies to cache
uses: actions/cache/save@v4
# If we had an exact cache hit, trying to save the cache would error because of key clash.
if: steps.cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ steps.cache.outputs.cache-primary-key }}

- name: Build
run: |
cd ambar-sqlserver
cabal build all
- name: Test
run: |
cd ambar-sqlserver
cabal run ambar-sqlserver-tests
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Ambar utility modules

This includes modules that are not application-specific and that are shared across application.

- `ambar-hs-utils` - General-purpose utility modules
- `ambar-sqlserver` - Convenient Microsoft SQL Server API wrapper
5 changes: 5 additions & 0 deletions ambar-hs-utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ambar-hs-utils

Functions used across Ambar's code.

Each module could be a package of their own, but they are kept together here for simplicity of usage.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions ambar-sqlserver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ambar-sqlserver

A wrapper around the [`mssql-simple`](https://hackage.haskell.org/package/mssql-simple) library to provide:
- Applicative interfaces for field and row parsing.
- Ability to provide explicit parsers for queries.
- A strongly typed `Query` type with automatic transaction wrapping.
- A `ToRow` class for standardised encoding of types in queries.

-
50 changes: 50 additions & 0 deletions ambar-sqlserver/ambar-sqlserver.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
cabal-version: 3.4
name: ambar-sqlserver
version: 0.1.0.0
license: NONE
author: Ambar
maintainer: [email protected]
category: Database
build-type: Simple
extra-doc-files: CHANGELOG.md

common common
ghc-options: -Wall
default-extensions:
DerivingStrategies
LambdaCase
OverloadedStrings
RecordWildCards
TypeFamilies
TypeFamilyDependencies
DeriveAnyClass

library
import: common
exposed-modules:
Database.SQLServer
build-depends:
base ^>=4.20.0.0
, ambar-hs-utils
, bytestring
, base16
, text
, ms-tds
, mssql-simple

hs-source-dirs: src
default-language: GHC2021

test-suite ambar-sqlserver-tests
import: common
default-language: GHC2021
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Main.hs
build-depends:
base ^>=4.20.0.0
, ambar-hs-utils
, ambar-sqlserver
, bytestring
, text
, hspec
4 changes: 4 additions & 0 deletions ambar-sqlserver/cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
with-compiler: ghc-9.10.1
packages:
.
../ambar-hs-utils
Loading

0 comments on commit 1776b9e

Please sign in to comment.