Fix CI and Makefile (WIP)

This commit is contained in:
Georges Dupéron 2019-09-06 04:02:18 +02:00
parent f831793fbd
commit 644d90be6d
15 changed files with 161 additions and 140 deletions

View File

@ -9,34 +9,21 @@ stages:
- test - test
.website_build: &website_build .website_build: &website_build
stage: build_and_deploy_website stage: test # TODO DODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODO restore to build_and_deploy_website
image: node:8 image: node:8
before_script: before_script:
- scripts/install_native_dependencies.sh - scripts/install_native_dependencies.sh
# TODO: these things are moved to scripts in other branches. - scripts/install_opam.sh # TODO: or scripts/install_build_environment.sh ?
- wget https://github.com/ocaml/opam/releases/download/2.0.1/opam-2.0.1-x86_64-linux -O opam-2.0.1-x86_64-linux
- cp opam-2.0.1-x86_64-linux /usr/local/bin/opam
- chmod +x /usr/local/bin/opam
- export PATH="/usr/local/bin${PATH:+:}${PATH:-}" - export PATH="/usr/local/bin${PATH:+:}${PATH:-}"
# Initialise opam
- printf '' | opam init --bare
- eval $(opam config env) - eval $(opam config env)
- scripts/setup_switch.sh
# Create switch
- printf '' | opam switch create toto ocaml-base-compiler.4.06.1
- eval $(opam config env) - eval $(opam config env)
- scripts/debug_show_versions.sh || true
# Show versions and current switch
- echo "$PATH"
- opam --version
- printf '' | ocaml
- opam switch
# install deps for internal documentation # install deps for internal documentation
- opam install -y odoc - opam install -y odoc
- vendors/opam-repository-tools/rewrite-local-opam-repository.sh # - vendors/opam-repository-tools/rewrite-local-opam-repository.sh
- opam repository add localrepo "file://$PWD/vendors/ligo-opam-repository-local-generated/" # - opam repository add localrepo "file://$PWD/vendors/ligo-opam-repository-local-generated/"
- opam install -y --build-test --deps-only ./src/ - opam install -y --build-test --deps-only ./src/
- dune build -p ligo - dune build -p ligo
# TODO: also try instead from time to time: # TODO: also try instead from time to time:
@ -75,44 +62,36 @@ stages:
before_script: before_script:
# Install dependencies # Install dependencies
# rsync is needed by opam to sync a package installed from a local directory with the copy in ~/.opam # rsync is needed by opam to sync a package installed from a local directory with the copy in ~/.opam
- apt-get update -qq
- scripts/install_native_dependencies.sh - scripts/install_native_dependencies.sh
- scripts/install_opam.sh - scripts/install_opam.sh # TODO: or scripts/install_build_environment.sh ?
- export PATH="/usr/local/bin${PATH:+:}${PATH:-}" - export PATH="/usr/local/bin${PATH:+:}${PATH:-}"
- echo "$PATH"; which ocaml || true
# Initialise opam, create switch, load opam environment variables
- printf '' | opam init --bare
- printf '' | opam switch create ligo-switch ocaml-base-compiler.4.06.1
- eval $(opam config env) - eval $(opam config env)
- echo "$PATH"; which ocaml || true
# Show versions and current switch - scripts/setup_switch.sh
- echo "$PATH" - echo "$PATH"; which ocaml || true
- opam --version - eval $(opam config env)
- printf '' | ocaml - echo "$PATH"; which ocaml || true
- opam switch - scripts/debug_show_versions.sh || true
local-dune-job: local-dune-job:
<<: *before_script <<: *before_script
stage: test stage: test
script: script:
- scripts/setup_ligo_opam_repository.sh - scripts/install_vendors_deps.sh
- opam install -y --build-test --deps-only ./src/ - scripts/build_ligo_local.sh
- dune build -p ligo
# TODO: also try instead from time to time:
#- (cd ./src/; dune build -p ligo)
- dune build @ligo-test - dune build @ligo-test
# artifacts:
# paths:
# - src/ligo/bin/cli.ml
local-repo-job: # TODO: uncomment this
<<: *before_script
stage: test # TODO
script: # local-repo-job:
- vendors/opam-repository-tools/rewrite-local-opam-repository.sh # <<: *before_script
- opam repository add localrepo "file://$PWD/vendors/ligo-opam-repository-local-generated/" # stage: test
#--build-test # script:
- opam install -y ligo # - scripts/install_vendors_deps.sh
# # TODO: also try from time to time with --build-test
# - opam install -y ligo
remote-repo-job: remote-repo-job:
<<: *before_script <<: *before_script
@ -130,19 +109,21 @@ remote-repo-job:
only: only:
- master - master
# Run a docker build without publishing to the registry # TODO: uncomment this
build-current-docker-image:
stage: build_docker # # Run a docker build without publishing to the registry
<<: *docker # build-current-docker-image:
<<: *docker_build # stage: test # TODO DODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODO restore to build_docker
except: # <<: *docker
- master # <<: *docker_build
- dev # except:
# - master
# - dev
# When a MR/PR is merged to dev # When a MR/PR is merged to dev
# take the previous build and publish it to Docker Hub # take the previous build and publish it to Docker Hub
build-and-publish-latest-docker-image: build-and-publish-latest-docker-image:
stage: build_and_deploy_docker stage: test # TODO DODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODODO restore to build_and_deploy_docker
<<: *docker <<: *docker
<<: *docker_build <<: *docker_build
after_script: after_script:

