From d85247d2ad8910c5d9e5c6ac4326195ec6567634 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Tue, 18 Dec 2018 22:35:58 +0900 Subject: [PATCH] Run tests inside container --- .circleci/config.yml | 12 +---------- BTCPayServer.Tests/Dockerfile | 27 +++++++++++++++---------- BTCPayServer.Tests/docker-compose.yml | 20 +++++++++--------- BTCPayServer.Tests/docker-entrypoint.sh | 5 +++++ 4 files changed, 32 insertions(+), 32 deletions(-) create mode 100755 BTCPayServer.Tests/docker-entrypoint.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 87b6ee4d2..454924cb3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,18 +12,8 @@ jobs: - checkout - run: command: | - lsb_release -a - wget -q https://packages.microsoft.com/config/ubuntu/14.04/packages-microsoft-prod.deb - sudo dpkg -i packages-microsoft-prod.deb - sudo apt-get install apt-transport-https - sudo apt-get update - sudo apt-get install dotnet-sdk-2.1 - dotnet --info - dotnet build /p:TreatWarningsAsErrors=true cd BTCPayServer.Tests - dotnet test --filter Fast=Fast - docker-compose up -d dev - dotnet test --filter Integration=Integration + docker-compose run tests # publish jobs require $DOCKERHUB_REPO, $DOCKERHUB_USER, $DOCKERHUB_PASS defined publish_docker_linuxamd64: diff --git a/BTCPayServer.Tests/Dockerfile b/BTCPayServer.Tests/Dockerfile index e63b9fbac..1bc9348ed 100644 --- a/BTCPayServer.Tests/Dockerfile +++ b/BTCPayServer.Tests/Dockerfile @@ -1,12 +1,17 @@ -FROM microsoft/dotnet:2.1.403-sdk-alpine3.7 -WORKDIR /app - # caches restore result by copying csproj file separately -COPY BTCPayServer.Tests/BTCPayServer.Tests.csproj BTCPayServer.Tests/BTCPayServer.Tests.csproj +FROM microsoft/dotnet:2.1.500-sdk-alpine3.7 AS builder +ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT false +RUN apk add --no-cache icu-libs +ENV LC_ALL en_US.UTF-8 +ENV LANG en_US.UTF-8 + +# This should be removed soon https://github.com/dotnet/corefx/issues/30003 +RUN apk add --no-cache curl + +WORKDIR /source COPY BTCPayServer/BTCPayServer.csproj BTCPayServer/BTCPayServer.csproj - -WORKDIR /app/BTCPayServer.Tests -RUN dotnet restore -# copies the rest of your code -COPY . ../. - -ENTRYPOINT ["dotnet", "test"] +COPY BTCPayServer.Tests/BTCPayServer.Tests.csproj BTCPayServer.Tests/BTCPayServer.Tests.csproj +RUN dotnet restore BTCPayServer.Tests/BTCPayServer.Tests.csproj +COPY . . +RUN dotnet build +WORKDIR /source/BTCPayServer.Tests +ENTRYPOINT ["./docker-entrypoint.sh"] diff --git a/BTCPayServer.Tests/docker-compose.yml b/BTCPayServer.Tests/docker-compose.yml index 7aba34f40..ba03e445e 100644 --- a/BTCPayServer.Tests/docker-compose.yml +++ b/BTCPayServer.Tests/docker-compose.yml @@ -19,10 +19,10 @@ services: TESTS_MYSQL: User ID=root;Host=mysql;Port=3306;Database=btcpayserver TESTS_PORT: 80 TESTS_HOSTNAME: tests - TEST_MERCHANTLIGHTNINGD: "type=clightning;server=/etc/merchant_lightningd_datadir/lightning-rpc" - TEST_CUSTOMERLIGHTNINGD: "type=clightning;server=/etc/customer_lightningd_datadir/lightning-rpc" - TEST_MERCHANTCHARGE: "type=charge;server=https://lightning-charged:9112/;api-token=foiewnccewuify;allowinsecure=true" - TEST_MERCHANTLND: "type=lnd-rest;server=https://lnd:lnd@127.0.0.1:53280/;allowinsecure=true" + TEST_MERCHANTLIGHTNINGD: "type=clightning;server=unix://etc/merchant_lightningd_datadir/lightning-rpc" + TEST_CUSTOMERLIGHTNINGD: "type=clightning;server=unix://etc/customer_lightningd_datadir/lightning-rpc" + TEST_MERCHANTCHARGE: "type=charge;server=http://lightning-charged:9112/;api-token=foiewnccewuify" + TEST_MERCHANTLND: "https://lnd:lnd@merchant_lnd:8080/" TESTS_INCONTAINER: "true" expose: - "80" @@ -36,7 +36,7 @@ services: # The dev container is not actually used, it is just handy to run `docker-compose up dev` to start all services dev: - image: nicolasdorier/docker-bitcoin:0.17.0 + image: btcpayserver/bitcoin:0.17.0 environment: BITCOIN_NETWORK: regtest BITCOIN_EXTRA_ARGS: | @@ -53,7 +53,7 @@ services: - merchant_lnd devlnd: - image: nicolasdorier/docker-bitcoin:0.17.0 + image: btcpayserver/bitcoin:0.17.0 environment: BITCOIN_NETWORK: regtest BITCOIN_EXTRA_ARGS: | @@ -94,7 +94,7 @@ services: - litecoind bitcoind: - image: nicolasdorier/docker-bitcoin:0.17.0 + image: btcpayserver/bitcoin:0.17.0 environment: BITCOIN_NETWORK: regtest BITCOIN_EXTRA_ARGS: | @@ -118,7 +118,7 @@ services: - "bitcoin_datadir:/data" customer_lightningd: - image: nicolasdorier/clightning:v0.6.2-3-dev + image: btcpayserver/lightning:v0.6.2-dev stop_signal: SIGKILL restart: unless-stopped environment: @@ -164,7 +164,7 @@ services: - merchant_lightningd merchant_lightningd: - image: nicolasdorier/clightning:v0.6.2-3-dev + image: btcpayserver/lightning:v0.6.2-dev stop_signal: SIGKILL environment: EXPOSE_TCP: "true" @@ -188,7 +188,7 @@ services: - bitcoind litecoind: - image: nicolasdorier/docker-litecoin:0.15.1 + image: nicolasdorier/docker-litecoin:0.16.3 environment: BITCOIN_EXTRA_ARGS: | rpcuser=ceiwHEbqWI83 diff --git a/BTCPayServer.Tests/docker-entrypoint.sh b/BTCPayServer.Tests/docker-entrypoint.sh new file mode 100755 index 000000000..ec8b479b5 --- /dev/null +++ b/BTCPayServer.Tests/docker-entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/sh +set -e + +dotnet test --filter Fast=Fast --no-build +dotnet test --filter Integration=Integration --no-build