diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..e04c99b48 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/Example.hs b/Example.hs index 1ab4c7868..d23cfb225 100644 --- a/Example.hs +++ b/Example.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} -module Example where +module Main where import Control.Monad.IO.Class (liftIO) import System.Metrics.Prometheus.Concurrent.RegistryT diff --git a/prometheus.cabal b/prometheus.cabal index cebe2c9be..fb91b64fb 100644 --- a/prometheus.cabal +++ b/prometheus.cabal @@ -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 @@ -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 diff --git a/stack-8.0.yaml b/stack-8.0.yaml deleted file mode 100644 index 082557669..000000000 --- a/stack-8.0.yaml +++ /dev/null @@ -1,5 +0,0 @@ -resolver: lts-9.21 -flags: {} -packages: - - location: '.' -extra-deps: [] diff --git a/stack-8.10.yaml b/stack-8.10.yaml index 220fffcf6..68e5260b0 100644 --- a/stack-8.10.yaml +++ b/stack-8.10.yaml @@ -1,5 +1,4 @@ --- - resolver: lts-18.28 flags: {} packages: diff --git a/stack-8.2.yaml b/stack-8.2.yaml deleted file mode 100644 index 80f381f47..000000000 --- a/stack-8.2.yaml +++ /dev/null @@ -1,5 +0,0 @@ -resolver: lts-11.19 -flags: {} -packages: - - location: '.' -extra-deps: [] diff --git a/stack-8.4.yaml b/stack-8.4.yaml deleted file mode 100644 index f75b485e0..000000000 --- a/stack-8.4.yaml +++ /dev/null @@ -1,5 +0,0 @@ -resolver: lts-12.5 -flags: {} -packages: - - location: '.' -extra-deps: [] diff --git a/stack-8.8.yaml b/stack-9.0.yaml similarity index 58% rename from stack-8.8.yaml rename to stack-9.0.yaml index 695193d87..3be543604 100644 --- a/stack-8.8.yaml +++ b/stack-9.0.yaml @@ -1,7 +1,6 @@ --- - -resolver: lts-16.5 +resolver: lts-19.33 flags: {} packages: - - '.' + - "." extra-deps: [] diff --git a/stack-9.4.yaml b/stack-9.4.yaml new file mode 100644 index 000000000..58ac959cd --- /dev/null +++ b/stack-9.4.yaml @@ -0,0 +1,6 @@ +--- +resolver: lts-21.25 +flags: {} +packages: + - "." +extra-deps: [] diff --git a/stack-8.6.yaml b/stack-9.6.yaml similarity index 53% rename from stack-8.6.yaml rename to stack-9.6.yaml index 9a4fa4322..3b4c1d267 100644 --- a/stack-8.6.yaml +++ b/stack-9.6.yaml @@ -1,5 +1,6 @@ -resolver: lts-14.27 +--- +resolver: lts-22.0 flags: {} packages: - - '.' + - "." extra-deps: [] diff --git a/stack.yaml b/stack.yaml deleted file mode 100644 index b8109e651..000000000 --- a/stack.yaml +++ /dev/null @@ -1,6 +0,0 @@ ---- -resolver: lts-21.4 -flags: {} -packages: - - "." -extra-deps: [] diff --git a/stack.yaml b/stack.yaml new file mode 120000 index 000000000..7d0a245a1 --- /dev/null +++ b/stack.yaml @@ -0,0 +1 @@ +./stack-9.6.yaml \ No newline at end of file diff --git a/stack.yaml.lock b/stack.yaml.lock index 24d61c7a7..ff6601376 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -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