Skip to content

Commit d8dc402

Browse files
committed
Basic GitHub Actions CI
Fixes #34.
1 parent 276c498 commit d8dc402

File tree

2 files changed

+126
-0
lines changed

2 files changed

+126
-0
lines changed

.github/ci.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
set -Eeuxo pipefail
3+
4+
DATE=$(date "+%Y-%m-%d")
5+
[[ "$RUNNER_OS" == 'Windows' ]] && IS_WIN=true || IS_WIN=false
6+
BIN=bin
7+
EXT=""
8+
$IS_WIN && EXT=".exe"
9+
mkdir -p "$BIN"
10+
11+
is_exe() { [[ -x "$1/$2$EXT" ]] || command -v "$2" > /dev/null 2>&1; }
12+
13+
install_llvm() {
14+
if [[ "$RUNNER_OS" = "Linux" ]]; then
15+
sudo apt-get update -q && sudo apt-get install -y clang-$LLVM_VERSION llvm-$LLVM_VERSION-tools
16+
else
17+
echo "$RUNNER_OS is not currently supported."
18+
return 1
19+
fi
20+
echo "CLANG=clang-$LLVM_VERSION" >> "$GITHUB_ENV"
21+
echo "LLVM_AS=llvm-as-$LLVM_VERSION" >> "$GITHUB_ENV"
22+
echo "LLVM_LINK=llvm-link-$LLVM_VERSION" >> "$GITHUB_ENV"
23+
}
24+
25+
install_solvers() {
26+
(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)
27+
cp $BIN/yices_smt2$EXT $BIN/yices-smt2$EXT
28+
chmod +x $BIN/*
29+
}
30+
31+
install_system_deps() {
32+
install_solvers
33+
install_llvm
34+
# wait
35+
export PATH=$PWD/$BIN:$PATH
36+
echo "$PWD/$BIN" >> $GITHUB_PATH
37+
is_exe "$BIN" z3 && is_exe "$BIN" cvc4 && is_exe "$BIN" cvc5 && is_exe "$BIN" yices
38+
}
39+
40+
COMMAND="$1"
41+
shift
42+
43+
"$COMMAND" "$@"

.github/workflows/ci.yaml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: copilot-verifier
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
env:
9+
SOLVER_PKG_VERSION: "snapshot-20221212"
10+
# The CACHE_VERSION can be updated to force the use of a new cache if
11+
# the current cache contents become corrupted/invalid. This can
12+
# sometimes happen when (for example) the OS version is changed but
13+
# older .so files are cached, which can have various effects
14+
# (e.g. cabal complains it can't find a valid version of the "happy"
15+
# tool).
16+
CACHE_VERSION: 1
17+
LLVM_VERSION: 12
18+
19+
jobs:
20+
build:
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
os: [ubuntu-22.04]
26+
ghc-version: ["8.10.7", "9.0.2", "9.2.7"]
27+
cabal: [ '3.8.1.0' ]
28+
steps:
29+
- uses: actions/checkout@v2
30+
with:
31+
submodules: true
32+
33+
- uses: haskell/actions/setup@v1
34+
id: setup-haskell
35+
with:
36+
ghc-version: ${{ matrix.ghc-version }}
37+
cabal-version: ${{ matrix.cabal }}
38+
39+
- uses: actions/cache/restore@v3
40+
name: Restore cabal store cache
41+
with:
42+
path: |
43+
${{ steps.setup-haskell.outputs.cabal-store }}
44+
dist-newstyle
45+
key: ${{ env.CACHE_VERSION }}-cabal-${{ matrix.os }}-${{ matrix.ghc-version }}-${{ hashFiles(format('cabal.GHC-{0}.config', matrix.ghc-version)) }}-${{ github.sha }}
46+
restore-keys: |
47+
${{ env.CACHE_VERSION }}-cabal-${{ matrix.os }}-${{ matrix.ghc-version }}-${{ hashFiles(format('cabal.GHC-{0}.config', matrix.ghc-version)) }}-
48+
49+
- shell: bash
50+
name: Install system dependencies
51+
run: .github/ci.sh install_system_deps
52+
env:
53+
BIN_ZIP_FILE: ${{ matrix.os }}-bin.zip
54+
BUILD_TARGET_OS: ${{ matrix.os }}
55+
56+
- shell: bash
57+
name: Update
58+
run: cabal update
59+
60+
- shell: bash
61+
name: Configure
62+
run: cabal configure --enable-tests -j2 all
63+
64+
- shell: bash
65+
name: Build copilot-verifier
66+
run: cabal build pkg:copilot-verifier
67+
68+
- shell: bash
69+
name: Build copilot-verifier-demo
70+
run: cabal build pkg:copilot-verifier-demo
71+
72+
- shell: bash
73+
name: Test copilot-verifier
74+
run: cabal test pkg:copilot-verifier
75+
76+
- uses: actions/cache/save@v3
77+
name: Save cabal store cache
78+
if: always()
79+
with:
80+
path: |
81+
${{ steps.setup-haskell.outputs.cabal-store }}
82+
dist-newstyle
83+
key: ${{ env.CACHE_VERSION }}-cabal-${{ matrix.os }}-${{ matrix.ghc-version }}-${{ hashFiles(format('cabal.GHC-{0}.config', matrix.ghc-version)) }}-${{ github.sha }}

0 commit comments

Comments
 (0)