diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 223f33240..594efb1b5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -97,6 +97,8 @@ build-current-docker-image: stage: build_docker <<: *docker <<: *docker_build + after_script: + - scripts/test_cli.sh except: - master - dev @@ -109,6 +111,7 @@ build-and-publish-latest-docker-image: <<: *docker_build after_script: - docker login -u $LIGO_REGISTRY_USER -p $LIGO_REGISTRY_PASSWORD + - scripts/test_cli.sh - docker push $LIGO_REGISTRY_IMAGE:next only: - dev diff --git a/scripts/ligo_ci.sh b/scripts/ligo_ci.sh new file mode 100755 index 000000000..a39da5873 --- /dev/null +++ b/scripts/ligo_ci.sh @@ -0,0 +1 @@ +docker run -i -v "$PWD":"$PWD" -w "$PWD" ligolang/ligo:next "$@" \ No newline at end of file diff --git a/scripts/test_cli.sh b/scripts/test_cli.sh new file mode 100755 index 000000000..04581fe72 --- /dev/null +++ b/scripts/test_cli.sh @@ -0,0 +1,117 @@ +#!/bin/sh +set -e +compiled_contract=$(./scripts/ligo_ci.sh compile-contract src/test/contracts/website2.ligo main); +compiled_storage=$(./scripts/ligo_ci.sh compile-storage src/test/contracts/website2.ligo main 1); +compiled_parameter=$(./scripts/ligo_ci.sh compile-parameter src/test/contracts/website2.ligo main "Increment(1)"); +dry_run_output=$(./scripts/ligo_ci.sh dry-run src/test/contracts/website2.ligo main "Increment(1)" 1); + +expected_compiled_contract="{ parameter (or int int) ; + storage int ; + code { {} ; + {} ; + {} ; + { PUSH (lambda (pair int int) int) + { {} ; + {} ; + {} ; + { { { DUP ; DIP { {} } } ; CAR } ; + { { { { DIP { DUP } ; SWAP } ; DIP { {} } } ; CDR } ; + { PUSH unit Unit ; + DROP ; + { { { DIP { DUP } ; SWAP } ; DIP { { DUP ; DIP { {} } } } } ; + ADD } } ; + {} ; + DIP { DROP } } ; + {} ; + DIP { DROP } } ; + {} ; + DIP { DROP } ; + {} } ; + { PUSH (lambda (pair int int) int) + { {} ; + {} ; + {} ; + { { { DUP ; DIP { {} } } ; CAR } ; + { { { { DIP { DUP } ; SWAP } ; DIP { {} } } ; CDR } ; + { PUSH unit Unit ; + DROP ; + { { { DIP { DUP } ; SWAP } ; DIP { { DUP ; DIP { {} } } } } ; + SUB } } ; + {} ; + DIP { DROP } } ; + {} ; + DIP { DROP } } ; + {} ; + DIP { DROP } ; + {} } ; + { { { { DIP { { DIP { DUP } ; SWAP } } ; SWAP } ; DIP { {} } } ; + CAR } ; + { { { { DIP { { DIP { { DIP { DUP } ; SWAP } } ; SWAP } } ; SWAP } ; + DIP { {} } } ; + CDR } ; + { PUSH unit Unit ; + DROP ; + { { NIL operation ; + DIP { { { { DIP { DUP } ; SWAP } ; + IF_LEFT + { { { DUP ; + { { { { DIP { { DIP { DUP } ; SWAP } } ; SWAP } ; + DIP { { DUP ; DIP { {} } } } } ; + PAIR } ; + DIP { { DIP { { DIP { { DIP { { DIP { DUP } ; SWAP } } ; SWAP } } ; SWAP } } ; + SWAP } } ; + EXEC } ; + {} ; + DIP { DROP } } ; + {} ; + DIP { DROP } } } + { { { DUP ; + { { { { DIP { { DIP { DUP } ; SWAP } } ; SWAP } ; + DIP { { DUP ; DIP { {} } } } } ; + PAIR } ; + DIP { { DIP { { DIP { { DIP { { DIP { { DIP { DUP } ; SWAP } } ; SWAP } } ; SWAP } } ; + SWAP } } ; + SWAP } } ; + EXEC } ; + {} ; + DIP { DROP } } ; + {} ; + DIP { DROP } } } } ; + DIP { {} } } } } ; + PAIR } } ; + {} ; + DIP { DROP } } ; + {} ; + DIP { DROP } } ; + {} ; + DIP { DROP } } ; + {} ; + DIP { DROP } } ; + {} ; + DIP { DROP } ; + {} } }"; +expected_compiled_parameter="(Right 1)"; +expected_compiled_storage=1; +expected_dry_run_output="tuple[ list[] + 2 +]"; + +if [ "$compiled_contract" != "$expected_compiled_contract" ]; then + echo "Expected $expected_compiled_contract as compile-storage output, got $compiled_contract instead"; + exit 1; +fi + +if [ "$compiled_storage" != "$expected_compiled_storage" ]; then + echo "Expected $expected_compiled_storage as compile-storage output, got $compiled_storage instead"; + exit 1; +fi + +if [ "$compiled_parameter" != "$expected_compiled_parameter" ]; then + echo "Expected $expected_compiled_parameter as compile-parameter output, got $compiled_parameter instead"; + exit 1; +fi + +if [ "$dry_run_output" != "$expected_dry_run_output" ]; then + echo "Expected $expected_dry_run_output as dry-run output, got $dry_run_output instead"; + exit 1; +fi \ No newline at end of file