Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/haskell-nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Haskell CI with Nix

on:
push:
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
nix-ci:
runs-on: ubuntu-latest
env:
NIX_CONFIG: accept-flake-config = true

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Check Nix flake inputs
uses: DeterminateSystems/flake-checker-action@3164002371bc90729c68af0e24d5aacf20d7c9f6 # v12

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@c5a866b6ab867e88becbed4467b93592bce69f8a # v21

- name: Enable Nix cache
uses: DeterminateSystems/magic-nix-cache-action@565684385bcd71bad329742eefe8d12f2e765b39 # v13

- name: Show toolchain versions from nix shell
shell: bash
run: |
nix develop --command bash -lc 'ghc --numeric-version'
nix develop --command bash -lc 'cabal --numeric-version'
nix develop --command bash -lc 'stack --numeric-version || true'
nix develop --command bash -lc 'fourmolu --version'

- name: Check formatting
run: nix develop --command make format-check

- name: Check cabal file
run: nix develop --command make cabal-check

- name: Update cabal package index
run: nix develop --command make cabal-update

- name: Configure the build
run: nix develop --command make configure

- name: Build dependencies
run: nix develop --command make deps

- name: Build the package
run: nix develop --command make build

- name: Run tests
run: nix develop --command make test

- name: Build documentation
run: nix develop --command make docs
126 changes: 40 additions & 86 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,129 +2,83 @@ name: Haskell CI

on:
push:
branches:
- '*'
pull_request:
branches: [ "master" ]
workflow_dispatch:

permissions:
contents: read

jobs:
fourmolu:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: haskell-actions/run-fourmolu@v9
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- uses: haskell-actions/run-fourmolu@v11
with:
version: "0.14.0.0"
version: "0.17.0.0"

build:
name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
ghc-version: ['9.6', '9.4', '9.2', '9.0']
os: [ubuntu-latest, macos-latest, windows-latest]
ghc-version: ["9.6.7"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set up GHC ${{ matrix.ghc-version }}
uses: haskell/actions/setup@v2
uses: haskell-actions/setup@v2
id: setup
with:
ghc-version: ${{ matrix.ghc-version }}
enable-stack: true
cabal-version: "3.16.0.0"

- name: Installed minor versions of GHC, Cabal, and Stack
- name: Show toolchain versions
shell: bash
run: |
GHC_VERSION=$(ghc --numeric-version)
CABAL_VERSION=$(cabal --numeric-version)
STACK_VERSION=$(stack --numeric-version)
echo "GHC_VERSION=${GHC_VERSION}" >> "${GITHUB_ENV}"
echo "CABAL_VERSION=${CABAL_VERSION}" >> "${GITHUB_ENV}"
echo "STACK_VERSION=${STACK_VERSION}" >> "${GITHUB_ENV}"
ghc --numeric-version
cabal --numeric-version

- name: Check cabal file
run: cabal check

- name: Update cabal package index
run: cabal update

- name: Configure the build
run: |
# cabal configure --enable-tests --enable-benchmarks --disable-documentation
# cabal build --dry-run
stack build --test --bench --no-haddock --dry-run
# The last step generates dist-newstyle/cache/plan.json for the cache key.

- name: Restore .stack-work cache
uses: actions/cache/restore@v3
id: cache-restore-stack-work
with:
path: .stack-work
key: ${{ runner.os }}-ghc-${{ env.GHC_VERSION }}-stack-${{ env.STACK_VERSION }}-stack-work-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}-${{ hashFiles('**/*.hs') }}
restore-keys: |
${{ runner.os }}-ghc-${{ env.GHC_VERSION }}-stack-${{ env.STACK_VERSION }}-stack-work-

- name: Restore ~/.stack cache (Unix)
uses: actions/cache/restore@v3
id: cache-restore-stack-global-unix
if: runner.os == 'Linux' || runner.os == 'macOS'
with:
path: ~/.stack
key: ${{ runner.os }}-ghc-${{ env.GHC_VERSION }}-stack-${{ env.STACK_VERSION }}-stack-global-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}
restore-keys: |
${{ runner.os }}-ghc-${{ env.GHC_VERSION }}-stack-${{ env.STACK_VERSION }}-stack-global-
cabal configure --enable-tests --enable-benchmarks --disable-documentation
cabal build --dry-run

- name: Restore %APPDATA%\stack, %LOCALAPPDATA%\Programs\stack cache (Windows)
uses: actions/cache/restore@v3
id: cache-restore-stack-global-windows
if: runner.os == 'Windows'
- name: Restore cabal store cache
uses: actions/cache/restore@v4
id: cache-restore
with:
path: |
~\AppData\Roaming\stack
~\AppData\Local\Programs\stack
key: ${{ runner.os }}-ghc-${{ env.GHC_VERSION }}-stack-${{ env.STACK_VERSION }}-stack-global-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ runner.os }}-ghc-${{ matrix.ghc-version }}-cabal-${{ hashFiles('**/plan.json') }}
restore-keys: |
${{ runner.os }}-ghc-${{ env.GHC_VERSION }}-stack-${{ env.STACK_VERSION }}-stack-global-
${{ runner.os }}-ghc-${{ matrix.ghc-version }}-cabal-

