diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8e44fd9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,69 @@ +# SPDX-FileCopyrightText: Copyright Preetham Gujjula +# SPDX-License-Identifier: BSD-3-Clause + +name: CI +on: + push: + branches: + - '*' + pull_request: +jobs: + generate-matrix: + name: Generate matrix from cabal + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + runs-on: ubuntu-latest + steps: + - name: Extract the tested GHC versions + id: set-matrix + uses: kleidukos/get-tested@v0.1.7.0 + with: + cabal-file: primecount.cabal + ubuntu-version: latest + version: 0.1.7.0 + reuse_compliance_check: + name: REUSE compliance check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: REUSE Compliance Check + uses: fsfe/reuse-action@v3 + ormolu: + name: Ormolu check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: haskell-actions/run-ormolu@v16 + cabal_test: + name: cabal test - ghc-${{ matrix.ghc }} + needs: generate-matrix + runs-on: ubuntu-latest + continue-on-error: false + strategy: + matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }} + fail-fast: false + steps: + - uses: actions/checkout@v4 + - name: Install primecount C library + run: sudo apt-get install libprimecount-dev + - uses: haskell-actions/setup@v2 + with: + ghc-version: ${{ matrix.ghc }} + - name: Restore cache + uses: actions/cache@v4 + with: + path: ~/.cabal/store + key: ${{ runner.os }}-${{ matrix.ghc }}-${{ github.sha }} + restore-keys: ${{ runner.os }}-${{ matrix.ghc }} + - name: Run cabal configure + run: cabal configure + --enable-tests + --test-show-details=streaming + --enable-benchmarks + --ghc-options="-Werror -Wall" + - run: cabal update + - run: cabal outdated --exit-code --ignore=base + - run: cabal freeze + - run: cabal build + - run: cabal test + - run: cabal test --prefer-oldest diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml deleted file mode 100644 index 9a7113b..0000000 --- a/.github/workflows/haskell-ci.yml +++ /dev/null @@ -1,238 +0,0 @@ -# SPDX-FileCopyrightText: Copyright Preetham Gujjula -# SPDX-License-Identifier: BSD-3-Clause - -# This GitHub workflow config has been generated by a script via -# -# haskell-ci 'github' 'primecount.cabal' -# -# To regenerate the script (for example after adjusting tested-with) run -# -# haskell-ci regenerate -# -# For more information, see https://github.com/haskell-CI/haskell-ci -# -# version: 0.13.20211116 -# -# REGENDATA ("0.13.20211116",["github","primecount.cabal"]) -# -name: Haskell-CI -on: - - push - - pull_request -jobs: - linux: - name: Linux - ${{ matrix.compiler }} - runs-on: ubuntu-latest - timeout-minutes: - 60 - container: - image: buildpack-deps:jammy - continue-on-error: ${{ matrix.allow-failure }} - strategy: - matrix: - include: - - compiler: ghc-9.6.2 - compilerKind: ghc - compilerVersion: 9.6.2 - setup-method: ghcup - allow-failure: false - - compiler: ghc-9.4.5 - compilerKind: ghc - compilerVersion: 9.4.5 - setup-method: ghcup - allow-failure: false - - compiler: ghc-9.2.8 - compilerKind: ghc - compilerVersion: 9.2.8 - setup-method: ghcup - allow-failure: false - - compiler: ghc-9.0.2 - compilerKind: ghc - compilerVersion: 9.0.2 - setup-method: ghcup - allow-failure: false - - compiler: ghc-8.10.7 - compilerKind: ghc - compilerVersion: 8.10.7 - setup-method: ghcup - allow-failure: false - fail-fast: false - steps: - - name: apt - run: | - apt-get update - apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 - if [ "${{ matrix.setup-method }}" = ghcup ]; then - mkdir -p "$HOME/.ghcup/bin" - curl -sL https://downloads.haskell.org/ghcup/0.1.18.0/x86_64-linux-ghcup-0.1.18.0 > "$HOME/.ghcup/bin/ghcup" - chmod a+x "$HOME/.ghcup/bin/ghcup" - "$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" - "$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0 - else - apt-add-repository -y 'ppa:hvr/ghc' - apt-get update - apt-get install -y "$HCNAME" - mkdir -p "$HOME/.ghcup/bin" - curl -sL https://downloads.haskell.org/ghcup/0.1.17.3/x86_64-linux-ghcup-0.1.17.3 > "$HOME/.ghcup/bin/ghcup" - chmod a+x "$HOME/.ghcup/bin/ghcup" - "$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0 - fi - env: - HCKIND: ${{ matrix.compilerKind }} - HCNAME: ${{ matrix.compiler }} - HCVER: ${{ matrix.compilerVersion }} - - name: Set up primecount - run: | - apt-get install -y --no-install-recommends cmake - wget https://github.com/kimwalisch/primecount/archive/refs/tags/v7.2.tar.gz - tar -xvf v7.2.tar.gz - cd primecount-7.2 - cmake . -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF - make -j - PRIMECOUNT_DIR=$(readlink -f .) - echo "PRIMECOUNT_DIR=$PRIMECOUNT_DIR" >> "$GITHUB_ENV" - - name: Set PATH and environment variables - run: | - echo "$HOME/.cabal/bin" >> $GITHUB_PATH - echo "LANG=C.UTF-8" >> "$GITHUB_ENV" - echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV" - echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV" - HCDIR=/opt/$HCKIND/$HCVER - if [ "${{ matrix.setup-method }}" = ghcup ]; then - HC=$HOME/.ghcup/bin/$HCKIND-$HCVER - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV" - echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV" - echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV" - else - HC=$HCDIR/bin/$HCKIND - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV" - echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV" - echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV" - fi - - HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))') - echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV" - echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV" - echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV" - echo "HEADHACKAGE=false" >> "$GITHUB_ENV" - echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV" - echo "GHCJSARITH=0" >> "$GITHUB_ENV" - echo "LD_LIBRARY_PATH=$PRIMECOUNT_DIR" >> "$GITHUB_ENV" - env: - HCKIND: ${{ matrix.compilerKind }} - HCNAME: ${{ matrix.compiler }} - HCVER: ${{ matrix.compilerVersion }} - - name: env - run: | - env - - name: write cabal config - run: | - mkdir -p $CABAL_DIR - cat >> $CABAL_CONFIG <> $CABAL_CONFIG < cabal-plan.xz - echo 'de73600b1836d3f55e32d80385acc055fd97f60eaa0ab68a755302685f5d81bc cabal-plan.xz' | sha256sum -c - - xz -d < cabal-plan.xz > $HOME/.cabal/bin/cabal-plan - rm -f cabal-plan.xz - chmod a+x $HOME/.cabal/bin/cabal-plan - cabal-plan --version - - name: checkout - uses: actions/checkout@v3 - with: - path: source - - name: initial cabal.project for sdist - run: | - touch cabal.project - echo "packages: $GITHUB_WORKSPACE/source/." >> cabal.project - cat cabal.project - - name: sdist - run: | - mkdir -p sdist - $CABAL sdist all --output-dir $GITHUB_WORKSPACE/sdist - - name: unpack - run: | - mkdir -p unpacked - find sdist -maxdepth 1 -type f -name '*.tar.gz' -exec tar -C $GITHUB_WORKSPACE/unpacked -xzvf {} \; - - name: generate cabal.project - run: | - PKGDIR_primecount="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/primecount-[0-9.]*')" - echo "PKGDIR_primecount=${PKGDIR_primecount}" >> "$GITHUB_ENV" - rm -f cabal.project cabal.project.local - touch cabal.project - touch cabal.project.local - echo "packages: ${PKGDIR_primecount}" >> cabal.project - echo "package primecount" >> cabal.project - echo " ghc-options: -Werror=missing-methods" >> cabal.project - cat >> cabal.project <> cabal.project.local - cat cabal.project - cat cabal.project.local - - name: dump install plan - run: | - $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all - cabal-plan - - name: cache - uses: actions/cache@v3 - with: - key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }} - path: ~/.cabal/store - restore-keys: ${{ runner.os }}-${{ matrix.compiler }}- - - name: install dependencies - run: | - $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --dependencies-only -j2 all - $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dependencies-only -j2 all - - name: build w/o tests - run: | - $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all - - name: build - run: | - $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always - - name: tests - run: | - $CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct - - name: cabal check - run: | - cd ${PKGDIR_primecount} || false - ${CABAL} -vnormal check - - name: haddock - run: | - $CABAL v2-haddock $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all - - name: unconstrained build - run: | - rm -f cabal.project.local - $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all diff --git a/README.md b/README.md index 3e6a3e8..8aa7bd2 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ SPDX-License-Identifier: BSD-3-Clause --> # `primecount` for Haskell -[![Haskell-CI](https://github.com/pgujjula/primecount-haskell/actions/workflows/haskell-ci.yml/badge.svg)](https://github.com/pgujjula/primecount-haskell/actions/workflows/haskell-ci.yml) +[![CI](https://github.com/pgujjula/primecount-haskell/actions/workflows/ci.yml/badge.svg)](https://github.com/pgujjula/primecount-haskell/actions/workflows/ci.yml) [![REUSE status](https://api.reuse.software/badge/github.com/pgujjula/primecount-haskell)](https://api.reuse.software/info/github.com/pgujjula/primecount-haskell) This library provides Haskell bindings to Kim Walisch's