Skip to content

Commit

Permalink
Merge pull request #817 from GaloisInc/actions/github-actions
Browse files Browse the repository at this point in the history
Implement github actions.
  • Loading branch information
Jared Weakly authored Aug 19, 2020
2 parents b20c90a + 4035491 commit 3fce7d1
Show file tree
Hide file tree
Showing 10 changed files with 550 additions and 39 deletions.
7 changes: 7 additions & 0 deletions .github/PropertiesTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class PropertiesTest {
public static void main(String[] args)
throws Exception {
String value = System.getProperty("sun.boot.class.path");
System.out.println(value);
}
}
169 changes: 169 additions & 0 deletions .github/ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
#!/usr/bin/env bash
set -Eeuo pipefail

[[ "$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; }

extract_exe() {
exe="$(cabal v2-exec which "$1$EXT")"
name="$(basename "$exe")"
echo "Copying $name to $2"
mkdir -p "$2"
cp -f "$exe" "$2/$name"
$IS_WIN || chmod +x "$2/$name"
}

retry() {
echo "Attempting with retry:" "$@"
local n=1
while true; do
if "$@"; then
break
else
if [[ $n -lt 3 ]]; then
sleep $n # don't retry immediately
((n++))
echo "Command failed. Attempt $n/3:"
else
echo "The command has failed after $n attempts."
return 1
fi
fi
done
}

setup_dist_bins() {
is_exe "dist/bin" "saw" && is_exe "dist/bin" "jss" && return
extract_exe "saw" "dist/bin"
extract_exe "jss" "dist/bin"
export PATH=$PWD/dist/bin:$PATH
echo "::add-path::$PWD/dist/bin"
strip dist/bin/saw* || echo "Strip failed: Ignoring harmless error"
strip dist/bin/jss* || echo "Strip failed: Ignoring harmless error"
}

install_z3() {
is_exe "$BIN" "z3" && return

case "$RUNNER_OS" in
Linux) file="ubuntu-16.04.zip" ;;
macOS) file="osx-10.14.6.zip" ;;
Windows) file="win.zip" ;;
esac
curl -o z3.zip -sL "https://github.com/Z3Prover/z3/releases/download/z3-$Z3_VERSION/z3-$Z3_VERSION-x64-$file"

if $IS_WIN; then 7z x -bd z3.zip; else unzip z3.zip; fi
cp z3-*/bin/z3$EXT $BIN/z3$EXT
$IS_WIN || chmod +x $BIN/z3
rm z3.zip
}

install_cvc4() {
is_exe "$BIN" "cvc4" && return
version="${CVC4_VERSION#4.}" # 4.y.z -> y.z

case "$RUNNER_OS" in
Linux) file="x86_64-linux-opt" ;;
Windows) file="win64-opt.exe" ;;
macOS) file="macos-opt" ;;
esac
curl -o cvc4$EXT -sL "https://github.com/CVC4/CVC4/releases/download/$version/cvc4-$version-$file"
$IS_WIN || chmod +x cvc4$EXT
mv cvc4$EXT "$BIN/cvc4$EXT"
}

install_yices() {
is_exe "$BIN" "yices" && return
ext=".tar.gz"
case "$RUNNER_OS" in
Linux) file="pc-linux-gnu-static-gmp.tar.gz" ;;
macOS) file="apple-darwin18.7.0-static-gmp.tar.gz" ;;
Windows) file="pc-mingw32-static-gmp.zip" && ext=".zip" ;;
esac
curl -o "yices$ext" -sL "https://yices.csl.sri.com/releases/$YICES_VERSION/yices-$YICES_VERSION-x86_64-$file"

