-
Notifications
You must be signed in to change notification settings - Fork 71
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
feat: solvers package #302
Changes from 22 commits
e56db6a
151a205
c364cf4
eca6dba
b103440
9baab5a
ef4354d
d709a22
794bdb1
fd0595f
fe20af6
f091994
87aa4b3
abe3ef8
a4666a6
e2125c4
b29f01a
9024483
edee71b
69772e5
4b77231
ba0fca5
fa55327
dcb5036
1321fc0
4a8485e
360427c
ed74102
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# based on https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-a-registry-using-a-personal-access-token | ||
name: Push solvers package | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- feat-packages | ||
|
||
# This creates an environment variable called `IMAGE_NAME ` with the value `solvers`. | ||
env: | ||
IMAGE_NAME: solvers | ||
|
||
# | ||
jobs: | ||
# This pushes the image to GitHub Packages. | ||
push: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
contents: read | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Build image | ||
run: docker build . --file packages/solvers/Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" | ||
|
||
- name: Log in to registry | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mattg-a16z just to double check, do you have any security concerns with this authentication method? |
||
|
||
- name: Push image | ||
run: | | ||
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME | ||
|
||
# This changes all uppercase characters to lowercase. | ||
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | ||
# This strips the git ref prefix from the version. | ||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
# This strips the "v" prefix from the tag name. | ||
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | ||
# This uses the Docker `latest` tag convention. | ||
[ "$VERSION" == "main" ] && VERSION=latest | ||
echo IMAGE_ID=$IMAGE_ID | ||
echo VERSION=$VERSION | ||
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION | ||
docker push $IMAGE_ID:$VERSION |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
FROM ubuntu:22.04 as builder | ||
|
||
# Install necessary packages | ||
RUN apt-get update && apt-get install --no-install-recommends -y \ | ||
curl \ | ||
git \ | ||
build-essential \ | ||
wget \ | ||
unzip \ | ||
autoconf \ | ||
libffi-dev \ | ||
cmake \ | ||
python3 \ | ||
python3-pip \ | ||
ninja-build \ | ||
software-properties-common \ | ||
g++ zlib1g-dev libboost-all-dev flex bison | ||
|
||
# Install Z3 | ||
COPY --from=ghcr.io/z3prover/z3:ubuntu-20.04-bare-z3-sha-770c51a /usr/bin/z3 /usr/local/bin/z3 | ||
|
||
# Install STP | ||
COPY --from=msoos/stp /usr/local/bin/stp /usr/local/bin/stp | ||
|
||
# Install Yices from the release binaries | ||
WORKDIR /yices | ||
ARG YICES_VERSION=2.6.4 | ||
RUN wget https://github.com/SRI-CSL/yices2/releases/download/Yices-2.6.4/yices-${YICES_VERSION}-x86_64-pc-linux-gnu.tar.gz -O yices.tar.gz && \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit : There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah you're right I missed a spot |
||
tar -xzvf yices.tar.gz --strip-components=1 && \ | ||
mv /yices/bin/* /usr/local/bin/ && \ | ||
mv /yices/lib/* /usr/local/lib/ && \ | ||
mv /yices/include/* /usr/local/include/ && \ | ||
rm -rf /yices | ||
|
||
# Install cvc5 from release binaries | ||
WORKDIR /cvc5 | ||
ARG CVC5_VERSION=1.1.2 | ||
RUN wget https://github.com/cvc5/cvc5/releases/download/cvc5-${CVC5_VERSION}/cvc5-Linux-static.zip -O cvc5-Linux-static.zip && \ | ||
unzip cvc5-Linux-static.zip && \ | ||
mv cvc5-Linux-static/bin/cvc5 /usr/local/bin/cvc5 && \ | ||
chmod +x /usr/local/bin/cvc5 && \ | ||
rm -rf /cvc5 | ||
|
||
# Install Bitwuzla | ||
WORKDIR /bitwuzla | ||
RUN git clone --depth 1 https://github.com/bitwuzla/bitwuzla . && \ | ||
pip3 install meson && \ | ||
./configure.py && \ | ||
cd build && \ | ||
ninja install && \ | ||
rm -rf /bitwuzla | ||
|
||
# Install Boolector | ||
WORKDIR /boolector | ||
RUN git clone --depth 1 https://github.com/boolector/boolector . && \ | ||
./contrib/setup-lingeling.sh && \ | ||
./contrib/setup-btor2tools.sh && \ | ||
./configure.sh && \ | ||
cd build && \ | ||
make && \ | ||
mv /boolector/build/bin/* /usr/local/bin/ && \ | ||
rm -rf /boolector | ||
|
||
# Create the final image | ||
FROM ubuntu:24.04 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: If there is no specific reason, it would be better to unify them. This can help streamline the build process and reduce potential compatibility issues. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasn't able to build yices on 24.04, but since we moved to binary releases it should be fine. I'll unify on 24.04 |
||
|
||
# Copy installed files from builder | ||
COPY --from=builder /usr/local/bin /usr/local/bin | ||
karmacoma-eth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Set the default command for the container | ||
WORKDIR /workspace | ||
CMD ["/bin/bash"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# solvers package | ||
|
||
A minimalist Docker image containing high-performance SMT solvers. | ||
|
||
## Quick start | ||
|
||
```sh | ||
# Step 1: Pull the image | ||
docker pull ghcr.io/a16z/solvers:latest | ||
|
||
# Step 2: Tag the image with a shorter name | ||
docker tag ghcr.io/a16z/solvers:latest solvers | ||
|
||
# Step 3: Run the container using the shorter name, | ||
for solver in bitwuzla boolector cvc5 stp yices z3 ; do \ | ||
echo --- $solver && \ | ||
docker run --rm solvers $solver --version ; \ | ||
done | ||
|
||
# Step 4: create an example smt2 file: | ||
cat << EOF > checkSanity.smt2 | ||
(set-logic QF_BV) | ||
(assert (= (bvsdiv (_ bv3 2) (_ bv2 2)) (_ bv0 2))) | ||
(check-sat) | ||
(exit) | ||
EOF | ||
|
||
# Step 5: invoke each solver on the file | ||
# (`-v .:/workspace` mounts the current working directory under /workspace on the container, making the files available there) | ||
for solver in bitwuzla boolector cvc5 stp yices-smt2 z3 ; do \ | ||
echo -n "$solver: " && \ | ||
docker run --rm -v .:/workspace solvers $solver checkSanity.smt2 ; \ | ||
done | ||
``` | ||
|
||
## Available solvers | ||
|
||
| Solver | Version | URL | Notes | ||
| ------ | ------- | --- | ----- | | ||
| Bitwuzla | 0.5.0-dev-main@50ce452 | [bitwuzla/bitwuzla](https://github.com/bitwuzla/bitwuzla) | Built from source | ||
| Boolector | 3.2.3 | [boolector/boolector](https://github.com/boolector/boolector) | Built from source | ||
| CVC5 | 1.1.2 | [cvc5/cvc5](https://github.com/cvc5/cvc5) | Installed from Github release binaries | ||
| STP | 2.3.3 | [stp/stp](https://github.com/stp/stp) | Provides a great Dockerfile that shows how to do a static build. We just copy the binary from the `msoos/stp` image since releases aren't too frequent. | | ||
| Yices | 2.6.4 | [SRI-CSL/yices2](https://github.com/SRI-CSL/yices2) | Installed from Github release binaries | ||
| Z3 | 4.13.1 | [Z3Prover/z3](https://github.com/Z3Prover/z3) | Includes a [Dockerfile](https://github.com/Z3Prover/z3/blob/master/docker/ubuntu-20-04.Dockerfile) and a package but no `latest` tag | | ||
|
||
|
||
## Credit | ||
|
||
Based on [EmperorOrokuSaki/solvers](https://github.com/EmperorOrokuSaki/solvers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is needed until the workflow is merged to
main
, can't manually dispatch from a branch