Skip to content

Commit

Permalink
Merge pull request #604 from conjure-cp/gh-action-updates
Browse files Browse the repository at this point in the history
Various updates to github actions and Dockerfile
  • Loading branch information
ozgurakgun committed Nov 9, 2023
2 parents bfa30a9 + 8e533c3 commit 58ba80c
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 45 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ on:
- Running all tests
types:
- completed
push: # for pushes to release tags (v*)
tags:
- "v*.*.*"
pull_request: # and for PRs that edit the docker files
paths:
- Dockerfile
Expand Down
67 changes: 47 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@ on:
workflow_dispatch: # can be triggered manually
push:
tags:
- 'v*'
- "v*.*.*"
pull_request: # and for PRs
paths:
- conjure-cp.cabal
- Makefile
- src/**
- tests/**
- etc/build/**
- etc/savilerow/**
- .github/workflows/release.yml
# other branches that want testing must create a PR

permissions:
contents: write
Expand Down Expand Up @@ -59,7 +69,7 @@ jobs:
- name: Setting PATH (for solvers)
shell: bash
run: |
echo "${HOME}/.local/bin" >> ${GITHUB_PATH}
echo "${HOME}/solver-binaries" >> ${GITHUB_PATH}
echo "/usr/lib/ccache" >> ${GITHUB_PATH}
echo "/usr/local/opt/ccache/libexec" >> ${GITHUB_PATH}
Expand All @@ -75,43 +85,60 @@ jobs:

- name: Build solvers
shell: bash
run: BIN_DIR=${HOME}/.local/bin PROCESSES=2 make solvers
run: |
rm -rf ${HOME}/solver-binaries
BIN_DIR=${HOME}/solver-binaries PROCESSES=2 make solvers
- name: Set version string to the commit hash
run: echo "RELEASE_VERSION=${{ github.sha }}" >> "$GITHUB_ENV"

- name: Set version string based on trigger (ref_name if on tag)
run: echo "RELEASE_VERSION=${{ github.ref_name }}" >> "$GITHUB_ENV"
if: startsWith(github.ref, 'refs/tags/')

- name: Set version string based on trigger (PR number if a PR)
run: echo "RELEASE_VERSION=${{ github.event.pull_request.number }}" >> "$GITHUB_ENV"
if: github.event_name == 'pull_request'

# when gecode comes back, this is the list
# conjure bc_minisat_all_release boolector cadical fzn-chuffed fzn-gecode glucose glucose-syrup kissat lingeling minion nbc_minisat_all_release open-wbo plingeling treengeling yices yices-sat yices-smt yices-smt2 z3
- name: Strip binaries
- name: Create the zip archives
shell: bash
run: |
pushd ~/.local/bin
pushd ${HOME}/solver-binaries
strip conjure bc_minisat_all_release boolector cadical fzn-chuffed glucose glucose-syrup kissat lingeling minion nbc_minisat_all_release open-wbo plingeling treengeling yices yices-sat yices-smt yices-smt2 z3
cp ~/.local/bin/conjure ~/.local/bin/savilerow ~/.local/bin/savilerow.jar .
mkdir -p lib
cp -r ~/.local/bin/lib/* lib/
mkdir -p conjure-${{ github.ref_name }}-${{ matrix.release_suffix }}
cp conjure conjure-${{ github.ref_name }}-${{ matrix.release_suffix }}
cd ..
rm -rf conjure-${RELEASE_VERSION}-${{ matrix.release_suffix }}-with-solvers
cp -r solver-binaries conjure-${RELEASE_VERSION}-${{ matrix.release_suffix }}-with-solvers
cd solver-binaries
cp -r ../conjure-${RELEASE_VERSION}-${{ matrix.release_suffix }}-with-solvers .
mkdir -p conjure-${{ github.ref_name }}-${{ matrix.release_suffix }}-with-solvers
cp conjure bc_minisat_all_release boolector cadical fzn-chuffed glucose glucose-syrup kissat lingeling minion nbc_minisat_all_release open-wbo plingeling treengeling yices yices-sat yices-smt yices-smt2 z3 conjure-${{ github.ref_name }}-${{ matrix.release_suffix }}-with-solvers
cp -r savilerow savilerow.jar lib conjure-${{ github.ref_name }}-${{ matrix.release_suffix }}-with-solvers
rm -rf conjure-${RELEASE_VERSION}-${{ matrix.release_suffix }}
mkdir conjure-${RELEASE_VERSION}-${{ matrix.release_suffix }}
cp conjure conjure-${RELEASE_VERSION}-${{ matrix.release_suffix }}
zip -r -9 conjure-${{ github.ref_name }}-${{ matrix.release_suffix }}.zip conjure-${{ github.ref_name }}-${{ matrix.release_suffix }}
zip -r -9 conjure-${{ github.ref_name }}-${{ matrix.release_suffix }}-with-solvers.zip conjure-${{ github.ref_name }}-${{ matrix.release_suffix }}-with-solvers
zip -r -9 conjure-${RELEASE_VERSION}-${{ matrix.release_suffix }}.zip conjure-${RELEASE_VERSION}-${{ matrix.release_suffix }}
zip -r -9 conjure-${RELEASE_VERSION}-${{ matrix.release_suffix }}-with-solvers.zip conjure-${RELEASE_VERSION}-${{ matrix.release_suffix }}-with-solvers
popd
cp ~/.local/bin/conjure-${{ github.ref_name }}-${{ matrix.release_suffix }}.zip .
cp ~/.local/bin/conjure-${{ github.ref_name }}-${{ matrix.release_suffix }}-with-solvers.zip .
cp ${HOME}/solver-binaries/conjure-${RELEASE_VERSION}-${{ matrix.release_suffix }}.zip .
cp ${HOME}/solver-binaries/conjure-${RELEASE_VERSION}-${{ matrix.release_suffix }}-with-solvers.zip .
# See https://github.com/softprops/action-gh-release
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${{ github.ref_name }}
name: ${RELEASE_VERSION}
draft: false
prerelease: false
generate_release_notes: true
files: |
conjure-${{ github.ref_name }}-${{ matrix.release_suffix }}.zip
conjure-${{ github.ref_name }}-${{ matrix.release_suffix }}-with-solvers.zip
conjure-${RELEASE_VERSION}-${{ matrix.release_suffix }}.zip
conjure-${RELEASE_VERSION}-${{ matrix.release_suffix }}-with-solvers.zip
1 change: 1 addition & 0 deletions .github/workflows/test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- src/**
- tests/**
- etc/build/**
- etc/savilerow/**
- .github/workflows/test-coverage.yml

jobs:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ on:
paths:
- conjure-cp.cabal
- Makefile
- Dockerfile # this is here because the docker-publish.yml depends on successful completion of this action
- src/**
- tests/**
- etc/build/**
- etc/savilerow
- etc/savilerow/**
- .github/workflows/test.yml
pull_request: # and for PRs
paths:
Expand All @@ -20,7 +21,7 @@ on:
- src/**
- tests/**
- etc/build/**
- etc/savilerow
- etc/savilerow/**
- .github/workflows/test.yml
# other branches that want testing must create a PR

Expand Down
13 changes: 4 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@ COPY . .
# Building Conjure and copying Savile Row
RUN make install

# Make binaries a bit smaller
RUN ls -l /root/.local/bin
RUN du -sh /root/.local/bin
RUN cd /root/.local/bin ; strip conjure bc_minisat_all_release boolector cadical fzn-chuffed fzn-ortools glucose glucose-syrup kissat lingeling minion nbc_minisat_all_release open-wbo plingeling treengeling yices yices-sat yices-smt yices-smt2 z3
# RUN cd /root/.local/bin ; strip conjure bc_minisat_all_release boolector cadical fzn-chuffed fzn-gecode fzn-ortools glucose glucose-syrup kissat lingeling minion nbc_minisat_all_release open-wbo plingeling treengeling yices yices-sat yices-smt yices-smt2 z3
# List the binaries
RUN ls -l /root/.local/bin
RUN du -sh /root/.local/bin

# a test to see if all solvers work as expected
RUN tests/allsolvers/test.sh


################################################################################
# Second stage: Copying the binaries
Expand All @@ -75,7 +74,3 @@ RUN apt-get update
RUN apt-get install -y --no-install-recommends default-jre-headless # savilerow
RUN mkdir -p /root/.local/bin/lib
COPY --from=builder /root/.local/bin /root/.local/bin

# Testing
CMD echo "find x : set of int(1..3)" > model.essence ; conjure solve model.essence --number-of-solutions=all ; cat model.solutions

10 changes: 5 additions & 5 deletions tests/allsolvers/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ echo ""
echo ""
echo "========================================"

echo "gecode"
conjure solve test.essence --solver gecode
echo ""
echo ""
echo "========================================"
# echo "gecode"
# conjure solve test.essence --solver gecode
# echo ""
# echo ""
# echo "========================================"

echo "chuffed"
conjure solve test.essence --solver chuffed
Expand Down
9 changes: 0 additions & 9 deletions tests/allsolvers/stdout.expected
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@ Running solver: minion
Copying solution to: test.solution


========================================
gecode
Using cached models.
Savile Row: model000001.eprime
Running minion for domain filtering.
Running solver: gecode
Copying solution to: test.solution


========================================
chuffed
Using cached models.
Expand Down
1 change: 1 addition & 0 deletions tests/allsolvers/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cd $DIR
if ! diff stdout stdout.expected; then
echo "The generated stdout doesn't match the expected stdout."
echo "That's what we call a failed test around here..."
exit 1
else
echo "Pass!"
fi
Expand Down

0 comments on commit 58ba80c

Please sign in to comment.