diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 50def4d2..ef8016d0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,8 @@ -on: [push, pull_request] +on: + push: + branches: [master] + pull_request: + branches: [master] name: Sanity Check codebase diff --git a/.github/workflows/integration_testing.yml b/.github/workflows/integration_testing.yml new file mode 100644 index 00000000..40e1ad85 --- /dev/null +++ b/.github/workflows/integration_testing.yml @@ -0,0 +1,19 @@ +name: Integration testing + +on: + push: + branches: [master] + pull_request: + branches: [master] + schedule: + - cron: '30 1 1,15 * *' + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Integration testing + run: | + cd docker + docker-compose up --exit-code-from coffee diff --git a/Cargo.lock b/Cargo.lock index 38f678c1..5bb917a8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -242,6 +242,12 @@ dependencies = [ "alloc-no-stdlib", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + [[package]] name = "anyhow" version = "1.0.71" @@ -500,6 +506,16 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +dependencies = [ + "android-tzdata", + "num-traits", +] + [[package]] name = "clap" version = "4.1.11" @@ -765,6 +781,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "colored" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59" +dependencies = [ + "atty", + "lazy_static", + "winapi", +] + [[package]] name = "concolor" version = "0.0.12" @@ -1666,6 +1693,48 @@ dependencies = [ "memoffset 0.6.5", ] +[[package]] +name = "ntest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da8ec6d2b73d45307e926f5af46809768581044384637af6b3f3fe7c3c88f512" +dependencies = [ + "ntest_test_cases", + "ntest_timeout", +] + +[[package]] +name = "ntest_test_cases" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be7d33be719c6f4d09e64e27c1ef4e73485dc4cc1f4d22201f89860a7fe22e22" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ntest_timeout" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "066b468120587a402f0b47d8f80035c921f6a46f8209efd0632a89a16f5188a4" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + [[package]] name = "num_cpus" version = "1.15.0" @@ -1875,6 +1944,16 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -2464,6 +2543,20 @@ dependencies = [ "redox_termios", ] +[[package]] +name = "tests" +version = "0.1.0" +dependencies = [ + "anyhow", + "chrono", + "coffee_lib", + "coffee_testing", + "colored", + "log", + "ntest", + "tokio", +] + [[package]] name = "thiserror" version = "1.0.40" @@ -2571,6 +2664,23 @@ dependencies = [ "tracing", ] +[[package]] +name = "toml_datetime" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" + +[[package]] +name = "toml_edit" +version = "0.19.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + [[package]] name = "tracing" version = "0.1.37" @@ -2848,6 +2958,15 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +[[package]] +name = "winnow" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca0ace3845f0d96209f0375e6d367e3eb87eb65d27d445bdc9f1843a26f39448" +dependencies = [ + "memchr", +] + [[package]] name = "zeroize" version = "1.6.0" diff --git a/Cargo.toml b/Cargo.toml index 7b3fa041..4a4c50e8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,5 +8,17 @@ members = [ "coffee_httpd", "coffee_plugin", "coffee_testing", + "tests" +] + +default-members = [ + "coffee_lib", + "coffee_github", + "coffee_storage", + "coffee_core", + "coffee_cmd", + "coffee_httpd", + "coffee_plugin", + "coffee_testing", ] resolver = "2" diff --git a/Makefile b/Makefile index 29ddb662..74b25d60 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CC=cargo FMT=fmt -ARGS="--all" +ARGS="" default: fmt $(CC) build @@ -32,4 +32,4 @@ install: $(CC) install --locked --path ./coffee_cmd integration: - cd tests; $(CC) test $(ARGS) + $(CC) test -p tests $(ARGS) diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..4f07fc21 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,43 @@ +FROM ubuntu:20.04 +LABEL mantainer="Vincenzo Palazzo vincenzopalazzodev@gmail.com" + +ENV TZ=Europe/Minsk +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +# Ubuntu utils +RUN apt-get update && apt-get install -y \ + software-properties-common \ + build-essential \ + curl wget + +RUN apt-get update + +## Install Rust +RUN curl https://sh.rustup.rs -sSf | bash -s -- -y +ENV PATH="/root/.cargo/bin:${PATH}" +RUN echo 'source $HOME/.cargo/env' >> $HOME/.bashrc + +# Install bitcoin core and lightningd (last version) +RUN add-apt-repository ppa:luke-jr/bitcoincore +RUN apt-get update && apt-get install -y \ + bitcoind jq libsodium-dev libpq-dev + autoconf automake build-essential git libtool libgmp-dev libsqlite3-dev \ + python3 python3-pip net-tools zlib1g-dev libsodium-dev gettext \ + pkg-config libssl-dev cmake + +ENV CLIGHTNING_VERSION=master + +RUN git clone https://github.com/ElementsProject/lightning.git --branch=$CLIGHTNING_VERSION && \ + cd lightning && \ + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \ + ./configure --enable-developer --disable-rust && git submodule update --init --recursive && \ + pip3 install --upgrade pip && \ + pip3 install mako mistune==0.8.4 mrkd && \ + make -j$(nproc) && make install + +RUN echo $(lightningd --version) + +WORKDIR workdir +COPY . . + +CMD ["./docker/entrypoint.sh"] diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml new file mode 100644 index 00000000..e9d4d1f2 --- /dev/null +++ b/docker/docker-compose.yaml @@ -0,0 +1,7 @@ +version: "3.8" + +services: + coffee: + build: + context: ../ + dockerfile: ./docker/Dockerfile diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100755 index 00000000..4e3fa1ba --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,2 @@ +#!/bin/bash +RUST_BACKTRACE=1 make integration ARGS="-- --show-output"