From 2a3db4ec7b62445864df016cb499f9bbb05baa1c Mon Sep 17 00:00:00 2001 From: Luke Anderson Date: Thu, 2 May 2019 15:15:16 +1000 Subject: [PATCH 01/10] Added a first attempt at a gitlab-ci.yml file. --- .gitlab-ci.yml | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 000000000..dc6cdace1 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,41 @@ +#Adapted from https://users.rust-lang.org/t/my-gitlab-config-docs-tests/16396 + +image: 'rust:latest' + +stages: + - test + - doc + - build + +variables: + CARGO_HOME: $CI_PROJECT_DIR/cargo + APT_CACHE_DIR: $CI_PROJECT_DIR/apt + +before_script: + - apt-get update -yq + - apt-get install -o dir::cache::archives="$APT_CACHE_DIR" -y clang libclang-dev cmake build-essential git unzip autoconf libtool + +test: + stage: test + script: + - rustc --version + - cargo --version + - cargo test --verbose + +pages: + stage: doc + script: + - cargo doc --no-deps + - mv target/doc public + # - echo '' > public/index.html + artifacts: + paths: + - public + only: + - master + +cache: + paths: + - apt/ + - cargo/ + - target/ From 3b1d8fbab87851043d1f1bc8070f4f4422e0917a Mon Sep 17 00:00:00 2001 From: Luke Anderson Date: Mon, 6 May 2019 19:17:03 +1000 Subject: [PATCH 02/10] Added a line to the GitLab config which installs protobuf before compiling lighthouse. --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dc6cdace1..a5d845165 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,6 +14,7 @@ variables: before_script: - apt-get update -yq - apt-get install -o dir::cache::archives="$APT_CACHE_DIR" -y clang libclang-dev cmake build-essential git unzip autoconf libtool + - git clone https://github.com/google/protobuf.git && cd protobuf && ./autogen.sh && ./configure && make && make install && ldconfig && make clean && cd .. && rm -r protobuf test: stage: test From 1276a2812e8f9c811dbff96e9dd6f04a30f6813a Mon Sep 17 00:00:00 2001 From: Luke Anderson Date: Mon, 6 May 2019 19:45:30 +1000 Subject: [PATCH 03/10] Included new jobs in the gitlab test stage, to get testing to run in parallel. --- .gitlab-ci.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a5d845165..c48a765be 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,12 +16,20 @@ before_script: - apt-get install -o dir::cache::archives="$APT_CACHE_DIR" -y clang libclang-dev cmake build-essential git unzip autoconf libtool - git clone https://github.com/google/protobuf.git && cd protobuf && ./autogen.sh && ./configure && make && make install && ldconfig && make clean && cd .. && rm -r protobuf -test: +test-dev: stage: test script: - - rustc --version - - cargo --version - - cargo test --verbose + - cargo test --verbose --all + +test-release: + stage: test + script: + - cargo test --verbose --all --release + +check-fmt: + stage: test + script: + - cargo fmt --all -- --check pages: stage: doc From dc8e879eda73a148a1bb0fe0de85fbec7ccaf617 Mon Sep 17 00:00:00 2001 From: Luke Anderson Date: Mon, 6 May 2019 19:47:41 +1000 Subject: [PATCH 04/10] Moved the GitLab format check up in priority. --- .gitlab-ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c48a765be..1a12d35c4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,6 +16,11 @@ before_script: - apt-get install -o dir::cache::archives="$APT_CACHE_DIR" -y clang libclang-dev cmake build-essential git unzip autoconf libtool - git clone https://github.com/google/protobuf.git && cd protobuf && ./autogen.sh && ./configure && make && make install && ldconfig && make clean && cd .. && rm -r protobuf +check-fmt: + stage: test + script: + - cargo fmt --all -- --check + test-dev: stage: test script: @@ -26,11 +31,6 @@ test-release: script: - cargo test --verbose --all --release -check-fmt: - stage: test - script: - - cargo fmt --all -- --check - pages: stage: doc script: From 9f88892fae46c6f528f85b49b36e26a4078cf922 Mon Sep 17 00:00:00 2001 From: Luke Anderson Date: Mon, 6 May 2019 20:49:25 +1000 Subject: [PATCH 05/10] Moved all the pre-build stuff to a new public docker image. --- .gitlab-ci.yml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1a12d35c4..2e51a4acc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,20 +1,20 @@ #Adapted from https://users.rust-lang.org/t/my-gitlab-config-docs-tests/16396 -image: 'rust:latest' +image: 'sigp/lighthouse:latest' stages: - test - doc - - build -variables: - CARGO_HOME: $CI_PROJECT_DIR/cargo - APT_CACHE_DIR: $CI_PROJECT_DIR/apt +#variables: +# CARGO_HOME: $CI_PROJECT_DIR/cargo +# APT_CACHE_DIR: $CI_PROJECT_DIR/apt -before_script: - - apt-get update -yq - - apt-get install -o dir::cache::archives="$APT_CACHE_DIR" -y clang libclang-dev cmake build-essential git unzip autoconf libtool - - git clone https://github.com/google/protobuf.git && cd protobuf && ./autogen.sh && ./configure && make && make install && ldconfig && make clean && cd .. && rm -r protobuf +#before_script: +# - apt-get update -yq +# - apt-get install -o dir::cache::archives="$APT_CACHE_DIR" -y clang libclang-dev cmake build-essential git unzip autoconf libtool +# - git clone https://github.com/google/protobuf.git && cd protobuf && ./autogen.sh && ./configure && make && make install && ldconfig +# - rustup component add rustfmt check-fmt: stage: test @@ -45,6 +45,5 @@ pages: cache: paths: - - apt/ - - cargo/ + - /cargocache - target/ From 13549422906aee3eeec27269608daa130c7cf561 Mon Sep 17 00:00:00 2001 From: Luke Anderson Date: Mon, 6 May 2019 22:11:47 +1000 Subject: [PATCH 06/10] Removed old build commands from gitlab config. --- .gitlab-ci.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2e51a4acc..830cb7d7d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,16 +6,6 @@ stages: - test - doc -#variables: -# CARGO_HOME: $CI_PROJECT_DIR/cargo -# APT_CACHE_DIR: $CI_PROJECT_DIR/apt - -#before_script: -# - apt-get update -yq -# - apt-get install -o dir::cache::archives="$APT_CACHE_DIR" -y clang libclang-dev cmake build-essential git unzip autoconf libtool -# - git clone https://github.com/google/protobuf.git && cd protobuf && ./autogen.sh && ./configure && make && make install && ldconfig -# - rustup component add rustfmt - check-fmt: stage: test script: From e72e7d2fd60887927041b023fc958b9d96e18c1d Mon Sep 17 00:00:00 2001 From: Luke Anderson Date: Tue, 7 May 2019 13:44:35 +1000 Subject: [PATCH 07/10] Moved the CARGO_HOME enviornment variable, in an attempt to get cargo packages to cache properly. --- .gitlab-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 830cb7d7d..c7fa56fff 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,9 +6,13 @@ stages: - test - doc +variables: + - CARGO_HOME: /cache/cargocache + check-fmt: stage: test script: + - echo $CARGO_HOME - cargo fmt --all -- --check test-dev: @@ -35,5 +39,4 @@ pages: cache: paths: - - /cargocache - target/ From 0d5c3f364354593a67c00b73bf5114cb05c65077 Mon Sep 17 00:00:00 2001 From: Luke Anderson Date: Tue, 7 May 2019 13:46:02 +1000 Subject: [PATCH 08/10] Fixed variables command in gitlab.yml --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c7fa56fff..c2016de13 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,7 @@ stages: - doc variables: - - CARGO_HOME: /cache/cargocache + CARGO_HOME: /cache/cargocache check-fmt: stage: test From 0bfe578810ff0a7cafa31bcd956a421f353aa2f4 Mon Sep 17 00:00:00 2001 From: Luke Anderson Date: Tue, 7 May 2019 14:00:15 +1000 Subject: [PATCH 09/10] Updated Jenkins configuration to use , to be consistent with the GitLab caching mechanism. --- Dockerfile | 4 ++-- Jenkinsfile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6691efa97..e693c91a3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,8 +14,8 @@ RUN git clone https://github.com/google/protobuf.git && \ rm -r protobuf -RUN mkdir /cargocache && chmod -R ugo+rwX /cargocache +RUN mkdir -p /cache/cargocache && chmod -R ugo+rwX /cache/cargocache -ENV CARGO_HOME /cargocache +ENV CARGO_HOME /cache/cargocache RUN rustup component add rustfmt clippy diff --git a/Jenkinsfile b/Jenkinsfile index 11cbf0abe..3b022551e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ pipeline { agent { dockerfile { filename 'Dockerfile' - args '-v cargo-cache:/cargocache:rw -e "CARGO_HOME=/cargocache"' + args '-v cargo-cache:/cache/cargocache:rw -e "CARGO_HOME=/cache/cargocache"' } } stages { From e0efe2d6720a9c14f549e61bd615025d308a4cb6 Mon Sep 17 00:00:00 2001 From: Luke Anderson Date: Tue, 7 May 2019 14:24:46 +1000 Subject: [PATCH 10/10] Included a command to build the protobuf service files, before doing the cargo fmt check. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c2016de13..db593a592 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,7 +12,7 @@ variables: check-fmt: stage: test script: - - echo $CARGO_HOME + - cargo build --manifest-path protos/Cargo.toml - cargo fmt --all -- --check test-dev: