Skip to content

Add a script that can be used to check release builds #759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
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/actions/check-release-builds/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: "Check release builds"
description: "Check release builds for public libraries in local packages"
inputs:
ghc-version:
required: true
description: "Version of GHC"
cabal-version:
required: true
description: "Version of cabal"
hackage-index-state:
required: true
description: "Timestamp for Hackage index"
cli-args:
required: true
description: "Command-line arguments for the check-release-builds script"
runs:
using: composite
steps:
- name: 🛠️ Install Haskell
uses: haskell-actions/setup@v2
id: setup-haskell
with:
ghc-version: ${{ inputs.ghc-version }}
cabal-version: ${{ inputs.cabal-version }}

- name: 💾 Restore Cabal dependencies
uses: actions/cache/restore@v4
if: ${{ !env.ACT }}
id: cache-cabal
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: check-release-builds-${{ runner.os }}-ghc-${{ steps.setup-haskell.outputs.ghc-version }}-cabal-${{ steps.setup-haskell.outputs.cabal-version }}-input-state-${{ inputs.hackage-index-state }}

- name: 🛠️ Build Cabal dependencies
shell: sh
run: |
cabal build ./scripts/check-release-builds.hs \
${{ inputs.hackage-index-state && format('--index-state={0}', inputs.hackage-index-state) }} \
--only-dependencies

- name: 💾 Save Cabal dependencies
uses: actions/cache/save@v4
if: ${{ !env.ACT && steps.cache-cabal.outputs.cache-hit != 'true' }}
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ steps.cache-cabal.outputs.cache-primary-key }}

- name: 🏗️ Build
shell: sh
run: |
cabal build ./scripts/check-release-builds.hs \
${{ inputs.hackage-index-state && format('--index-state={0}', inputs.hackage-index-state) }}

- name: 🛠️ Check release builds
shell: sh
run: |
cabal run ./scripts/check-release-builds.hs \
${{ inputs.hackage-index-state && format('--index-state={0}', inputs.hackage-index-state) }} \
-- ${{ inputs.cli-args }}
123 changes: 123 additions & 0 deletions .github/workflows/check-release-builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Check release builds

on:
push:
branches:
- "main"
pull_request:
merge_group:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read

# Set the default shell on all platforms.
defaults:
run:
shell: sh

jobs:
################################################################################
# Build
################################################################################
build:
name: |
${{ format(
'Check release build on {0}{1}{2}',
startsWith(matrix.os, 'ubuntu-') && 'Linux' || startsWith(matrix.os, 'macOS-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows',
matrix.ghc-version && format(' with GHC {0}', matrix.ghc-version),
matrix.cabal-version && format(' and Cabal {0}', matrix.cabal-version)
)
}}
runs-on: ${{ matrix.os }}
timeout-minutes: 60

env:
full-run: ${{ github.event_name == 'workflow_dispatch' || matrix.ghc-version == '9.6' }}

steps:
- name: 📥 Checkout repository
if: ${{ env.full-run }}
uses: actions/checkout@v4

- name: 🗄️ Print Job info
if: ${{ env.full-run }}
run: |
echo 'matrix.os: ${{ matrix.os }}'
echo 'matrix.ghc-version: ${{ matrix.ghc-version }}'
echo 'matrix.cabal-version: ${{ matrix.cabal-version }}'
echo 'toJSON(matrix): ${{ toJSON(matrix) }}'

- name: 🛠️ Setup Haskell
if: ${{ env.full-run }}
id: setup-haskell
uses: haskell-actions/setup@v2
with:
ghc-version: ${{ matrix.ghc-version }}
cabal-version: ${{ matrix.cabal-version }}

- name: 🛠️ Setup system dependencies (Linux)
if: ${{ runner.os == 'Linux' && env.full-run }}
run: sudo apt-get update && sudo apt-get -y install liburing-dev librocksdb-dev
env:
DEBIAN_FRONTEND: "noninteractive"

- name: 🛠️ Configure
if: ${{ env.full-run }}
run: |
echo "packages: ./blockio/blockio.cabal ./lsm-tree.cabal" > cabal.project.temp
cabal configure \
--project-file="cabal.project.temp" \
--disable-tests \
--disable-benchmarks \
--index-state=HEAD \
--ghc-options="-Werror" \
cat "cabal.project.temp.local"

- name: 💾 Generate Cabal plan
if: ${{ env.full-run }}
run: |
cabal build all \
--project-file="cabal.project.temp" \
--dry-run

- name: 💾 Restore Cabal dependencies
uses: actions/cache/restore@v4
if: ${{ !env.ACT && env.full-run }}
id: cache-cabal
env:
key: check-release-build-${{ runner.os }}-ghc-${{ steps.setup-haskell.outputs.ghc-version }}-cabal-${{ steps.setup-haskell.outputs.cabal-version }}
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ env.key }}-plan-${{ hashFiles('dist-newstyle/cache/plan.json') }}
restore-keys: ${{ env.key }}-