if $IS_WIN; then
7z x -bd "yices$ext"
mv "yices-$YICES_VERSION"/bin/*.exe "$BIN"
else
tar -xzf "yices$ext"
pushd "yices-$YICES_VERSION" || exit
sudo ./install-yices
popd || exit
fi
rm -rf "yices$ext" "yices-$YICES_VERSION"
}

install_yasm() {
is_exe "$BIN" "yasm" && return
if [[ "$RUNNER_OS" = "Linux" ]]; then
sudo apt-get update -q && sudo apt-get install -y yasm
else
brew install yasm
fi
}

build() {
ghc_ver="$(ghc --numeric-version)"
cp cabal.GHC-"$ghc_ver".config cabal.project.freeze
cabal v2-update
# Limit jobs on windows due to: https://gitlab.haskell.org/ghc/ghc/issues/17926
if [[ "$ghc_ver" =~ 8.8.3|8.10.1 && $IS_WIN ]]; then JOBS=1; else JOBS=2; fi
cabal v2-configure -j$JOBS --minimize-conflict-set
tee -a cabal.project > /dev/null < cabal.project.ci
retry cabal v2-build "$@" saw jss
}

build_abc() {
arch=X86_64
case "$RUNNER_OS" in
Linux) os="Linux" ;;
macOS) os="OSX" ;;
Windows) return ;;
esac
pushd deps/abcBridge
$IS_WIN || scripts/build-abc.sh $arch $os
popd
}

install_system_deps() {
install_z3 &
install_cvc4 &
install_yices &
install_yasm &
wait
export PATH=$PWD/$BIN:$PATH
echo "::add-path::$PWD/$BIN"
is_exe "$BIN" z3 && is_exe "$BIN" cvc4 && is_exe "$BIN" yices && is_exe "$BIN" yasm
}

test_dist() {
# To be replaced with a working implementation
# Copied from legacy CI
setup_dist_bins
find_java
pushd intTests
for t in test0001 test0019_jss_switch_statement test_crucible_jvm test_ecdsa test_examples test_issue108 test_tutorial1 test_tutorial2 test_tutorial_w4; do echo $t >> disabled_tests.txt; done
LOUD=true ./runtests.sh
sh -c "! grep '<failure>' results.xml"
}

find_java() {
pushd .github
javac PropertiesTest.java
RT_JAR="$(java PropertiesTest | tr : '\n' | grep rt.jar | head -n 1)"
export RT_JAR
echo "::set-env name=RT_JAR::$RT_JAR"
rm PropertiesTest.class
popd
}

COMMAND="$1"
shift

"$COMMAND" "$@"
77 changes: 77 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: SAWScript
on:
push:
branches: [master]
pull_request:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
ghc: ["8.6.5", "8.8.3"]
include:
- os: macos-latest
ghc: 8.6.5
continue-on-error: true
- os: macos-latest
ghc: 8.8.3
continue-on-error: true
name: SAWScript - GHC v${{ matrix.ghc }} - ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- run: |
git submodule update --init
git -C deps/abcBridge submodule update --init
- uses: actions/setup-haskell@v1
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc }}
enable-stack: true

- uses: actions/cache@v2
name: Cache cabal store
with:
path: |
${{ steps.setup-haskell.outputs.cabal-store }}
dist-newstyle
key: cabal-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('**/cabal.GHC-*') }}-${{ github.sha }}
restore-keys: |
cabal-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('**/cabal.GHC-*') }}-
cabal-${{ runner.os }}-${{ matrix.ghc }}-
- shell: bash
run: .github/ci.sh build_abc

- shell: bash
run: .github/ci.sh build

- shell: bash
run: .github/ci.sh install_system_deps
env:
Z3_VERSION: "4.8.7"
CVC4_VERSION: "4.1.8"
YICES_VERSION: "2.6.2"

- uses: actions/setup-java@v1
with:
java-version: "8"
java-package: jdk
architecture: x64

- shell: bash
id: test
continue-on-error: ${{ matrix.continue-on-error }}
name: Test
run: |
mkdir -p ~/.stack
echo "system-ghc: true" >> ~/.stack/config.yaml
.github/ci.sh test_dist
- shell: bash
if: "steps.test.outcome == 'failure'"
name: Warn if tests failed
run: echo "::error ::Test Suite Failed. Pipeline allowed to pass until tests are reliable."
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ stack.yaml
.DS_Store
.ghc.environment*
.class
*.class
dist-newstyle
cabal.project.freeze
*~
*#
.#*
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ script:
# Ideally, we'd like to pass --ghc-options=-Werror to cabal build.
# However, this currently enables -Werror for all dependencies as well.
# See: https://github.com/haskell/cabal/issues/3883
- cabal new-build --project-file=cabal.project.ci -j saw jss
- cp `cabal new-exec --project-file=cabal.project.ci --verbose=silent -- sh -c 'which saw'` bin
- cp `cabal new-exec --project-file=cabal.project.ci --verbose=silent -- sh -c 'which jss'` bin
- tee -a cabal.project > /dev/null < cabal.project.ci
- cabal new-build -j saw jss
- cp `cabal new-exec --verbose=silent -- sh -c 'which saw'` bin
- cp `cabal new-exec --verbose=silent -- sh -c 'which jss'` bin

jobs:
include:
Expand Down Expand Up @@ -112,4 +113,3 @@ jobs:
name: hmac failure
before_script:
- export TESTS=sawHMACFailure

1 change: 0 additions & 1 deletion cabal.project.freeze → cabal.GHC-8.6.5.config
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ constraints: any.Cabal ==2.4.0.1,
any.hedgehog ==1.0.2,
any.heredoc ==0.2.0.0,
any.hpc ==0.6.0.3,
any.hsc2hs ==0.68.7,
hsc2hs -in-ghc-tree,
any.hspec ==2.7.1,
any.hspec-core ==2.7.1,
Expand Down
Loading

0 comments on commit 3fce7d1

Please sign in to comment.