View File

@ -1,3 +1,37 @@
.ONESHELL:
all: test
# Use install-deps instead of 'install' because usually 'make install' adds a
# binary to the system path and we don't want to confuse users
install-deps:
# Install ligo/tezos specific system-level dependencies
sudo scripts/install_native_dependencies.sh
scripts/install_build_environment.sh # TODO: or scripts/install_opam.sh ?
build-deps: build-deps:
scripts/install_native_dependencies.sh echo aa
scripts/install_opam.sh export PATH="/usr/local/bin$${PATH:+:}$${PATH:-}"
# Create opam dev switch locally for use with Ligo, add merlin/etc
if [ -n "`opam switch show | grep -P ".+/ligo"`" ];
then :; else scripts/setup_dev_switch.sh;
fi
echo bb
eval $$(opam config env)
echo cc
# Install OCaml build dependencies for Ligo
scripts/install_vendors_deps.sh
echo dd
scripts/install_ligo_with_dependencies.sh # TODO: rename & cleanup
echo ee
build: build-deps
export PATH="/usr/local/bin$${PATH:+:}$${PATH:-}"
eval $$(opam config env)
# Build Ligo for local dev use
scripts/build_ligo_local.sh
test: build
export PATH="/usr/local/bin$${PATH:+:}$${PATH:-}"
eval $$(opam config env)
scripts/test_ligo.sh

View File

@ -19,12 +19,17 @@ WORKDIR /ligo
# Install required native dependencies # Install required native dependencies
RUN sh scripts/install_native_dependencies.sh RUN sh scripts/install_native_dependencies.sh
# Setup a custom opam repository where ligo is published # Install OPAM
RUN sh scripts/setup_ligo_opam_repository.sh # TODO: or scripts/install_build_environment.sh ?
RUN sh scripts/install_opam.sh
# Creat opam switch
RUN sh scripts/setup_switch.sh
RUN opam update RUN opam update
# Install ligo # Install ligo
RUN sh scripts/install_vendors_deps.sh
RUN sh scripts/install_ligo_with_dependencies.sh RUN sh scripts/install_ligo_with_dependencies.sh
# Use the ligo binary as a default command # Use the ligo binary as a default command

View File