- name: 🛠️ Build Cabal dependencies
if: ${{ env.full-run }}
run: |
cabal build all \
--project-file="cabal.project.temp" \
--only-dependencies

- name: 💾 Save Cabal dependencies
uses: actions/cache/save@v4
if: ${{ !env.ACT && steps.cache-cabal.outputs.cache-hit != 'true' && env.full-run }}
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ steps.cache-cabal.outputs.cache-primary-key }}

- name: 🏗️ Build
if: ${{ env.full-run }}
run: |
cabal build all \
--project-file="cabal.project.temp"

strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macOS-latest", "windows-latest"]
ghc-version: ["9.2", "9.4", "9.6", "9.8", "9.10", "9.12"]
cabal-version: ["3.12"]
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,26 @@ jobs:
- name: 🎗️ Lint with ShellCheck
run: ./scripts/lint-shellcheck.sh

################################################################################
# Check release builds
################################################################################
check-release-builds:
name: Check release builds
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout repository
uses: actions/checkout@v4

- name: 🛠️ Check release builds
uses: ./.github/actions/check-release-builds
with:
ghc-version: ${{ env.DEFAULT_GHC_VERSION }}
cabal-version: ${{ env.DEFAULT_CABAL_VERSION }}
hackage-index-state: "2025-06-16T00:00:00Z"
# Run without supplying any cabal files just to verify whether the
# script runs without problems.
cli-args: "Default"

################################################################################
# Publish documentation
################################################################################
Expand Down
13 changes: 7 additions & 6 deletions bloomfilter/examples/spell.hs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{-# LANGUAGE BangPatterns #-}
module Main (main) where

import Control.Monad (forM_, when)
import Control.Monad (forM_, unless, when)
import System.Environment (getArgs)

import qualified Data.BloomFilter as B

main :: IO ()
main = do
files <- getArgs
dictionary <- readFile "/usr/share/dict/words"
let !bloom = B.fromList (B.policyForFPR 0.01) (words dictionary)
forM_ files $ \file ->
putStrLn . unlines . filter (`B.notElem` bloom) . words
=<< readFile file
unless (null files) $ do
dictionary <- readFile "/usr/share/dict/words"
let !bloom = B.fromList (B.policyForFPR 0.01) (words dictionary)
forM_ files $ \file ->
putStrLn . unlines . filter (`B.notElem` bloom) . words
=<< readFile file
4 changes: 2 additions & 2 deletions bloomfilter/tests/fpr-calc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import qualified Data.IntSet as IntSet
import Data.List (unfoldr)
import Math.Regression.Simple
import System.Environment (getArgs)
import System.Exit (exitFailure)
import System.IO
import System.Random

Expand All @@ -29,7 +28,8 @@ main = do
["Regression"] -> main_regression
_ -> do
putStrLn "Usage: bloomfilter-fpr-calc [Generate|Regression]"
exitFailure
-- NOTE: we expicitly don't use exitFailure here because
-- @bloomfilter-fpr-calc@ is a cabal @test-suite@.

main_regression :: IO ()
main_regression = do
Expand Down
18 changes: 14 additions & 4 deletions lsm-tree.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -692,9 +692,14 @@ benchmark bloomfilter-bench
, lsm-tree:bloomfilter
, random

executable bloomfilter-fpr-calc
-- TODO: ideally this should be an executable because it's not really testing
-- anything, but if we make it an executable component then the solver takes the
-- build-depends into account when building the public library, which is not
-- desirable. Maybe these executables should be moved out into a separate
-- package?
test-suite bloomfilter-fpr-calc
import: language, warnings
scope: private
type: exitcode-stdio-1.0
hs-source-dirs: bloomfilter/tests
main-is: fpr-calc.hs
build-depends:
Expand All @@ -707,9 +712,14 @@ executable bloomfilter-fpr-calc

ghc-options: -threaded

executable bloomfilter-spell
-- TODO: ideally this should be an executable because it's not really testing
-- anything, but if we make it an executable component then the solver takes the
-- build-depends into account when building the public library, which is not
-- desirable. Maybe these executables should be moved out into a separate
-- package?
test-suite bloomfilter-spell
import: language
scope: private
type: exitcode-stdio-1.0
hs-source-dirs: bloomfilter/examples
main-is: spell.hs
build-depends:
Expand Down
Loading