Skip to content

Commit

Permalink
CI: separate mono installation
Browse files Browse the repository at this point in the history
Mono installation takes a long time and currently our CI
has to do it almost 4 times which causes the CI to take
forever to build, test and package a commit so to mitigate
this issue this commit separates mono installation into
a separate stage and uploads the resulting docker image
into Gitlab's Container Registry and then we use that
docker image for the rest of the stages.

See merge request https://gitlab.com/nblockchain/geewallet/-/merge_requests/123
  • Loading branch information
aarani authored and knocte committed Mar 26, 2021
1 parent 49376de commit 2bfc26c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 31 deletions.
54 changes: 27 additions & 27 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
before_script:
- apt-get update
- apt install -y make git
# needed to download NuGet
- apt-get install -y curl

stages:
- buildenv
- build
- unit_tests
- integration_tests
- package

stockmono_buildenv:
image: docker:19.03.12
stage: buildenv
services:
- docker:19.03.12-dind
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE/stock_env:$CI_COMMIT_SHA -f stockmono.docker .
- docker push $CI_REGISTRY_IMAGE/stock_env:$CI_COMMIT_SHA

stockmono_build:
image: ubuntu:20.04
image: $CI_REGISTRY_IMAGE/stock_env:$CI_COMMIT_SHA
stage: build
script:
# https://askubuntu.com/a/1013396
- DEBIAN_FRONTEND=noninteractive apt-get install -y mono-complete mono-xbuild fsharp
- mono --version

- ./configure.sh
Expand All @@ -25,40 +28,43 @@ stockmono_build:
- make install

stockmono_test_unit:
image: ubuntu:20.04
image: $CI_REGISTRY_IMAGE/stock_env:$CI_COMMIT_SHA
stage: unit_tests
script:
# https://askubuntu.com/a/1013396
- DEBIAN_FRONTEND=noninteractive apt-get install -y mono-complete mono-xbuild fsharp
- mono --version

- apt-get install -y nunit-console
- ./configure.sh
- make
- make check

stockmono_test_integration:
image: ubuntu:20.04
image: $CI_REGISTRY_IMAGE/stock_env:$CI_COMMIT_SHA
stage: integration_tests
script:
# https://askubuntu.com/a/1013396
- DEBIAN_FRONTEND=noninteractive apt-get install -y mono-complete mono-xbuild fsharp
- mono --version

- ./configure.sh
- make
- make update-servers

newmono_buildenv:
image: docker:19.03.12
stage: buildenv
services:
- docker:19.03.12-dind
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE/new_env:$CI_COMMIT_SHA -f newmono.docker .
- docker push $CI_REGISTRY_IMAGE/new_env:$CI_COMMIT_SHA

newmono_build:
image: ubuntu:20.04
image: $CI_REGISTRY_IMAGE/new_env:$CI_COMMIT_SHA
stage: build
artifacts:
paths:
- bin/*.zip
expire_in: 50days
script:
- ./scripts/install_mono_from_microsoft_deb_packages.sh

- ./configure.sh
- make sanitycheck
- make strict
Expand All @@ -67,25 +73,19 @@ newmono_build:
# so that we log the version of nuget for when it works
- make nuget

- apt-get install -y zip
- make zip

newmono_test_unit:
image: ubuntu:20.04
image: $CI_REGISTRY_IMAGE/new_env:$CI_COMMIT_SHA
stage: unit_tests
script:
- ./scripts/install_mono_from_microsoft_deb_packages.sh

- apt install -y nunit-console

- time (./configure.sh && make && make check)

newmono_test_integration:
image: ubuntu:20.04
image: $CI_REGISTRY_IMAGE/new_env:$CI_COMMIT_SHA
stage: integration_tests
script:
- ./scripts/install_mono_from_microsoft_deb_packages.sh

- ./configure.sh &&
make &&
make update-servers
Expand Down
4 changes: 0 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,3 @@ Some other items that haven't been prioritized include (likely only intelligible
* https://github.com/stroiman/JsonFSharp
- Paranoid-build mode: instead of binary nuget deps, use either git submodules, or [local nugets](https://github.com/mono/mono-addins/issues/73#issuecomment-389343246) (maybe depending on [this RFE](https://github.com/dotnet/sdk/issues/1151) or any workaround mentioned there, or a config file like it's explained here: https://docs.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior), or [source-only nugets](https://medium.com/@attilah/source-code-only-nuget-packages-8f34a8fb4738).
- Maybe replace JsonRpcSharp with https://www.nuget.org/packages/StreamJsonRpc .
- Reduce GitLabCI pipeline times by trying one of these two solutions:
* Installing deps in docker image and passing it as an artifact: https://forum.gitlab.com/t/passing-docker-image-between-build-and-test-stage-in-gitlab-runner/2444/7
* Try GitLabCI's parent-child pipelines: maybe the parent pipeline that defines the 'trigger' element can have a 'script' element too?

8 changes: 8 additions & 0 deletions newmono.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM ubuntu:20.04

COPY "./scripts/install_mono_from_microsoft_deb_packages.sh" "/tmp/install_mono_from_microsoft_deb_packages.sh"

RUN apt update
RUN apt install -y make git curl zip
RUN "/tmp/install_mono_from_microsoft_deb_packages.sh"
RUN apt install -y nunit-console
8 changes: 8 additions & 0 deletions stockmono.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM ubuntu:20.04


RUN apt update
RUN apt install -y make git curl zip
# https://askubuntu.com/a/1013396
ARG DEBIAN_FRONTEND=noninteractive
RUN apt install -y mono-complete mono-xbuild fsharp nunit-console

0 comments on commit 2bfc26c

Please sign in to comment.