@ -1,25 +0,0 @@
# Use install-deps instead of 'install' because usually 'make install' adds a
# binary to the system path and we don't want to confuse users
install-deps:
# Install ligo/tezos specific system-level dependencies
sudo scripts/install_native_dependencies.sh
build-deps:
# Create opam dev switch locally for use with Ligo, add merlin/etc
if [ -n "`opam switch show | grep -P ".+/ligo"`" ];
then exit; else scripts/setup_dev_switch.sh;
fi
# Set up the local ligo opam repository so that it can be built
if [ -n "`opam repo list --safe | grep -P "ligo-opam-repository"`" ];
then exit; else scripts/setup_ligo_opam_repository.sh;
fi
# Install OCaml build dependencies for Ligo
scripts/install_ligo_with_dependencies.sh
build: build-deps
# Build Ligo for local dev use
scripts/build_ligo_local.sh
.ONESHELL:
test: build
scripts/test_ligo.sh

View File

@ -1,2 +1,8 @@
eval $(opam env) #!/bin/sh
dune build -p ligo set -e
eval $(opam config env)
dune build src # TODO: make it work with -p ligo
# TODO: also try instead from time to time:
#- (cd ./src/; dune build -p ligo)

8
scripts/debug_show_versions.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
set -e
echo "$PATH"
opam --version
printf '' | ocaml
opam switch

View File

@ -1,3 +1,6 @@
#!/bin/sh
set -e
# This script installs opam for the user. It should NOT be included in any makefiles/etc. # This script installs opam for the user. It should NOT be included in any makefiles/etc.
if [ -n "`which opam`" ] if [ -n "`which opam`" ]

View File

@ -1,10 +1,27 @@
#!/bin/sh #!/bin/sh
set -e set -e
set -x
# TODO: this has many different modes of failure (file temp.opam-2.0.1-x86_64-linux.download-in-progress already exists, /usr/local/bin/opam already exists and is a directory or hard link, …) # TODO: this has many different modes of failure (file temp.opam-2.0.1-x86_64-linux.download-in-progress already exists, /usr/local/bin/opam already exists and is a directory or hard link, …)
# Try to improve these aspects. # Try to improve these aspects.
if command -v wget >/dev/null 2>&1; then
wget https://github.com/ocaml/opam/releases/download/2.0.1/opam-2.0.1-x86_64-linux -O temp.opam-2.0.1-x86_64-linux.download-in-progress wget https://github.com/ocaml/opam/releases/download/2.0.1/opam-2.0.1-x86_64-linux -O temp.opam-2.0.1-x86_64-linux.download-in-progress
else
curl -L https://github.com/ocaml/opam/releases/download/2.0.1/opam-2.0.1-x86_64-linux --output temp.opam-2.0.1-x86_64-linux.download-in-progress
fi
# debug
ls
apt -y install hexdump || true
apt -y install xxd || true
(cat temp.opam-2.0.1-x86_64-linux.download-in-progress | xxd | head -n 30) || true
cp -i temp.opam-2.0.1-x86_64-linux.download-in-progress /usr/local/bin/opam cp -i temp.opam-2.0.1-x86_64-linux.download-in-progress /usr/local/bin/opam
chmod +x /usr/local/bin/opam chmod +x /usr/local/bin/opam
rm temp.opam-2.0.1-x86_64-linux.download-in-progress rm temp.opam-2.0.1-x86_64-linux.download-in-progress
which opam || true
opam init -a --bare

12
scripts/install_vendors_deps.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
set -e
# Install local dependencies
opam install -y ./vendors/ligo-utils/simple-utils
opam install -y ./vendors/ligo-utils/tezos-protocol-alpha
opam install -y ./vendors/ligo-utils/tezos-protocol-alpha-parameters
opam install -y ./vendors/ligo-utils/memory-proto-alpha
opam install -y ./vendors/ligo-utils/tezos-utils/michelson-parser
opam install -y ./vendors/ligo-utils/tezos-utils
opam install -y ./vendors/ligo-utils/proto-alpha-utils
opam install -y getopt ppx_deriving menhir

