-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: rework CI script for more extensibility
Rework script for more flexibility and extensibility: * Run any command in a container with `--docker` or in the current environment without this parameter. * Split compiling circuits and producing constraint & table, because further work with proof market requires the constraint only. Run each command as a separate step in CI. * Use single script for all commands. New commands with the proof-market-toolchain will use the same syntax. The new script syntax is heavily inspired by https://github.com/NilFoundation/dbms/blob/master/scripts/ci.sh Follow-up to #5
- Loading branch information
1 parent
cb2d4cb
commit d64c5f9
Showing
4 changed files
with
101 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/usr/bin/env bash | ||
set -euxo pipefail | ||
|
||
# define dirs so that we can run scripts from any directory without shifting filesystem paths | ||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
REPO_ROOT="$SCRIPT_DIR/.." | ||
|
||
# podman is a safer option for using on CI machines | ||
if ! command -v podman; then | ||
DOCKER="docker" | ||
DOCKER_OPTS="" | ||
else | ||
DOCKER="podman" | ||
DOCKER_OPTS='--detach-keys= --userns=keep-id' | ||
fi | ||
|
||
# checking files that should be produced | ||
# on all steps of the pipeline | ||
check_file_exists() { | ||
FILE1="${1}" | ||
if [ ! -e "$FILE1" ] | ||
then | ||
echo "File $FILE1 was not created" >&2 | ||
exit 1 | ||
else | ||
echo "File $FILE1 created successfully" | ||
fi | ||
} | ||
|
||
compile() { | ||
if [ "$USE_DOCKER" = true ] ; then | ||
cd "$REPO_ROOT" | ||
$DOCKER run $DOCKER_OPTS \ | ||
--rm \ | ||
--platform=linux/amd64 \ | ||
--user $(id -u ${USER}):$(id -g ${USER}) \ | ||
--volume $(pwd):/opt/zkllvm-template \ | ||
ghcr.io/nilfoundation/zkllvm-template:latest \ | ||
sh -c "bash ./scripts/ci.sh compile" | ||
cd - | ||
else | ||
rm -rf "$REPO_ROOT/build" | ||
mkdir -p "$REPO_ROOT/build" | ||
cd "$REPO_ROOT/build" | ||
cmake -DCIRCUIT_ASSEMBLY_OUTPUT=TRUE .. | ||
make template | ||
cd - | ||
check_file_exists "$REPO_ROOT/build/src/template.ll" | ||
fi | ||
} | ||
|
||
run_assigner() { | ||
if [ "$USE_DOCKER" = true ] ; then | ||
cd "$REPO_ROOT" | ||
$DOCKER run $DOCKER_OPTS \ | ||
--rm \ | ||
--platform=linux/amd64 \ | ||
--user $(id -u ${USER}):$(id -g ${USER}) \ | ||
--volume $(pwd):/opt/zkllvm-template \ | ||
ghcr.io/nilfoundation/zkllvm-template:latest \ | ||
sh -c "bash ./scripts/ci.sh run_assigner" | ||
cd - | ||
else | ||
cd "$REPO_ROOT/build" | ||
assigner \ | ||
-b src/template.ll \ | ||
-i ../src/main.inp \ | ||
-c template.crct \ | ||
-t template.tbl \ | ||
-e pallas | ||
cd - | ||
check_file_exists "$REPO_ROOT/build/template.crct" | ||
check_file_exists "$REPO_ROOT/build/template.tbl" | ||
fi | ||
} | ||
|
||
|
||
USE_DOCKER=false | ||
SUBCOMMAND=run_all | ||
|
||
while [[ "$#" -gt 0 ]]; do | ||
case $1 in | ||
-d|--docker) USE_DOCKER=true ;; | ||
all) SUBCOMMAND=run_all ;; | ||
compile) SUBCOMMAND=compile ;; | ||
run_assigner) SUBCOMMAND=run_assigner ;; | ||
make_statement) SUBCOMMAND=make_statement ;; | ||
prove) SUBCOMMAND=prove ;; | ||
*) echo "Unknown parameter passed: $1"; exit 1 ;; | ||
esac | ||
shift | ||
done | ||
|
||
echo "Running ${SUBCOMMAND}" | ||
$SUBCOMMAND |
This file was deleted.
Oops, something went wrong.