mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
simply scripts alot, not the null check is necessray because gitlab ci regex with variables is weird and would contain errors otherwise.
limit pages to master run only, as we dont export scheduled pages
This commit is contained in:
parent
203fe7ad47
commit
618d4b2340
@ -14,6 +14,7 @@ variables:
|
|||||||
GIT_DEPTH: 3
|
GIT_DEPTH: 3
|
||||||
GIT_CLEAN_FLAGS: -f
|
GIT_CLEAN_FLAGS: -f
|
||||||
CACHE_IMAGE_TAG: d7756444
|
CACHE_IMAGE_TAG: d7756444
|
||||||
|
TAG_REGEX: '/^v[0-9]+\.[0-9]+\.[0-9]+$/'
|
||||||
|
|
||||||
default:
|
default:
|
||||||
# https://docs.gitlab.com/ee/ci/pipelines/settings.html#auto-cancel-pending-pipelines
|
# https://docs.gitlab.com/ee/ci/pipelines/settings.html#auto-cancel-pending-pipelines
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
# cargo clippy is a superset of cargo check, so we don't check manually
|
|
||||||
code-quality:
|
code-quality:
|
||||||
extends: .recompile-branch
|
extends: .recompile-branch
|
||||||
stage: check
|
stage: check
|
||||||
image: registry.gitlab.com/veloren/veloren-docker-ci/cache/quality:${CACHE_IMAGE_TAG}
|
image: registry.gitlab.com/veloren/veloren-docker-ci/cache/quality:${CACHE_IMAGE_TAG}
|
||||||
tags: ["veloren/veloren", "check"]
|
tags: ["veloren/veloren", "check"]
|
||||||
script:
|
script:
|
||||||
|
- echo $CI_COMMIT_TAG
|
||||||
|
- echo $TAG_REGEX
|
||||||
- ln -s /dockercache/target target
|
- ln -s /dockercache/target target
|
||||||
- cat ./.gitlab/scripts/code-quality.sh
|
- cat ./.gitlab/scripts/code-quality.sh
|
||||||
- source ./.gitlab/scripts/code-quality.sh
|
- source ./.gitlab/scripts/code-quality.sh
|
||||||
|
@ -8,10 +8,6 @@
|
|||||||
- when: never
|
- when: never
|
||||||
before_script:
|
before_script:
|
||||||
- source "$CI_PROJECT_DIR/.gitlab/scripts/utils.sh"
|
- source "$CI_PROJECT_DIR/.gitlab/scripts/utils.sh"
|
||||||
- publishtype PUBLISH_TYPE
|
|
||||||
- publishdockertag PUBLISH_DOCKER_TAG
|
|
||||||
- publishgittag PUBLISH_GIT_TAG
|
|
||||||
- echo "Publish detected '$PUBLISH_TYPE' Docker Tag '$PUBLISH_DOCKER_TAG' Git Tag '$PUBLISH_GIT_TAG'"
|
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
extends: .publish
|
extends: .publish
|
||||||
@ -29,7 +25,8 @@ docker:
|
|||||||
- export container=docker
|
- export container=docker
|
||||||
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
|
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
|
||||||
- |
|
- |
|
||||||
if [[ ! -z "${PUBLISH_DOCKER_TAG}" ]]; then
|
publishdockertag PUBLISH_DOCKER_TAG
|
||||||
|
if [ "${PUBLISH_DOCKER_TAG}" != "" ]; then
|
||||||
/kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/server-cli/Dockerfile --destination "${CI_REGISTRY_IMAGE}/server-cli:${PUBLISH_DOCKER_TAG}"
|
/kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/server-cli/Dockerfile --destination "${CI_REGISTRY_IMAGE}/server-cli:${PUBLISH_DOCKER_TAG}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -43,13 +40,16 @@ gittag:
|
|||||||
- git config --global http.postBuffer 52428800
|
- git config --global http.postBuffer 52428800
|
||||||
- git remote set-url origin https://veloren-bot:${GITLAB_TOKEN_WRITE}@${CI_PROJECT_URL:8}
|
- git remote set-url origin https://veloren-bot:${GITLAB_TOKEN_WRITE}@${CI_PROJECT_URL:8}
|
||||||
- |
|
- |
|
||||||
if [[ ! -z "${PUBLISH_GIT_TAG}" ]]; then
|
publishgittag PUBLISH_GIT_TAG
|
||||||
|
if [ "${PUBLISH_GIT_TAG}" != "" ]; then
|
||||||
git tag -a "${PUBLISH_GIT_TAG}" -m '' -f;
|
git tag -a "${PUBLISH_GIT_TAG}" -m '' -f;
|
||||||
git push origin "${PUBLISH_GIT_TAG}" -f;
|
git push origin "${PUBLISH_GIT_TAG}" -f;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
extends: .publish
|
extends: .publish
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE != "schedule"
|
||||||
image: registry.gitlab.com/veloren/veloren-docker-ci/cache/quality:${CACHE_IMAGE_TAG}
|
image: registry.gitlab.com/veloren/veloren-docker-ci/cache/quality:${CACHE_IMAGE_TAG}
|
||||||
tags: ["veloren/veloren", "publish"]
|
tags: ["veloren/veloren", "publish"]
|
||||||
artifacts:
|
artifacts:
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
.optional-release:
|
.optional-release:
|
||||||
stage: check
|
stage: check
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_PIPELINE_SOURCE != "merge_request_event" || $CI_PIPELINE_SOURCE == "schedule" || $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+/
|
- if: $CI_PIPELINE_SOURCE != "merge_request_event" || $CI_PIPELINE_SOURCE == "schedule" || ( $CI_COMMIT_TAG != null && $CI_COMMIT_TAG =~ $TAG_REGEX )
|
||||||
when: never
|
when: never
|
||||||
- when: manual
|
- when: manual
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
@ -11,7 +11,7 @@
|
|||||||
.release:
|
.release:
|
||||||
stage: build
|
stage: build
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_PIPELINE_SOURCE != "merge_request_event" && ($CI_PIPELINE_SOURCE == "schedule" || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+/)
|
- if: $CI_PIPELINE_SOURCE != "merge_request_event" && ( $CI_PIPELINE_SOURCE == "schedule" || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || ( $CI_COMMIT_TAG != null && $CI_COMMIT_TAG =~ $TAG_REGEX ) )
|
||||||
when: on_success
|
when: on_success
|
||||||
- when: never
|
- when: never
|
||||||
retry:
|
retry:
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# cargo clippy is a superset of cargo check, so we don't check manually
|
||||||
time cargo clippy --all-targets --locked --features="bin_cmd_doc_gen,bin_compression,bin_csv,bin_graphviz,bin_bot,bin_asset_migrate,asset_tweak" -- -D warnings &&
|
time cargo clippy --all-targets --locked --features="bin_cmd_doc_gen,bin_compression,bin_csv,bin_graphviz,bin_bot,bin_asset_migrate,asset_tweak" -- -D warnings &&
|
||||||
# Ensure that the veloren-voxygen default-publish feature builds as it excludes some default features
|
# Ensure that the veloren-voxygen default-publish feature builds as it excludes some default features
|
||||||
time cargo clippy -p veloren-voxygen --locked --no-default-features --features="default-publish" -- -D warnings &&
|
time cargo clippy -p veloren-voxygen --locked --no-default-features --features="default-publish" -- -D warnings &&
|
||||||
|
@ -1,97 +1,49 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
### forbid setting SCHEDULE_CADENCE to v0.1.2 syntax
|
### returns respective DOCKER TAG
|
||||||
sanitize () {
|
### release-tag => <release-tag> (e.g. v1.2.3)
|
||||||
|
### schedule => <SCHEDULE_CADENCE> (e.g. nightly)
|
||||||
|
### master => "master"
|
||||||
|
### else => ""
|
||||||
|
publishdockertag () {
|
||||||
|
# this stores the result in a variable defined by the caller
|
||||||
local -n VAR=$1
|
local -n VAR=$1
|
||||||
INPUT=$2
|
|
||||||
if [[ "${INPUT}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
|
|
||||||
echo "---WARN---SANITIZE---ACTIVE---"
|
|
||||||
VAR="";
|
VAR="";
|
||||||
return 1;
|
if [[ "${CI_COMMIT_TAG}" =~ ${TAG_REGEX} ]]; then
|
||||||
fi
|
VAR="${CI_COMMIT_TAG}";
|
||||||
VAR="${INPUT}";
|
|
||||||
}
|
|
||||||
|
|
||||||
### returns the respective type of publish for the ci
|
|
||||||
### 0 => optional build/no publish
|
|
||||||
### 10 => master build
|
|
||||||
### 20 => scheduled build
|
|
||||||
### 30 => release build
|
|
||||||
publishtype () {
|
|
||||||
local -n VAR=$1
|
|
||||||
if [[ "${CI_COMMIT_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
|
|
||||||
VAR=30;
|
|
||||||
return 0;
|
return 0;
|
||||||
fi
|
fi
|
||||||
if [[ -z "${SCHEDULE_CADENCE}" && ${CI_PIPELINE_SOURCE} == "schedule" ]]; then
|
if [[ -z "${SCHEDULE_CADENCE}" && ${CI_PIPELINE_SOURCE} == "schedule" ]]; then
|
||||||
VAR=20;
|
# sanitize check
|
||||||
|
if [[ "${SCHEDULE_CADENCE}" =~ ${TAG_REGEX} ]]; then
|
||||||
|
VAR="invalid_cadence";
|
||||||
|
else
|
||||||
|
VAR="${SCHEDULE_CADENCE}";
|
||||||
|
fi
|
||||||
return 0;
|
return 0;
|
||||||
fi
|
fi
|
||||||
if [[ ${CI_COMMIT_BRANCH} == ${CI_DEFAULT_BRANCH} ]]; then
|
if [[ ${CI_COMMIT_BRANCH} == ${CI_DEFAULT_BRANCH} ]]; then
|
||||||
VAR=10;
|
|
||||||
return 0;
|
|
||||||
fi
|
|
||||||
VAR=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
### returns respective DOCKER TAG
|
|
||||||
### 0 => exit code 3
|
|
||||||
### 10 => master
|
|
||||||
### 20 => <SCHEDULE_CADENCE>
|
|
||||||
### 30 => <tag>
|
|
||||||
### else => exit code 7
|
|
||||||
|
|
||||||
publishdockertag () {
|
|
||||||
local -n VAR=$1
|
|
||||||
INPUT=$2
|
|
||||||
if [[ "${INPUT}" == "0" ]]; then
|
|
||||||
VAR="";
|
|
||||||
return 3;
|
|
||||||
fi
|
|
||||||
if [[ "${INPUT}" == "10" ]]; then
|
|
||||||
VAR="master";
|
VAR="master";
|
||||||
return 0;
|
return 0;
|
||||||
fi
|
fi
|
||||||
if [[ "${INPUT}" == "20" ]]; then
|
|
||||||
VAR="${SCHEDULE_CADENCE}";
|
|
||||||
sanitize $1 "${VAR}";
|
|
||||||
return 0;
|
|
||||||
fi
|
|
||||||
if [[ "${INPUT}" == "30" ]]; then
|
|
||||||
VAR="${CI_COMMIT_TAG}";
|
|
||||||
return 0;
|
|
||||||
fi
|
|
||||||
VAR="";
|
|
||||||
return 7;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
### returns respective GIT TAG
|
### returns respective GIT TAG
|
||||||
### 0 => exit code 3
|
### release-tag => "" (releases already have a tag)
|
||||||
### 10 => exit code 4
|
### schedule => <SCHEDULE_CADENCE> (e.g. nightly)
|
||||||
### 20 => <SCHEDULE_CADENCE>
|
### master => "" (master doesn't need a tag)
|
||||||
### 30 => exit code 6
|
### else => ""
|
||||||
### else => exit code 7
|
|
||||||
|
|
||||||
publishgittag () {
|
publishgittag () {
|
||||||
local -n VAR=$1
|
local -n VAR=$1
|
||||||
INPUT=$2
|
if [[ -z "${SCHEDULE_CADENCE}" && ${CI_PIPELINE_SOURCE} == "schedule" ]]; then
|
||||||
if [[ "${INPUT}" == "0" ]]; then
|
VAR="${SCHEDULE_CADENCE}";
|
||||||
VAR="";
|
# sanitize check
|
||||||
return 3;
|
if [[ "${SCHEDULE_CADENCE}" =~ ${TAG_REGEX} ]]; then
|
||||||
fi
|
VAR="invalid_cadence";
|
||||||
if [[ "${INPUT}" == "10" ]]; then
|
else
|
||||||
VAR="";
|
|
||||||
return 4;
|
|
||||||
fi
|
|
||||||
if [[ "${INPUT}" == "20" ]]; then
|
|
||||||
VAR="${SCHEDULE_CADENCE}";
|
VAR="${SCHEDULE_CADENCE}";
|
||||||
sanitize $1 "${VAR}";
|
|
||||||
return 0;
|
|
||||||
fi
|
fi
|
||||||
if [[ "${INPUT}" == "30" ]]; then
|
|
||||||
VAR="${CI_COMMIT_TAG}";
|
|
||||||
return 0;
|
return 0;
|
||||||
fi
|
fi
|
||||||
VAR="";
|
VAR="";
|
||||||
return 7;
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user