diff --git a/.github/workflows/packcheck.yml b/.github/workflows/packcheck.yml index 792ddc7..edd0157 100644 --- a/.github/workflows/packcheck.yml +++ b/.github/workflows/packcheck.yml @@ -1,113 +1,351 @@ -name: Haskell CI +# packcheck-0.7.1 +# You can use any of the options supported by packcheck as environment +# variables here. See https://github.com/composewell/packcheck for all +# options and their explanation. + +name: TEST + +#----------------------------------------------------------------------------- +# Events on which the build should be triggered +#----------------------------------------------------------------------------- on: + workflow_dispatch: + pull_request: push: branches: - master - pull_request: + +#----------------------------------------------------------------------------- +# Build matrix +#----------------------------------------------------------------------------- jobs: build: - name: ${{ matrix.name }} + name: >- + ${{ matrix.runner }} + ${{ matrix.command }} + ${{ matrix.ghc_version }} + ${{ matrix.name }} env: # ------------------------------------------------------------------------ # Common options # ------------------------------------------------------------------------ CABAL_REINIT_CONFIG: y LC_ALL: C.UTF-8 - DISABLE_SDIST_BUILD: y + + # ------------------------------------------------------------------------ + # What to build + # ------------------------------------------------------------------------ + # DISABLE_TEST: "y" + # DISABLE_BENCH: "y" + # DISABLE_DOCS: "y" + # DISABLE_SDIST_BUILD: "y" + # DISABLE_SDIST_GIT_CHECK: "y" + # DISABLE_DIST_CHECKS: "y" + + # ------------------------------------------------------------------------ + # Selecting tool versions + # ------------------------------------------------------------------------ + # For updating see: https://downloads.haskell.org/~ghcup/ + GHCUP_VERSION: 0.1.50.2 + GHCVER: ${{ matrix.ghc_version }} # ------------------------------------------------------------------------ # cabal options # ------------------------------------------------------------------------ CABAL_CHECK_RELAX: y - CABAL_NO_SANDBOX: y - # CABAL_PROJECT: cabal.project.user + + # CABAL_BUILD_OPTIONS="-j1" + # Enable the above option if you: + # 1. want logs in serial order to be able to correlate them better. + # + # 2. run into memory issues due to Build paralellism. We need to + # have sufficient per CPU memory, if not we can use a lower -j + # option; cabal default is ncpus. + # + # Currently (2026-03-12) from packcheck output we see: + # Linux: 15GB, 4 cpus + # macOS: 7GB, 3 cpus + # Windows: 16GB, 4 cpus # ------------------------------------------------------------------------ - # Location of packcheck.sh + # stack options (if using stack builds) # ------------------------------------------------------------------------ - PACKCHECK_LOCAL_PATH: "./packcheck.sh" + # Note requiring a specific version of stack using STACKVER may fail due to + # github API limit while checking and upgrading/downgrading to the specific + # version. + #STACKVER: "1.6.5" + #STACK_UPGRADE: "y" + STACK_YAML: "stack.yaml" + + # ------------------------------------------------------------------------ + # Location of packcheck.sh (the shell script invoked to perform CI tests ). + # ------------------------------------------------------------------------ + # You can either commit the packcheck.sh script at this path in your repo or + # you can use it by specifying the PACKCHECK_REPO_URL option below in which + # case it will be automatically copied from the packcheck repo to this path + # during CI tests. In any case it is finally invoked from this path. + PACKCHECK: "./packcheck.sh" + # If you have not committed packcheck.sh in your repo at PACKCHECK + # then it is automatically pulled from this URL. PACKCHECK_GITHUB_URL: "https://raw.githubusercontent.com/composewell/packcheck" - PACKCHECK_GITHUB_COMMIT: "v0.6.0" + PACKCHECK_GITHUB_COMMIT: "3d3c94bf48f18a99271d509c1f1702d15824b1f0" # ------------------------------------------------------------------------ - # Build options + # Final build variables # ------------------------------------------------------------------------ - BUILD: cabal-v2 ${{ matrix.pack_options }} - GHCVER: ${{ matrix.ghc_version }} + PACKCHECK_COMMAND: ${{ matrix.command }} ${{ matrix.pack_options }} + # Subdir + SUBDIR: ${{ matrix.subdir }} + # ubuntu seems to have better support than debian on CI systems runs-on: ${{ matrix.runner }} + #continue-on-error: ${{ matrix.ignore_error }} strategy: fail-fast: false matrix: - name: - - 8.6.5 - - 8.8.4 - - 8.10.7+macos - - 9.0.1 - - 9.2.1 - - hlint + # The order of jobs is important to optimize fail-fast. + + # This section is to order the important jobs first especially for + # "fail-fast" so that these are the ones started first. + #name: + # - ci + + # The name of the CI is built using the name and other info from CI, + # therefore, the "name" field can be same for all tests here. + # + # The reason we have an explicit "name" field here is to force + # an additional config instead of adding to an existing config + # while adding additional configs. + # Look at + # for more info about adding matrix elements. + # Adding any element to the list will increase the number of matrix + # elements proportional to the cross product. include: - - name: 8.6.5 - ghc_version: 8.6.5 + #- name: ci + # runner: ubuntu-latest + # command: cabal + # ghc_version: head + # # The URL may change, to find a working URL go to https://gitlab.haskell.org/ghc/ghc/-/jobs/ + # # Find a debian10/11/12 job, click on a passed/failed status, at the + # # end of the output you will find the tar.xz name, put that tar + # # name after "raw/", and put the job name after "job=". + # # Also see https://github.com/mpickering/ghc-artefact-nix/blob/master/gitlab-artifact.nix + # # + # # May also use ghcup for installing ghc head version, use the + # # version "LatestNightly", and the following config: + # # ghcup config add-release-channel https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml + # # WARNING! cannot use # comments inside pack_options. + # pack_options: >- + # GHCUP_GHC_OPTIONS="-u https://gitlab.haskell.org/ghc/ghc/-/jobs/artifacts/master/raw/ghc-x86_64-linux-deb10-int_native-validate.tar.xz?job=x86_64-linux-deb10-int_native-validate" + # CABAL_PROJECT=cabal.project.ghc-head + # DISABLE_SDIST_BUILD="y" + + - name: ci runner: ubuntu-latest - cabal_version: 3.2 + command: cabal + ghc_version: 9.14.1 + # WARNING! cannot use # comments inside pack_options. + #pack_options: >- + # CABAL_PROJECT=cabal.project + + - name: ci + runner: macos-latest + command: cabal + ghc_version: 9.12.4 + # WARNING! cannot use # comments inside pack_options. + #pack_options: >- + # CABAL_PROJECT=cabal.project - - name: 8.8.4 - ghc_version: 8.8.4 + - name: ci runner: ubuntu-latest - cabal_version: 3.2 + command: cabal + ghc_version: 9.10.3 + # WARNING! cannot use # comments inside pack_options. + #pack_options: >- + # CABAL_PROJECT=cabal.project - - name: 9.0.1 - ghc_version: 9.0.1 + #- name: ghc-9.10.3 + # runner: ubuntu-latest + # command: stack + # # WARNING! cannot use # comments inside pack_options. + # pack_options: >- + # CABAL_PROJECT=cabal.project.user + # STACK_UPGRADE="y" + # DISABLE_SDIST_BUILD="y" + + - name: ci runner: ubuntu-latest - cabal_version: 3.2 + command: cabal + ghc_version: 9.8.4 + # WARNING! cannot use # comments inside pack_options. + #pack_options: >- + # CABAL_PROJECT=cabal.project - - name: hlint - ghc_version: 8.8.4 - pack_options: HLINT_OPTIONS="lint" HLINT_TARGETS="src" + - name: ci runner: ubuntu-latest - cabal_version: 3.2 + command: cabal + ghc_version: 9.6.3 + # WARNING! cannot use # comments inside pack_options. + #pack_options: >- + # CABAL_PROJECT=cabal.project - - name: 8.10.7+macos - ghc_version: 8.10.7 - runner: macos-latest - cabal_version: 3.2 + - name: ci + runner: windows-latest + command: cabal + ghc_version: 9.12.4 + # WARNING! cannot use # comments inside pack_options. + #pack_options: >- + # CABAL_PROJECT=cabal.project - - name: 9.2.1 - ghc_version: 9.2.1 + - name: ci runner: ubuntu-latest - cabal_version: 3.6 + command: hlint + # WARNING! cannot use # comments inside pack_options. + pack_options: >- + HLINT_VERSION=3.6.1 + HLINT_OPTIONS="lint" + HLINT_TARGETS="src" + #- name: docspec + # runner: ubuntu-latest + # command: cabal + # ghc_version: 9.12.4 + # # WARNING! cannot use # comments inside pack_options. + # pack_options: >- + # ENABLE_DOCSPEC="y" + # DOCSPEC_URL=https://github.com/phadej/cabal-extras/releases/download/cabal-docspec-0.0.0.20210111/cabal-docspec-0.0.0.20210111.xz + # DOCSPEC_OPTIONS="--timeout 60" + # CABAL_PROJECT=cabal.project + +#----------------------------------------------------------------------------- +# Usually you do need to change anything below, this is generic code for +# caching and running packcheck on Linux/Mac/Windows. +#----------------------------------------------------------------------------- steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - uses: haskell/actions/setup@v1 + # This should happen before cache restore. + - name: Remove ~/.ghcup symlink (non-Windows) + if: runner.os != 'Windows' + run: | + rm -f ~/.ghcup + + - name: Cache hackage package index (non-Windows) + uses: actions/cache@v4 + if: runner.os != 'Windows' + with: + path: | + ~/.cache/cabal/packages + # Bump the key version to clear the cache + key: cache-cabal-packages + + # See the "cabal path" output in the CI logs to tweak the cache locations + # ghc is big but cheap to install, if cache size is a concern we can avoid + # caching it. + - name: Cache ghcup and ghc (non-Windows) + uses: actions/cache@v4 + if: runner.os != 'Windows' + with: + path: | + ~/.ghcup + key: ${{ matrix.runner }}-${{ matrix.ghc_version }}.${{ matrix.ghc_salt}} + + # XXX If we want to invalidate the cache on resolver change we + # should use a separate cache for stack as it should be keyed on + # resolver as well. But that requires resolver as a matrix element + # and then copied to pack_options from there, needs some work. It + # should be fine as resolver minor version change can only increase + # the cache size. + - name: Cache build dependencies (non-Windows) + uses: actions/cache@v4 + if: runner.os != 'Windows' with: - ghc-version: ${{ matrix.ghc_version }} - cabal-version: ${{ matrix.cabal_version }} + # cabal: ~/.local/bin, ~/.local/state/cabal + # ~/.cache/cabal/packages can be cached, but will increase the + # cache size. But can save the "cabal update" time. + path: | + ~/.local/bin + ~/.local/state/cabal + ~/.stack + # Bump the key version to clear the cache + key: ${{ matrix.runner }}-${{ matrix.command }}-${{ matrix.ghc_version }}-${{ matrix.name }}-v1 - - uses: actions/cache@v4 - name: Cache ~/.cabal + - name: Cache common directories (Windows) + uses: actions/cache@v4 + if: runner.os == 'Windows' with: - path: ~/.cabal - key: ${{ runner.os }}-${{ matrix.ghc_version }}-cabal + path: | + ${{ env.APPDATA }}/local + C:/ghcup + C:/cabal + key: ${{ matrix.runner }}-${{ matrix.command }}-${{ matrix.ghc_version }}-${{ matrix.name }}-v1 - name: Download packcheck + # on windows-latest GitHub Actions defaults to PowerShell + shell: bash run: | - # If a custom stack-yaml is specified, replace the default with that - if test -e "$STACK_YAML"; then rm -f stack.yaml && ln -sv $STACK_YAML stack.yaml; else true; fi - unset STACK_YAML - - # Get packcheck if needed - CURL=$(which curl) - PACKCHECK_URL=${PACKCHECK_GITHUB_URL}/${PACKCHECK_GITHUB_COMMIT}/packcheck.sh - if test ! -e "$PACKCHECK_LOCAL_PATH"; then $CURL -sL -o "$PACKCHECK_LOCAL_PATH" $PACKCHECK_URL; fi; - chmod +x $PACKCHECK_LOCAL_PATH + if test ! -e "$PACKCHECK" + then + if test -z "$PACKCHECK_GITHUB_COMMIT" + then + die "PACKCHECK_GITHUB_COMMIT env var is not specified." + fi + PACKCHECK_URL=${PACKCHECK_GITHUB_URL}/${PACKCHECK_GITHUB_COMMIT}/packcheck.sh + curl --fail -sL -o "$PACKCHECK" $PACKCHECK_URL || exit 1 + chmod +x $PACKCHECK + elif test ! -x "$PACKCHECK" + then + chmod +x $PACKCHECK + fi - name: Run packcheck + # on windows-latest GitHub Actions defaults to PowerShell + shell: bash + run: | + if test -n "$SUBDIR" + then + mv "$PACKCHECK" "$SUBDIR/packcheck.sh" + # This is required otherwise dist-newstyle will be created in + # the top level directory as it is considered the working dir. + rm -f cabal.project + cd "$SUBDIR" + fi + # Commands like mount, sysctl for info require sbin + PATH_VAR=/bin:/usr/bin:/sbin:/usr/sbin + case "$(uname)" in + Linux) + # On Linux it defaults to /usr/local, during cache restore + # tar is unable to change permissions and restore fails. + export GHCUP_INSTALL_BASE_PREFIX=$HOME + ;; + CYGWIN*|MINGW*|MSYS*) + PATH_VAR="$PATH_VAR:/c/Program Files/7-Zip:/mingw64/bin" + ;; + esac + # Use "bash -c" instead of invoking directly to preserve quoted + # arguments in PACKCHECK_COMMAND e.g. DOCSPEC_OPTIONS="--timeout 60". + # Direct invocation would word-split on spaces inside quoted values. + echo "$PACKCHECK $PACKCHECK_COMMAND PATH=\"$PATH_VAR\"" + bash -c "$PACKCHECK $PACKCHECK_COMMAND PATH=\"$PATH_VAR\"" + + - name: Check cache locations + if: runner.os != 'Windows' run: | - bash -c "$PACKCHECK_LOCAL_PATH $BUILD" + # We want to see if it is a symlink; e.g. on github ~/.ghcup is a + # pre-existing symlink to /usr/local. + list="$HOME/.local/bin $HOME/.local/state/cabal $HOME/.ghcup $HOME/.stack" + for dir in $list; do + # macOS does not have --no-dereference option + if [ -L "$dir" ]; then + echo "$dir is a symlink -> $(readlink $dir)" + else + du -sh "$dir" 2>/dev/null || echo "$dir missing" + fi + done + echo + #ls -ld $list 2>/dev/null || true + ls -al $list 2>/dev/null || true diff --git a/.packcheck.ignore b/.packcheck.ignore index 06f164d..068de0c 100644 --- a/.packcheck.ignore +++ b/.packcheck.ignore @@ -1,3 +1,6 @@ .packcheck.ignore .github/workflows/packcheck.yml -cabal.project \ No newline at end of file +.gitignore +cabal.project.user +flake.lock +flake.nix diff --git a/default.nix b/default.nix deleted file mode 100644 index b6c8c54..0000000 --- a/default.nix +++ /dev/null @@ -1,54 +0,0 @@ -# CAUTION! a spelling mistake in arg string is ignored silently. -# -# To use ghc-8.10.7 -# nix-shell --argstr compiler "ghc8107" - -{ nixpkgs ? import (builtins.fetchTarball - "https://github.com/NixOS/nixpkgs/archive/refs/tags/22.11.tar.gz") { } -, compiler ? "default" }: -let - utils = let - src = fetchGit { - url = "git@github.com:composewell/composewell-haskell.git"; - ref = "master"; - }; - in (import "${src}/utils.nix") { inherit nixpkgs; }; - - haskellPackages = let - src = fetchGit { - url = "git@github.com:composewell/composewell-haskell.git"; - ref = "master"; - }; - in (import "${src}/haskellPackages.nix") { - inherit nixpkgs; - inherit compiler; - }; - - mkHaskellPackages = inShell: - haskellPackages.override (old: { - overrides = nixpkgs.lib.composeExtensions (old.overrides or (_: _: { })) - (with nixpkgs.haskell.lib; - self: super: { - packdiff = utils.local super "packdiff" ./. "" inShell; - streamly = - super.callHackageDirect - { pkg = "streamly"; - ver = "0.9.0"; - sha256 = "1ab5n253krgccc66j7ch1lx328b1d8mhkfz4szl913chr9pmbv3q"; - } {}; - streamly-core = - super.callHackageDirect - { pkg = "streamly-core"; - ver = "0.1.0"; - sha256 = "00lfgvicap41rxapzjcml0qxry1lx8501jarhjxrcpxy1plrb146"; - } {}; - streamly-process = utils.composewell super "streamly-process" - "d80b860d9d8ea98e4f7f63390442b3155c34dd08"; - }); - }); - - shellDrv = mkHaskellPackages true; - - shell = utils.mkShell shellDrv (p: [ p.packdiff ]) true; - -in if nixpkgs.lib.inNixShell then shell else (mkHaskellPackages false).packdiff diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..970b20d --- /dev/null +++ b/flake.lock @@ -0,0 +1,88 @@ +{ + "nodes": { + "basepkgs": { + "inputs": { + "basepkgs": "basepkgs_2", + "nixpkgs": "nixpkgs", + "nixpkgs-darwin": "nixpkgs-darwin" + }, + "locked": { + "lastModified": 1775312922, + "narHash": "sha256-V292VAXWHHN2Q6xKqs45BqSPego/jtEp+Pc8H/gneEU=", + "ref": "refs/heads/master", + "rev": "76420910d9c74e5fc1d92d680499c97e4f94e873", + "revCount": 118, + "type": "git", + "url": "ssh://git@github.com/composewell/streamly-packages" + }, + "original": { + "rev": "76420910d9c74e5fc1d92d680499c97e4f94e873", + "type": "git", + "url": "ssh://git@github.com/composewell/streamly-packages" + } + }, + "basepkgs_2": { + "locked": { + "lastModified": 1775305167, + "narHash": "sha256-BPBKbDZ9aoGOHDAeScwj/N4h2IHOLLRSJmSC3AXQZko=", + "owner": "composewell", + "repo": "nixpack", + "rev": "fc492c73877aeaa3bf9bec85d0eebc56036d53f9", + "type": "github" + }, + "original": { + "owner": "composewell", + "repo": "nixpack", + "rev": "fc492c73877aeaa3bf9bec85d0eebc56036d53f9", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1774106199, + "narHash": "sha256-US5Tda2sKmjrg2lNHQL3jRQ6p96cgfWh3J1QBliQ8Ws=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6c9a78c09ff4d6c21d0319114873508a6ec01655", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6c9a78c09ff4d6c21d0319114873508a6ec01655", + "type": "github" + } + }, + "nixpkgs-darwin": { + "locked": { + "lastModified": 1774106199, + "narHash": "sha256-US5Tda2sKmjrg2lNHQL3jRQ6p96cgfWh3J1QBliQ8Ws=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6c9a78c09ff4d6c21d0319114873508a6ec01655", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6c9a78c09ff4d6c21d0319114873508a6ec01655", + "type": "github" + } + }, + "root": { + "inputs": { + "basepkgs": "basepkgs", + "nixpkgs": [ + "basepkgs", + "nixpkgs" + ], + "nixpkgs-darwin": [ + "basepkgs", + "nixpkgs-darwin" + ] + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..5482f54 --- /dev/null +++ b/flake.nix @@ -0,0 +1,19 @@ +{ + description = "Packdiff Development Environment"; + + inputs = { + basepkgs.url = "git+ssh://git@github.com/composewell/streamly-packages?rev=76420910d9c74e5fc1d92d680499c97e4f94e873"; + nixpkgs.follows = "basepkgs/nixpkgs"; + nixpkgs-darwin.follows = "basepkgs/nixpkgs-darwin"; + }; + + outputs = { self, nixpkgs, nixpkgs-darwin, basepkgs }: + basepkgs.nixpack.mkOutputs { + inherit nixpkgs nixpkgs-darwin basepkgs; + name = "packdiff"; + sources = basepkgs.nixpack.lib.localSource "packdiff" ./.; + packages = basepkgs.nixpack.lib.devPackage "packdiff"; + #sources = import ./sources.nix; + #packages = import ./packages.nix; + }; +} diff --git a/packdiff.cabal b/packdiff.cabal index 8c837a5..2c39309 100644 --- a/packdiff.cabal +++ b/packdiff.cabal @@ -15,7 +15,13 @@ maintainer: streamly@composewell.com copyright: 2022 Composewell Technologies -- category: build-type: Simple -extra-source-files: CHANGELOG.md +tested-with: + GHC==9.14.1 + , GHC==9.12.4 + , GHC==9.10.3 + , GHC==9.8.4 + , GHC==9.6.3 +extra-doc-files: README.md, CHANGELOG.md common compile-options default-language: Haskell2010 @@ -37,8 +43,8 @@ library , Diff , Pretty -- other-extensions: - build-depends: base >= 4.10 && < 4.22 - , streamly-core >= 0.1.0 + build-depends: base >= 4.10 && < 4.23 + , streamly-core >= 0.1.0 && < 0.4 , containers >= 0.6 && < 0.9 hs-source-dirs: src default-language: Haskell2010 @@ -49,7 +55,7 @@ executable packdiff -- other-extensions: build-depends: base , streamly-core - , streamly-process >= 0.3.1 + , streamly-process >= 0.3.1 && < 0.5 , packdiff , containers hs-source-dirs: cli