fabaccess-bffh/.gitlab-ci.yml

197 lines
6.3 KiB
YAML
Raw Normal View History

2020-09-16 12:41:05 +02:00
# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/rust/tags/
image: "rust:latest"
# Optional: Pick zero or more services to be used on all builds.
# Only needed when using a docker container to run your tests in.
# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-a-service
# services:
# - mysql:latest
# - redis:latest
# - postgres:latest
variables:
GIT_SUBMODULE_STRATEGY: recursive
# CARGO_HOME: $CI_PROJECT_DIR/cargo
APT_CACHE_DIR: $CI_PROJECT_DIR/apt
2021-12-28 01:47:24 +01:00
stages:
- lint
- test
- build
- upload
- release
2021-12-28 01:33:12 +01:00
2020-09-16 12:41:05 +02:00
# install build dependencies
before_script:
2021-12-14 15:50:17 +01:00
- apt-get update -y
- apt-get install -o dir::cache::archives="$APT_CACHE_DIR" -y --no-install-recommends capnproto build-essential cmake clang libclang-dev libgsasl7-dev
2020-09-16 12:41:05 +02:00
- rustup update
- rustup component add rustfmt
- rustup component add clippy
# Use clippy to lint the project
lint:clippy:
2021-12-28 01:47:24 +01:00
stage: lint
2020-09-16 12:41:05 +02:00
allow_failure: true
script:
- rustc --version && cargo --version # Print version info for debugging
- cargo clippy -- -D warnings
only:
- master
- development
- merge_requests
2020-09-17 15:07:04 +02:00
tags:
- linux
- docker
2020-09-16 12:41:05 +02:00
# Use rustfmt to check formating of the project
lint:fmt:
2021-12-28 01:47:24 +01:00
stage: lint
2020-09-16 12:41:05 +02:00
allow_failure: true
script:
- rustc --version && cargo --version # Print version info for debugging
- cargo fmt -- --check # TODO: Do we want to enforce formating?
only:
- master
- development
- merge_requests
2020-09-17 15:07:04 +02:00
tags:
- linux
- docker
2020-09-16 12:41:05 +02:00
# Use cargo to test the project
test:cargo:
2021-12-28 01:47:24 +01:00
stage: test
2020-09-16 12:41:05 +02:00
script:
- rustc --version && cargo --version # Print version info for debugging
- cargo test --workspace --verbose
only:
- master
- development
- merge_requests
2020-09-17 15:07:04 +02:00
tags:
- linux
- docker
2020-09-16 12:41:05 +02:00
2021-12-28 01:47:24 +01:00
# build:docker-master:
# image:
# name: gcr.io/kaniko-project/executor:v1.6.0-debug
# entrypoint: [""]
# before_script:
# - ''
# script:
# - mkdir -p /kaniko/.docker
# - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
# - /kaniko/executor --force --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:latest
# only:
# - master
# tags:
# - linux
# - docker
2020-10-06 14:43:40 +02:00
2021-12-28 01:47:24 +01:00
# build:docker-releases:
# image:
# name: gcr.io/kaniko-project/executor:v1.6.0-debug
# entrypoint: [""]
# before_script:
# - ''
# script:
# - mkdir -p /kaniko/.docker
# - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
# - /kaniko/executor --force --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
# only:
# - tags
# tags:
# - linux
# - docker
2020-10-06 14:43:40 +02:00
2021-12-28 01:33:12 +01:00
build:binary:
2021-12-14 15:28:08 +01:00
image: rust:latest
2021-12-28 01:47:24 +01:00
stage: build
2021-12-14 13:35:38 +01:00
before_script:
2021-12-14 15:36:12 +01:00
- cp cargo-cross-config /usr/local/cargo/config
2021-12-14 15:42:36 +01:00
- dpkg --add-architecture armhf
2021-12-26 22:12:20 +01:00
- dpkg --add-architecture armel
2021-12-14 15:50:17 +01:00
- apt-get update -y
2021-12-26 22:12:20 +01:00
- apt-get install -o dir::cache::archives="$APT_CACHE_DIR" -y libc6-armhf-cross libc6-dev-armhf-cross gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libc6-armel-cross libc6-dev-armel-cross gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
- apt-get install -o dir::cache::archives="$APT_CACHE_DIR" -y --no-install-recommends capnproto build-essential cmake clang libclang-dev libgsasl7-dev libgsasl7-dev:armhf libssl-dev:armhf libgsasl7-dev:armel libssl-dev:armel
2021-12-14 15:58:27 +01:00
- rustup target add armv7-unknown-linux-gnueabihf
2021-12-14 15:28:08 +01:00
2020-10-06 14:43:40 +02:00
script:
2021-12-14 16:50:38 +01:00
- cargo update
- cargo build --target armv7-unknown-linux-gnueabihf
- cargo build --target x86_64-unknown-linux-gnu
2021-12-28 00:38:00 +01:00
- ls target/armv7-unknown-linux-gnueabihf
- ls target/x86_64-unknown-linux-gnu
artifacts:
paths:
2021-12-28 01:33:12 +01:00
- target/armv7-unknown-linux-gnueabihf/release
- target/x86_64-unknown-linux-gnu/release
2021-12-14 15:28:08 +01:00
# only:
# - development
tags:
- linux
- docker
2021-12-28 01:47:24 +01:00
upload:nightly:
stage: upload
image: curlimages/curl:latest
variables:
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/diflouroborane/nightly"
2021-12-28 01:49:47 +01:00
# rules:
# - if: $CI_COMMIT_TAG
2021-12-28 01:47:24 +01:00
script:
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file target/armv7-unknown-linux-gnueabihf/release/diflouroborane "${PACKAGE_REGISTRY_URL}/diflouroborane-linux-armv7-nightly"
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file target/x86_64-unknown-linux-gnu/release/diflouroborane "${PACKAGE_REGISTRY_URL}/diflouroborane-linux-amd64-nightly"
tags:
- linux
- docker
2020-09-16 12:41:05 +02:00
2021-12-28 01:47:24 +01:00
upload:releases:
2021-12-28 01:33:12 +01:00
stage: upload
image: curlimages/curl:latest
variables:
2021-12-28 01:47:24 +01:00
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/diflouroborane/${CI_COMMIT_TAG}"
2021-12-28 01:51:16 +01:00
rules:
- if: $CI_COMMIT_TAG
2021-12-28 01:33:12 +01:00
script:
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file target/armv7-unknown-linux-gnueabihf/release/diflouroborane "${PACKAGE_REGISTRY_URL}/diflouroborane-linux-armv7-${CI_COMMIT_TAG}"
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file target/x86_64-unknown-linux-gnu/release/diflouroborane "${PACKAGE_REGISTRY_URL}/diflouroborane-linux-amd64-${CI_COMMIT_TAG}"
2021-12-28 01:47:24 +01:00
tags:
- linux
- docker
2021-12-28 01:33:12 +01:00
release:
# Caution, as of 2021-02-02 these assets links require a login, see:
# https://gitlab.com/gitlab-org/gitlab/-/issues/299384
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
variables:
2021-12-28 01:47:24 +01:00
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/diflouroborane/${CI_COMMIT_TAG}"
2021-12-28 01:33:12 +01:00
rules:
- if: $CI_COMMIT_TAG
script:
- |
release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \
--assets-link "{\"name\":\"diflouroborane-linux-armv7-${CI_COMMIT_TAG}\",\"url\":\"${PACKAGE_REGISTRY_URL}/diflouroborane-linux-armv7-${CI_COMMIT_TAG}\"}" \
--assets-link "{\"name\":\"diflouroborane-linux-amd64-${CI_COMMIT_TAG}\",\"url\":\"${PACKAGE_REGISTRY_URL}/diflouroborane-linux-amd64-${CI_COMMIT_TAG}\"}"
2021-12-28 01:47:24 +01:00
tags:
- linux
- docker
2021-12-28 01:33:12 +01:00
2020-09-16 12:41:05 +02:00
# cache dependencies and build environment to speed up setup
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- apt/
# - cargo/
- target/