View File

@ -1,4 +1,7 @@
opam switch create . ocaml-base-compiler.4.06.1 #!/bin/sh
eval $(opam env) set -e
"$(dirname "$0")"/setup_switch.sh
opam install -y ocp-indent tuareg merlin alcotest-lwt crowbar opam install -y ocp-indent tuareg merlin alcotest-lwt crowbar
opam -y user-setup install opam -y user-setup install

15
scripts/setup_switch.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/sh
set -e
set -x
printf '' | opam switch create . 4.07.1 # toto ocaml-base-compiler.4.06.1
eval $(opam config env)
# Add Tezos opam repository
opam repo add tezos-opam-repository https://gitlab.com/nomadic-labs/tezos-opam-repository.git
# TODO: move this to install_vendor_deps.sh
# Pin the versions of some dependencies
opam pin -y zarith 1.7
opam pin -y ipaddr 3.1.0
opam pin -y macaddr 3.1.0

View File

@ -1,2 +1,5 @@
eval $(opam env) #!/bin/sh
set -e
eval $(opam config env)
dune build @ligo-test dune build @ligo-test

View File

@ -1,20 +0,0 @@
switch=titi
cd src/ligo
sudo apt -y install libev-dev libhidapi-dev
opam init
eval $(opam env)
opam switch create $switch ocaml-base-compiler.4.06.1
eval $(opam env --switch=$switch --set-switch)
opam repository add new-tezos https://gitlab.com/ligolang/new-tezos-opam-repository.git
# si une build a déjà été tentée, il vaut mieux git add tout ce qui est utile et git clean -dfx pour supprimer tout le reste (dune 1.7 crée des fichiers non compatibles avec dune 1.6)
opam install -y ocplib-endian alcotest
(cd ligo-parser && opam install -y .)
eval $(opam env)
(cd ligo-helpers && opam install -y .)
eval $(opam env)
(opam install -y .)
eval $(opam env)
opam install merlin ocp-indent ledit
opam user-setup install

View File

@ -1,21 +0,0 @@
before_script:
- apt-get update -qq
- apt-get -y -qq install libhidapi-dev libcap-dev bubblewrap
- wget https://github.com/ocaml/opam/releases/download/2.0.1/opam-2.0.1-x86_64-linux -O opam-2.0.1-x86_64-linux
- cp opam-2.0.1-x86_64-linux /usr/local/bin/opam
- chmod +x /usr/local/bin/opam
- export PATH="/usr/local/bin${PATH:+:}${PATH:-}"
- echo "$PATH"
- printf '' | opam init
- eval $(opam config env)
- opam repository add tezos-opam-repository https://gitlab.com/ligolang/tezos-opam-repository.git
- eval $(opam config env)
- opam --version
- printf '' | ocaml
default-job:
script:
- opam install -y --working-dir .
artifacts:
paths:
- Parser.exe

View File

