From b9344ffeb710376fecd18cec0d2382aa0e57ace2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Fri, 12 Jun 2020 13:09:56 +0200 Subject: [PATCH] CI cleanup - switching more to rules syntax - clean up some templates - EITHER optional builds or build builds - ordering --- .gitlab-ci.yml | 10 +-- ...post.gitlab-ci.yml => build.gitlab-ci.yml} | 88 +++++++++++-------- ...pile.gitlab-ci.yml => check.gitlab-ci.yml} | 12 +-- .gitlab/CI/optional-builds.gitlab-ci.yml | 54 ------------ .gitlab/CI/publish.gitlab-ci.yml | 19 ++-- .gitlab/CI/recompile.yml | 4 + .gitlab/CI/release.yml | 16 ++++ 7 files changed, 91 insertions(+), 112 deletions(-) rename .gitlab/CI/{build-post.gitlab-ci.yml => build.gitlab-ci.yml} (73%) rename .gitlab/CI/{check-compile.gitlab-ci.yml => check.gitlab-ci.yml} (73%) delete mode 100644 .gitlab/CI/optional-builds.gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b851fb7f40..bde49cf4d1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,6 @@ stages: - - optional-builds - - check-compile - - build-post + - check + - build - publish variables: @@ -44,7 +43,6 @@ workflow: include: - local: .gitlab/CI/recompile.yml - local: .gitlab/CI/release.yml - - local: .gitlab/CI/optional-builds.gitlab-ci.yml - - local: .gitlab/CI/check-compile.gitlab-ci.yml - - local: .gitlab/CI/build-post.gitlab-ci.yml + - local: .gitlab/CI/check.gitlab-ci.yml + - local: .gitlab/CI/build.gitlab-ci.yml - local: .gitlab/CI/publish.gitlab-ci.yml diff --git a/.gitlab/CI/build-post.gitlab-ci.yml b/.gitlab/CI/build.gitlab-ci.yml similarity index 73% rename from .gitlab/CI/build-post.gitlab-ci.yml rename to .gitlab/CI/build.gitlab-ci.yml index 4935e9360f..4ad788189c 100644 --- a/.gitlab/CI/build-post.gitlab-ci.yml +++ b/.gitlab/CI/build.gitlab-ci.yml @@ -1,32 +1,15 @@ -.tests: &tests - extends: .recompile-branch - stage: build-post - tags: - - veloren-docker - unittests: - <<: *tests + extends: .recompile-branch + stage: build script: - ln -s /dockercache/cache-all target - cargo test retry: max: 2 -coverage: - # Run on master and branches - extends: .recompile - allow_failure: true - stage: build-post - tags: - - veloren-docker - script: - - ln -s /dockercache/cache-tarpaulin target - - cargo tarpaulin -v - retry: - max: 2 - benchmarks: - <<: *tests + extends: .recompile-branch + stage: build script: - unset DISABLE_GIT_LFS_CHECK - ln -s /dockercache/cache-all target @@ -35,23 +18,27 @@ benchmarks: max: 2 localization-status: - <<: *tests + extends: .recompile-branch + stage: build variables: GIT_DEPTH: 0 allow_failure: true script: - ln -s /dockercache/cache-all target - - cargo test -q test_all_localizations -- --nocapture --ignored + - cargo test test_all_localizations -- --nocapture --ignored -# Artifacts -.artifact: &artifact - extends: .release - stage: build-post - tags: - - veloren-docker +# Coverage is needed on master for the README.md badge to work +coverage: + extends: .recompile + stage: build + script: + - ln -s /dockercache/cache-tarpaulin target + - cargo tarpaulin -v + retry: + max: 2 -linux: - <<: *artifact +#linux, windows, macos builds here as template +.tlinux: script: - ln -s /dockercache/cache-release-linux target - cargo build --release @@ -67,8 +54,7 @@ linux: - LICENSE expire_in: 1 week -windows: - <<: *artifact +.twindows: script: - ln -s /dockercache/cache-release-windows target - cargo build --target=x86_64-pc-windows-gnu --release @@ -82,8 +68,7 @@ windows: - LICENSE expire_in: 1 week -macos: - <<: *artifact +.tmacos: script: - ln -s /dockercache/cache-release-macos target - PATH="/dockercache/osxcross/target/bin:$PATH" COREAUDIO_SDK_PATH=/dockercache/osxcross/target/SDK/MacOSX10.13.sdk CC=o64-clang CXX=o64-clang++ cargo build --target x86_64-apple-darwin --release @@ -96,4 +81,35 @@ macos: - assets/ - LICENSE expire_in: 1 week - allow_failure: true + +# build on release or master +linux: + extends: + - .tlinux + - .release + +windows: + extends: + - .twindows + - .release + +macos: + extends: + - .tmacos + - .release + +# if NOT release or master, allow optional builds +opt-linux: + extends: + - .tlinux + - .optional-release + +opt-windows: + extends: + - .twindows + - .optional-release + +opt-macos: + extends: + - .tmacos + - .optional-release \ No newline at end of file diff --git a/.gitlab/CI/check-compile.gitlab-ci.yml b/.gitlab/CI/check.gitlab-ci.yml similarity index 73% rename from .gitlab/CI/check-compile.gitlab-ci.yml rename to .gitlab/CI/check.gitlab-ci.yml index 5f5e673443..efebfb2918 100644 --- a/.gitlab/CI/check-compile.gitlab-ci.yml +++ b/.gitlab/CI/check.gitlab-ci.yml @@ -1,17 +1,13 @@ check: extends: .recompile-branch - stage: check-compile - tags: - - veloren-docker + stage: check script: - ln -s /dockercache/cache-all target - RUSTFLAGS="-D warnings" cargo check --locked code-quality: extends: .recompile-branch - stage: check-compile - tags: - - veloren-docker + stage: check script: - ln -s /dockercache/cache-all target - cargo clippy -- -D warnings @@ -19,10 +15,8 @@ code-quality: security: extends: .recompile-branch - stage: check-compile + stage: check allow_failure: true - tags: - - veloren-docker script: - ln -s /dockercache/cache-all target - cargo audit diff --git a/.gitlab/CI/optional-builds.gitlab-ci.yml b/.gitlab/CI/optional-builds.gitlab-ci.yml deleted file mode 100644 index 8fdb5d5f9c..0000000000 --- a/.gitlab/CI/optional-builds.gitlab-ci.yml +++ /dev/null @@ -1,54 +0,0 @@ -.optional-release: &optional-release - stage: optional-builds - tags: - - veloren-docker - except: - - schedules - when: manual - -optional-release:linux: - <<: *optional-release - script: - - ln -s /dockercache/cache-release-linux target - - cargo build --verbose --release - - cp target/release/veloren-server-cli $CI_PROJECT_DIR - - cp target/release/veloren-voxygen $CI_PROJECT_DIR - - strip --strip-all veloren-server-cli - - strip --strip-all veloren-voxygen - artifacts: - paths: - - veloren-server-cli - - veloren-voxygen - - assets/ - - LICENSE - expire_in: 1 week - -optional-release:windows: - <<: *optional-release - script: - - ln -s /dockercache/cache-release-windows target - - cargo build --verbose --target=x86_64-pc-windows-gnu --release - - cp target/x86_64-pc-windows-gnu/release/veloren-server-cli.exe $CI_PROJECT_DIR - - cp target/x86_64-pc-windows-gnu/release/veloren-voxygen.exe $CI_PROJECT_DIR - artifacts: - paths: - - veloren-server-cli.exe - - veloren-voxygen.exe - - assets/ - - LICENSE - expire_in: 1 week - -optional-release:macos: - <<: *optional-release - script: - - ln -s /dockercache/cache-release-macos target - - PATH="/dockercache/osxcross/target/bin:$PATH" COREAUDIO_SDK_PATH=/dockercache/osxcross/target/SDK/MacOSX10.13.sdk CC=o64-clang CXX=o64-clang++ cargo build --target x86_64-apple-darwin --release - - cp -r target/x86_64-apple-darwin/release/veloren-server-cli $CI_PROJECT_DIR - - cp -r target/x86_64-apple-darwin/release/veloren-voxygen $CI_PROJECT_DIR - artifacts: - paths: - - veloren-server-cli - - veloren-voxygen - - assets/ - - LICENSE - expire_in: 1 week diff --git a/.gitlab/CI/publish.gitlab-ci.yml b/.gitlab/CI/publish.gitlab-ci.yml index c110eb7444..1885f2a284 100644 --- a/.gitlab/CI/publish.gitlab-ci.yml +++ b/.gitlab/CI/publish.gitlab-ci.yml @@ -1,8 +1,16 @@ # Publishes veloren-server-cli to the gitlab container registry # https://gitlab.com/veloren/veloren/container_registry -docker: +.publish: stage: publish - extends: .release + tags: + - veloren-docker + rules: + - when: never + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + when: always + +docker: + extends: .publish image: name: gcr.io/kaniko-project/executor:debug entrypoint: [""] @@ -10,15 +18,12 @@ docker: - linux before_script: - ls "$CI_PROJECT_DIR/server-cli/" - tags: - - veloren-docker script: - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/server-cli/Dockerfile --destination "${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}-server" pages: - extends: .release - stage: publish + extends: .publish artifacts: paths: - public @@ -26,4 +31,4 @@ pages: - rm -rf public - mkdir -p public - cargo doc --no-deps --all-features --document-private-items - - mv target/doc/* public + - mv target/doc/* public \ No newline at end of file diff --git a/.gitlab/CI/recompile.yml b/.gitlab/CI/recompile.yml index a8229856eb..b559c5d710 100644 --- a/.gitlab/CI/recompile.yml +++ b/.gitlab/CI/recompile.yml @@ -1,5 +1,7 @@ # Template to only run if actual changes has been made to the code and not just documentation .recompile-branch: + tags: + - veloren-docker rules: - if: $CI_COMMIT_REF_NAME !~ /^master$/ # No '-' here is *very* important: https://docs.gitlab.com/ee/ci/yaml/#complex-rule-clauses @@ -11,6 +13,8 @@ # like .recompile-branch but will run on master too .recompile: + tags: + - veloren-docker rules: - changes: - "**/*.{rs,ron,toml,vox,png,wav}" diff --git a/.gitlab/CI/release.yml b/.gitlab/CI/release.yml index 98b53a0d32..efddd5e6e5 100644 --- a/.gitlab/CI/release.yml +++ b/.gitlab/CI/release.yml @@ -1,4 +1,20 @@ +# allow_failure: true makes these pipelines manual and "non-blocking" which changed with except -> rule syntax +.optional-release: + stage: build + tags: + - veloren-docker + rules: + - when: manual + allow_failure: true + - if: $CI_COMMIT_REF_NAME =~ /^master$/ || $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+/ || $CI_COMMIT_REF_NAME =~ /^r[0-9]+\.[0-9]+/ || $CI_PIPELINE_SOURCE == "schedule" + when: never + # Template to only run if pushes to master or a tag happened .release: + stage: build + tags: + - veloren-docker rules: - if: $CI_COMMIT_REF_NAME =~ /^master$/ || $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+/ || $CI_COMMIT_REF_NAME =~ /^r[0-9]+\.[0-9]+/ + when: always + - when: never