Skip to content

Commit

Permalink
Merge pull request #50 from bitnomial/add-ci
Browse files Browse the repository at this point in the history
Add GitHub Actions CI
  • Loading branch information
wraithm authored Dec 19, 2023
2 parents 2da0c7e + 27fa227 commit 42be28d
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 32 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: CI

on:
pull_request:
push:
branches: [master]

jobs:
cabal:
name: cabal / ghc-${{ matrix.ghc }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
# - macOS-latest
cabal:
- "latest"
ghc:
- "8.10.7"
- "9.0.2"
- "9.2.8"
- "9.4.8"
- "9.6.3"

steps:
- uses: actions/checkout@v4

- uses: haskell-actions/setup@v2
id: setup-haskell-cabal
name: Setup Haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}

- uses: actions/cache@v3
name: Cache cabal-store
with:
path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }}
key: ${{ matrix.os }}-${{ matrix.ghc }}-cabal

- name: Build
run: |
cabal update
cabal build package:prometheus --enable-tests --enable-benchmarks --write-ghc-environment-files=always --flags="buildexamples"
# TODO: Actually add tests
# - name: Test
# run: |
# cabal test package:prometheus --enable-tests

stack:
name: stack ${{ matrix.resolver }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
# - macOS-latest
stack: ["latest"]
resolver:
- "--stack-yaml ./stack-8.10.yaml"
- "--stack-yaml ./stack-9.0.yaml"
- "--stack-yaml ./stack-9.2.yaml"
- "--stack-yaml ./stack-9.4.yaml"
- "--stack-yaml ./stack-9.6.yaml"

steps:
- uses: actions/checkout@v4

- uses: haskell-actions/setup@v2
name: Setup Haskell Stack
with:
stack-version: ${{ matrix.stack }}
enable-stack: true

- uses: actions/cache@v3
name: Cache ~/.stack
with:
path: ~/.stack
key: ${{ matrix.os }}-stack-${{ matrix.resolver }}

- name: Build
run: |
stack build --test --bench --no-run-tests --no-run-benchmarks --flag prometheus:buildexamples
# TODO: Actually add tests
# - name: Test
# run: |
# stack test
2 changes: 1 addition & 1 deletion Example.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{-# LANGUAGE OverloadedStrings #-}

module Example where
module Main where

import Control.Monad.IO.Class (liftIO)
import System.Metrics.Prometheus.Concurrent.RegistryT
Expand Down
20 changes: 20 additions & 0 deletions prometheus.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ description:
extra-source-files: Example.hs
, README.md

-- This flag builds the Example.hs file. It is only used for testing. It
-- is enabled in CI.
flag buildexamples
description: Build the Example.hs file. This is normally only used for testing.
default: False

library
hs-source-dirs: src
default-language: Haskell2010
Expand Down Expand Up @@ -95,6 +101,20 @@ library
, wai >= 3.2 && < 3.3
, warp >= 3.2 && < 3.5

executable prometheus-example
main-is: Example.hs
default-language: Haskell2010

ghc-options: -Wall -fwarn-tabs -fno-warn-unused-do-bind

build-depends: base
, prometheus

if flag(buildexamples)
buildable: True
else
buildable: False

source-repository head
type: git
location: https://github.com/bitnomial/prometheus
5 changes: 0 additions & 5 deletions stack-8.0.yaml

This file was deleted.

1 change: 0 additions & 1 deletion stack-8.10.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---

resolver: lts-18.28
flags: {}
packages:
Expand Down
5 changes: 0 additions & 5 deletions stack-8.2.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions stack-8.4.yaml

This file was deleted.

5 changes: 2 additions & 3 deletions stack-8.8.yaml → stack-9.0.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---

resolver: lts-16.5
resolver: lts-19.33
flags: {}
packages:
- '.'
- "."
extra-deps: []
6 changes: 6 additions & 0 deletions stack-9.4.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
resolver: lts-21.25
flags: {}
packages:
- "."
extra-deps: []
5 changes: 3 additions & 2 deletions stack-8.6.yaml → stack-9.6.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
resolver: lts-14.27
---
resolver: lts-22.0
flags: {}
packages:
- '.'
- "."
extra-deps: []
6 changes: 0 additions & 6 deletions stack.yaml

This file was deleted.

1 change: 1 addition & 0 deletions stack.yaml
8 changes: 4 additions & 4 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
packages: []
snapshots:
- completed:
sha256: caa77fdbc5b9f698262b21ee78030133272ec53116ad6ddbefdc4c321f668e0c
size: 640014
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/4.yaml
original: lts-21.4
sha256: e176944bc843f740e05242fa7a66ca1f440c127e425254f7f1257f9b19add23f
size: 712153
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/0.yaml
original: lts-22.0

0 comments on commit 42be28d

Please sign in to comment.