@ -75,13 +75,13 @@ let (first_owner , first_contract) =
let open Proto_alpha_utils.Memory_proto_alpha in let open Proto_alpha_utils.Memory_proto_alpha in
let id = List.nth dummy_environment.identities 0 in let id = List.nth dummy_environment.identities 0 in
let kt = id.implicit_contract in let kt = id.implicit_contract in
Alpha_context.Contract.to_b58check kt , kt Protocol.Alpha_context.Contract.to_b58check kt , kt
let second_owner = let second_owner =
let open Proto_alpha_utils.Memory_proto_alpha in let open Proto_alpha_utils.Memory_proto_alpha in
let id = List.nth dummy_environment.identities 1 in let id = List.nth dummy_environment.identities 1 in
let kt = id.implicit_contract in let kt = id.implicit_contract in
Alpha_context.Contract.to_b58check kt Protocol.Alpha_context.Contract.to_b58check kt
let basic a b cards next_id = let basic a b cards next_id =
let card_patterns = List.map card_pattern_ez [ let card_patterns = List.map card_pattern_ez [
@ -113,13 +113,13 @@ let buy () =
let%bind () = let%bind () =
let%bind amount = let%bind amount =
trace_option (simple_error "getting amount for run") @@ trace_option (simple_error "getting amount for run") @@
Memory_proto_alpha.Alpha_context.Tez.of_mutez @@ Int64.of_int 10000000000 in Memory_proto_alpha.Protocol.Alpha_context.Tez.of_mutez @@ Int64.of_int 10000000000 in
let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~amount () in let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~amount () in
expect_eq_n_pos_small ~options program "buy_single" make_input make_expected in expect_eq_n_pos_small ~options program "buy_single" make_input make_expected in
let%bind () = let%bind () =
let%bind amount = let%bind amount =
trace_option (simple_error "getting amount for run") @@ trace_option (simple_error "getting amount for run") @@
Memory_proto_alpha.Alpha_context.Tez.of_mutez @@ Int64.of_int 0 in Memory_proto_alpha.Protocol.Alpha_context.Tez.of_mutez @@ Int64.of_int 0 in
let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~amount () in let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~amount () in
trace_strong (simple_error "could buy without money") @@ trace_strong (simple_error "could buy without money") @@
Assert.assert_fail Assert.assert_fail
@ -152,13 +152,13 @@ let dispatch_buy () =
let%bind () = let%bind () =
let%bind amount = let%bind amount =
trace_option (simple_error "getting amount for run") @@ trace_option (simple_error "getting amount for run") @@
Memory_proto_alpha.Alpha_context.Tez.of_mutez @@ Int64.of_int 10000000000 in Memory_proto_alpha.Protocol.Alpha_context.Tez.of_mutez @@ Int64.of_int 10000000000 in
let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~amount () in let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~amount () in
expect_eq_n_pos_small ~options program "main" make_input make_expected in expect_eq_n_pos_small ~options program "main" make_input make_expected in
let%bind () = let%bind () =
let%bind amount = let%bind amount =
trace_option (simple_error "getting amount for run") @@ trace_option (simple_error "getting amount for run") @@
Memory_proto_alpha.Alpha_context.Tez.of_mutez @@ Int64.of_int 0 in Memory_proto_alpha.Protocol.Alpha_context.Tez.of_mutez @@ Int64.of_int 0 in
let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~amount () in let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~amount () in
trace_strong (simple_error "could buy without money") @@ trace_strong (simple_error "could buy without money") @@
Assert.assert_fail Assert.assert_fail
@ -190,7 +190,7 @@ let transfer () =
e_pair ops storage e_pair ops storage
in in
let%bind () = let%bind () =
let amount = Memory_proto_alpha.Alpha_context.Tez.zero in let amount = Memory_proto_alpha.Protocol.Alpha_context.Tez.zero in
let payer = first_contract in let payer = first_contract in
let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~amount ~payer () in let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~amount ~payer () in
expect_eq_n_strict_pos_small ~options program "transfer_single" make_input make_expected in expect_eq_n_strict_pos_small ~options program "transfer_single" make_input make_expected in
@ -220,7 +220,7 @@ let sell () =
Ast_simplified.Misc.assert_value_eq (expected_storage , storage) Ast_simplified.Misc.assert_value_eq (expected_storage , storage)
in in
let%bind () = let%bind () =
let amount = Memory_proto_alpha.Alpha_context.Tez.zero in let amount = Memory_proto_alpha.Protocol.Alpha_context.Tez.zero in
let payer = first_contract in let payer = first_contract in
let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~amount ~payer () in let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~amount ~payer () in
expect_n_strict_pos_small ~options program "sell_single" make_input make_expecter in expect_n_strict_pos_small ~options program "sell_single" make_input make_expecter in