- name: Build dependencies
run: stack build --only-dependencies

- name: Build the package
run: stack build
run: cabal build --only-dependencies

- name: Save .stack-work cache
uses: actions/cache/save@v3
id: cache-save-stack-work
if: steps.cache-restore-stack-work.outputs.cache-hit != 'true'
with:
path: .stack-work
key: ${{ steps.cache-restore-stack-work.outputs.cache-primary-key }}

- name: Save %APPDATA%\stack, %LOCALAPPDATA%\Programs\stack cache (Windows)
uses: actions/cache/save@v3
if: runner.os == 'Windows'
&& steps.cache-restore-stack-global-windows.outputs.cache-hit != 'true'
with:
path: |
~\AppData\Roaming\stack
~\AppData\Local\Programs\stack
key: ${{ steps.cache-restore-stack-global-windows.outputs.cache-primary-key }}

- name: Save ~/.stack cache (Unix)
uses: actions/cache/save@v3
id: cache-save-stack-global
if: (runner.os == 'Linux' || runner.os == 'macOS')
&& steps.cache-restore-stack-global-unix.outputs.cache-hit != 'true'
- name: Save cabal store cache
uses: actions/cache/save@v4
if: steps.cache-restore.outputs.cache-hit != 'true'
with:
path: ~/.stack
key: ${{ steps.cache-restore-stack-global-unix.outputs.cache-primary-key }}
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ steps.cache-restore.outputs.cache-primary-key }}

- name: Run tests
run: stack test
- name: Build the package
run: cabal build all

- name: Check cabal file
run: cabal check
- name: Run tests
run: cabal test all

- name: Build documentation
run: stack haddock
run: cabal haddock all --disable-documentation
43 changes: 43 additions & 0 deletions .github/workflows/update-flake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Update Nix Flake

on:
schedule:
# Every 2 weeks on Monday at 06:00 UTC
- cron: "0 6 1,15 * *"
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
update-flake:
runs-on: ubuntu-latest
env:
NIX_CONFIG: accept-flake-config = true

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@c5a866b6ab867e88becbed4467b93592bce69f8a # v21

- name: Enable Nix cache
uses: DeterminateSystems/magic-nix-cache-action@565684385bcd71bad329742eefe8d12f2e765b39 # v13

- name: Update flake lockfile
run: nix flake update

- name: Create Pull Request
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
with:
commit-message: "chore(nix): update flake lockfile"
title: "chore(nix): update flake lockfile"
body: |
Automated flake lockfile update via `nix flake update`.

This PR was created by the scheduled update-flake workflow.
Please review CI results before merging.
branch: automation/update-flake-lock
delete-branch: true
labels: dependencies, automated
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
*~
dist-*/
.vscode/*
.direnv/*
.envrc
cabal.project.local
18 changes: 18 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

## Unreleased changes

- **BREAKING CHANGE**: Restructured `VarDomain` type to support upper bounds
- Replaced `NonNegative`, `LowerBound SimplexNum`, and `Unbounded` constructors with
a single `Bounded { lowerBound :: Maybe SimplexNum, upperBound :: Maybe SimplexNum }` record
- Added smart constructors for convenience: `unbounded`, `nonNegative`, `lowerBoundOnly`,
`upperBoundOnly`, and `boundedRange`
- `Bounded Nothing Nothing` is equivalent to `Unbounded`
- `Bounded (Just 0) Nothing` is equivalent to `NonNegative`
- Upper bounds are now supported and automatically added as LEQ constraints
- Added `AddUpperBound` constructor to `VarTransform` for upper bound constraint generation
- Updated `getTransform` to return a list of transforms (can now generate both lower and upper bound transforms)
- Use Hspec for tests
- Add nix flake
- twoPhaseSimplex now takes a VarDomainMap (as the first param)
- You can specify each Var's domain using smart constructors: `nonNegative`, `unbounded`,
`lowerBoundOnly`, `upperBoundOnly`, or `boundedRange`
- If a VarDomain for a Var is undefined, it's assumed to be `unbounded`
- If you want to keep the same behaviour as before (all vars non-negative), use `nonNegative` for all Vars

## [v0.2.0.0](https://github.com/rasheedja/LPPaver/tree/v0.2.0.0)

- Setup CI
Expand Down
43 changes: 43 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
HS_FILES := $(shell git ls-files '*.hs')

.PHONY: format
format:
@test -n "$(HS_FILES)" || { echo "No tracked .hs files found"; exit 0; }
fourmolu -i $(HS_FILES)

.PHONY: format-check
format-check:
@test -n "$(HS_FILES)" || { echo "No tracked .hs files found"; exit 0; }
fourmolu -m check $(HS_FILES)

.PHONY: cabal-check
cabal-check:
cabal check

.PHONY: cabal-update
cabal-update:
cabal update

.PHONY: configure
configure:
cabal configure --enable-tests --enable-benchmarks --disable-documentation
cabal build --dry-run

.PHONY: deps
deps:
cabal build --only-dependencies

.PHONY: build
build:
cabal build all

.PHONY: test
test:
cabal test all

.PHONY: docs
docs:
cabal haddock all --disable-documentation

.PHONY: ci
ci: format-check cabal-check cabal-update configure deps build test docs
Loading
Loading