Skip to content

Commit

Permalink
Basic GitHub Actions CI
Browse files Browse the repository at this point in the history
Fixes #34.
  • Loading branch information
RyanGlScott committed Mar 8, 2023
1 parent 276c498 commit d8dc402
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
set -Eeuxo pipefail

DATE=$(date "+%Y-%m-%d")
[[ "$RUNNER_OS" == 'Windows' ]] && IS_WIN=true || IS_WIN=false
BIN=bin
EXT=""
$IS_WIN && EXT=".exe"
mkdir -p "$BIN"

is_exe() { [[ -x "$1/$2$EXT" ]] || command -v "$2" > /dev/null 2>&1; }

install_llvm() {
if [[ "$RUNNER_OS" = "Linux" ]]; then
sudo apt-get update -q && sudo apt-get install -y clang-$LLVM_VERSION llvm-$LLVM_VERSION-tools
else
echo "$RUNNER_OS is not currently supported."
return 1
fi
echo "CLANG=clang-$LLVM_VERSION" >> "$GITHUB_ENV"
echo "LLVM_AS=llvm-as-$LLVM_VERSION" >> "$GITHUB_ENV"
echo "LLVM_LINK=llvm-link-$LLVM_VERSION" >> "$GITHUB_ENV"
}

install_solvers() {
(cd $BIN && curl -o bins.zip -sL "https://github.com/GaloisInc/what4-solvers/releases/download/$SOLVER_PKG_VERSION/$BUILD_TARGET_OS-bin.zip" && unzip -o bins.zip && rm bins.zip)
cp $BIN/yices_smt2$EXT $BIN/yices-smt2$EXT
chmod +x $BIN/*
}

install_system_deps() {
install_solvers
install_llvm
# wait
export PATH=$PWD/$BIN:$PATH
echo "$PWD/$BIN" >> $GITHUB_PATH
is_exe "$BIN" z3 && is_exe "$BIN" cvc4 && is_exe "$BIN" cvc5 && is_exe "$BIN" yices
}

COMMAND="$1"
shift

"$COMMAND" "$@"
83 changes: 83 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: copilot-verifier

on:
push:
branches: [main]
pull_request:

env:
SOLVER_PKG_VERSION: "snapshot-20221212"
# The CACHE_VERSION can be updated to force the use of a new cache if
# the current cache contents become corrupted/invalid. This can
# sometimes happen when (for example) the OS version is changed but
# older .so files are cached, which can have various effects
# (e.g. cabal complains it can't find a valid version of the "happy"
# tool).
CACHE_VERSION: 1
LLVM_VERSION: 12

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
ghc-version: ["8.10.7", "9.0.2", "9.2.7"]
cabal: [ '3.8.1.0' ]
steps:
- uses: actions/checkout@v2
with:
submodules: true

- uses: haskell/actions/setup@v1
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc-version }}
cabal-version: ${{ matrix.cabal }}

- uses: actions/cache/restore@v3
name: Restore cabal store cache
with:
path: |
${{ steps.setup-haskell.outputs.cabal-store }}
dist-newstyle
key: ${{ env.CACHE_VERSION }}-cabal-${{ matrix.os }}-${{ matrix.ghc-version }}-${{ hashFiles(format('cabal.GHC-{0}.config', matrix.ghc-version)) }}-${{ github.sha }}
restore-keys: |
${{ env.CACHE_VERSION }}-cabal-${{ matrix.os }}-${{ matrix.ghc-version }}-${{ hashFiles(format('cabal.GHC-{0}.config', matrix.ghc-version)) }}-
- shell: bash
name: Install system dependencies
run: .github/ci.sh install_system_deps
env:
BIN_ZIP_FILE: ${{ matrix.os }}-bin.zip
BUILD_TARGET_OS: ${{ matrix.os }}

- shell: bash
name: Update
run: cabal update

- shell: bash
name: Configure
run: cabal configure --enable-tests -j2 all

- shell: bash
name: Build copilot-verifier
run: cabal build pkg:copilot-verifier

- shell: bash
name: Build copilot-verifier-demo
run: cabal build pkg:copilot-verifier-demo

- shell: bash
name: Test copilot-verifier
run: cabal test pkg:copilot-verifier

- uses: actions/cache/save@v3
name: Save cabal store cache
if: always()
with:
path: |
${{ steps.setup-haskell.outputs.cabal-store }}
dist-newstyle
key: ${{ env.CACHE_VERSION }}-cabal-${{ matrix.os }}-${{ matrix.ghc-version }}-${{ hashFiles(format('cabal.GHC-{0}.config', matrix.ghc-version)) }}-${{ github.sha }}

0 comments on commit d8dc402

Please sign in to comment.