Conduit is a simple, fast and reliable chat server powered by Matrix https://conduit.rs
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
349 lines
13 KiB
349 lines
13 KiB
stages: |
|
- build |
|
- build docker image |
|
- test |
|
- upload artifacts |
|
|
|
variables: |
|
GIT_SUBMODULE_STRATEGY: recursive |
|
FF_USE_FASTZIP: 1 |
|
CACHE_COMPRESSION_LEVEL: fastest |
|
|
|
|
|
# --------------------------------------------------------------------- # |
|
# Cargo: Compiling for different architectures # |
|
# --------------------------------------------------------------------- # |
|
|
|
.build-cargo-shared-settings: |
|
stage: "build" |
|
needs: [] |
|
rules: |
|
- if: '$CI_COMMIT_BRANCH == "master"' |
|
- if: '$CI_COMMIT_BRANCH == "next"' |
|
- if: '$CI_COMMIT_TAG' |
|
# TODO: Remove this before merging: |
|
- if: '$CI_COMMIT_BRANCH == "better-multiarch-building-the-second-attempt"' |
|
interruptible: true |
|
image: "rust:latest" |
|
tags: [ "docker" ] |
|
cache: |
|
paths: |
|
- cargohome |
|
- target/ |
|
key: "build_cache--$TARGET--$CI_COMMIT_BRANCH--release" |
|
variables: |
|
CARGO_PROFILE_RELEASE_LTO: "true" |
|
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "1" |
|
before_script: |
|
- 'echo "Building for target $TARGET"' |
|
- 'mkdir -p cargohome && CARGOHOME="cargohome"' |
|
- "rustc --version && cargo --version && rustup show" # Print version info for debugging |
|
- "rustup target add $TARGET" |
|
script: |
|
- time cargo build --target $TARGET --release |
|
- 'cp "target/$TARGET/release/conduit" "conduit-$TARGET"' |
|
artifacts: |
|
expire_in: never |
|
|
|
build:release:cargo:x86_64-unknown-linux-musl-with-debug: |
|
extends: .build-cargo-shared-settings |
|
image: messense/rust-musl-cross:x86_64-musl |
|
variables: |
|
CARGO_PROFILE_RELEASE_DEBUG: 2 # Enable debug info for flamegraph profiling |
|
TARGET: "x86_64-unknown-linux-musl" |
|
after_script: |
|
- "mv ./conduit-x86_64-unknown-linux-musl ./conduit-x86_64-unknown-linux-musl-with-debug" |
|
artifacts: |
|
name: "conduit-x86_64-unknown-linux-musl-with-debug" |
|
paths: |
|
- "conduit-x86_64-unknown-linux-musl-with-debug" |
|
expose_as: "Conduit for x86_64-unknown-linux-musl-with-debug" |
|
|
|
build:release:cargo:x86_64-unknown-linux-musl: |
|
extends: .build-cargo-shared-settings |
|
image: messense/rust-musl-cross:x86_64-musl |
|
variables: |
|
TARGET: "x86_64-unknown-linux-musl" |
|
artifacts: |
|
name: "conduit-x86_64-unknown-linux-musl" |
|
paths: |
|
- "conduit-x86_64-unknown-linux-musl" |
|
expose_as: "Conduit for x86_64-unknown-linux-musl" |
|
|
|
build:release:cargo:arm-unknown-linux-musleabihf: |
|
extends: .build-cargo-shared-settings |
|
image: messense/rust-musl-cross:arm-musleabihf |
|
variables: |
|
TARGET: "arm-unknown-linux-musleabihf" |
|
artifacts: |
|
name: "conduit-arm-unknown-linux-musleabihf" |
|
paths: |
|
- "conduit-arm-unknown-linux-musleabihf" |
|
expose_as: "Conduit for arm-unknown-linux-musleabihf" |
|
|
|
build:release:cargo:armv7-unknown-linux-musleabihf: |
|
extends: .build-cargo-shared-settings |
|
image: messense/rust-musl-cross:armv7-musleabihf |
|
variables: |
|
TARGET: "armv7-unknown-linux-musleabihf" |
|
artifacts: |
|
name: "conduit-armv7-unknown-linux-musleabihf" |
|
paths: |
|
- "conduit-armv7-unknown-linux-musleabihf" |
|
expose_as: "Conduit for armv7-unknown-linux-musleabihf" |
|
|
|
build:release:cargo:aarch64-unknown-linux-musl: |
|
extends: .build-cargo-shared-settings |
|
image: messense/rust-musl-cross:aarch64-musl |
|
variables: |
|
TARGET: "aarch64-unknown-linux-musl" |
|
artifacts: |
|
name: "conduit-aarch64-unknown-linux-musl" |
|
paths: |
|
- "conduit-aarch64-unknown-linux-musl" |
|
expose_as: "Conduit for aarch64-unknown-linux-musl" |
|
|
|
|
|
.cargo-debug-shared-settings: |
|
extends: ".build-cargo-shared-settings" |
|
rules: |
|
- if: '$CI_COMMIT_BRANCH != "master"' |
|
cache: |
|
key: "build_cache--$TARGET--$CI_COMMIT_BRANCH--debug" |
|
script: |
|
- "time cargo build --target $TARGET" |
|
- 'mv "target/$TARGET/debug/conduit" "conduit-debug-$TARGET"' |
|
artifacts: |
|
expire_in: 4 weeks |
|
|
|
build:debug:cargo:x86_64-unknown-linux-musl: |
|
extends: ".cargo-debug-shared-settings" |
|
image: messense/rust-musl-cross:x86_64-musl |
|
variables: |
|
TARGET: "x86_64-unknown-linux-musl" |
|
artifacts: |
|
name: "conduit-debug-x86_64-unknown-linux-musl" |
|
paths: |
|
- "conduit-debug-x86_64-unknown-linux-musl" |
|
expose_as: "Conduit DEBUG for x86_64-unknown-linux-musl" |
|
|
|
|
|
# --------------------------------------------------------------------- # |
|
# Cargo: Compiling deb packages for different architectures # |
|
# --------------------------------------------------------------------- # |
|
|
|
|
|
#.build-cargo-deb-shared-settings: |
|
# stage: "build" |
|
# needs: [ ] |
|
# rules: |
|
# - if: '$CI_COMMIT_BRANCH == "master"' |
|
# - if: '$CI_COMMIT_BRANCH == "next"' |
|
# - if: '$CI_COMMIT_TAG' |
|
# interruptible: true |
|
# image: "rust:latest" |
|
# tags: ["docker"] |
|
# cache: |
|
# paths: |
|
# - cargohome |
|
# - target/ |
|
# key: "build_cache-deb-$TARGET" |
|
# before_script: |
|
# - 'echo "Building debian package for target $TARGET"' |
|
# - 'mkdir -p cargohome && CARGOHOME="cargohome"' |
|
# - "cat /etc/*-release && rustc --version && cargo --version" # Print version info for debugging |
|
# - 'apt-get update -yqq' |
|
# - 'echo "Installing packages: $NEEDED_PACKAGES"' |
|
# - "apt-get install -yqq --no-install-recommends $NEEDED_PACKAGES" |
|
# - "rustup target add $TARGET" |
|
# - "cargo install cargo-deb" |
|
# script: |
|
# - time cargo deb --target $TARGET |
|
# - 'mv target/$TARGET/debian/*.deb "conduit-$TARGET.deb"' |
|
# |
|
#build:cargo-deb:x86_64-unknown-linux-gnu: |
|
# extends: .build-cargo-deb-shared-settings |
|
# variables: |
|
# TARGET: "x86_64-unknown-linux-gnu" |
|
# NEEDED_PACKAGES: "" |
|
# artifacts: |
|
# name: "conduit-x86_64-unknown-linux-gnu.deb" |
|
# paths: |
|
# - "conduit-x86_64-unknown-linux-gnu.deb" |
|
# expose_as: "Debian Package x86_64" |
|
# |
|
|
|
# --------------------------------------------------------------------- # |
|
# Create and publish docker image # |
|
# --------------------------------------------------------------------- # |
|
|
|
|
|
build:docker:new-way-of-building: |
|
stage: "build docker image" |
|
image: jdrouet/docker-with-buildx:stable |
|
tags: [ "docker" ] |
|
services: |
|
- docker:dind |
|
needs: |
|
- "build:release:cargo:x86_64-unknown-linux-musl" |
|
- "build:release:cargo:arm-unknown-linux-musleabihf" |
|
- "build:release:cargo:armv7-unknown-linux-musleabihf" |
|
- "build:release:cargo:aarch64-unknown-linux-musl" |
|
rules: |
|
- if: '$CI_COMMIT_BRANCH == "master"' |
|
- if: '$CI_COMMIT_BRANCH == "next"' |
|
# TODO: Remove this after debugging |
|
- if: '$CI_COMMIT_BRANCH == "better-multiarch-building-the-second-attempt"' |
|
variables: |
|
DOCKER_HOST: tcp://docker:2375/ |
|
DOCKER_TLS_CERTDIR: "" |
|
DOCKER_DRIVER: overlay2 |
|
PLATFORMS: "linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/amd64" |
|
IMAGE_TAG: "$CI_REGISTRY_IMAGE/debug-conduit:multiarch-test-dont-use-yet" |
|
DOCKER_FILE: "docker/ci-binaries-packaging.Dockerfile" |
|
before_script: |
|
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY |
|
script: |
|
# Prepare buildx to build multiarch stuff: |
|
- docker context create 'ci-context' |
|
- docker buildx create --name 'multiarch-builder' --use 'ci-context' |
|
# Copy binaries to their docker arch path |
|
- mkdir -p linux/ && mv ./conduit-x86_64-unknown-linux-musl linux/amd64 |
|
- mkdir -p linux/arm/ && mv ./conduit-arm-unknown-linux-musleabihf linux/arm/v6 |
|
- mkdir -p linux/arm/ && mv ./conduit-armv7-unknown-linux-musleabihf linux/arm/v7 |
|
- mkdir -p linux/arm64/ && mv ./conduit-aarch64-unknown-linux-musl linux/arm64/v8 |
|
# Actually create multiarch image: |
|
- docker buildx build --pull --squash --push --platform $PLATFORMS --tag $IMAGE_TAG --file $DOCKER_FILE . |
|
|
|
|
|
## Build a docker image by packaging up the x86_64-unknown-linux-musl binary into an alpine image |
|
#.docker-shared-settings: |
|
# stage: "build docker image" |
|
# needs: [] |
|
# interruptible: true |
|
# image: |
|
# name: "gcr.io/kaniko-project/executor:debug" |
|
# entrypoint: [""] |
|
# tags: ["docker"] |
|
# variables: |
|
# # Configure Kaniko Caching: https://cloud.google.com/build/docs/kaniko-cache |
|
# KANIKO_CACHE_ARGS: "--cache=true --cache-copy-layers=true --cache-ttl=120h --cache-repo $CI_REGISTRY_IMAGE/kaniko-ci-cache" |
|
# before_script: |
|
# - "mkdir -p /kaniko/.docker" |
|
# - 'echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"},\"$DOCKER_HUB\":{\"username\":\"$DOCKER_HUB_USER\",\"password\":\"$DOCKER_HUB_PASSWORD\"}}}" > /kaniko/.docker/config.json' |
|
# |
|
# |
|
#build:docker:next: |
|
# extends: .docker-shared-settings |
|
# needs: |
|
# - "build:release:cargo:x86_64-unknown-linux-musl" |
|
# script: |
|
# - > |
|
# /kaniko/executor |
|
# $KANIKO_CACHE_ARGS |
|
# --force |
|
# --context $CI_PROJECT_DIR |
|
# --build-arg CREATED=$(date -u +'%Y-%m-%dT%H:%M:%SZ') |
|
# --build-arg VERSION=$(grep -m1 -o '[0-9].[0-9].[0-9]' Cargo.toml) |
|
# --build-arg "GIT_REF=$CI_COMMIT_SHORT_SHA" |
|
# --dockerfile "$CI_PROJECT_DIR/docker/ci-binaries-packaging.Dockerfile" |
|
# --destination "$CI_REGISTRY_IMAGE/conduit:next" |
|
# --destination "$CI_REGISTRY_IMAGE/conduit:next-alpine" |
|
# --destination "$CI_REGISTRY_IMAGE/conduit:commit-$CI_COMMIT_SHORT_SHA" |
|
# --destination "$DOCKER_HUB_IMAGE/matrixconduit/matrix-conduit:next" |
|
# --destination "$DOCKER_HUB_IMAGE/matrixconduit/matrix-conduit:next-alpine" |
|
# --destination "$DOCKER_HUB_IMAGE/matrixconduit/matrix-conduit:commit-$CI_COMMIT_SHORT_SHA" |
|
# rules: |
|
# - if: '$CI_COMMIT_BRANCH == "next"' |
|
# |
|
# |
|
|
|
|
|
# --------------------------------------------------------------------- # |
|
# Run tests # |
|
# --------------------------------------------------------------------- # |
|
|
|
test:cargo: |
|
stage: "test" |
|
needs: [ ] |
|
image: "rust:latest" |
|
tags: [ "docker" ] |
|
variables: |
|
CARGO_HOME: "cargohome" |
|
cache: |
|
paths: |
|
- target |
|
- cargohome |
|
key: test_cache |
|
interruptible: true |
|
before_script: |
|
- mkdir -p $CARGO_HOME && echo "using $CARGO_HOME to cache cargo deps" |
|
- apt-get update -yqq |
|
- apt-get install -yqq --no-install-recommends build-essential libssl-dev pkg-config |
|
- rustup component add clippy rustfmt |
|
script: |
|
- rustc --version && cargo --version # Print version info for debugging |
|
- cargo fmt --all -- --check |
|
- cargo test --workspace --verbose --locked |
|
- cargo clippy |
|
|
|
test:sytest: |
|
stage: "test" |
|
allow_failure: true |
|
needs: |
|
- "build:debug:cargo:x86_64-unknown-linux-musl" |
|
image: |
|
name: "valkum/sytest-conduit:latest" |
|
entrypoint: [ "" ] |
|
tags: [ "docker" ] |
|
variables: |
|
PLUGINS: "https://github.com/valkum/sytest_conduit/archive/master.tar.gz" |
|
before_script: |
|
- "mkdir -p /app" |
|
- "cp ./conduit-debug-x86_64-unknown-linux-musl /app/conduit" |
|
- "chmod +x /app/conduit" |
|
- "rm -rf /src && ln -s $CI_PROJECT_DIR/ /src" |
|
- "mkdir -p /work/server-0/database/ && mkdir -p /work/server-1/database/ && mkdir -p /work/server-2/database/" |
|
- "cd /" |
|
script: |
|
- "SYTEST_EXIT_CODE=0" |
|
- "/bootstrap.sh conduit || SYTEST_EXIT_CODE=1" |
|
- "perl /sytest/tap-to-junit-xml.pl --puretap --input /logs/results.tap --output $CI_PROJECT_DIR/sytest.xml \"Sytest\" && cp /logs/results.tap $CI_PROJECT_DIR/results.tap" |
|
- "exit $SYTEST_EXIT_CODE" |
|
artifacts: |
|
when: always |
|
paths: |
|
- "$CI_PROJECT_DIR/sytest.xml" |
|
- "$CI_PROJECT_DIR/results.tap" |
|
reports: |
|
junit: "$CI_PROJECT_DIR/sytest.xml" |
|
|
|
|
|
# --------------------------------------------------------------------- # |
|
# Store binaries as package so they have download urls # |
|
# --------------------------------------------------------------------- # |
|
|
|
publish:package: |
|
stage: "upload artifacts" |
|
needs: |
|
- "build:release:cargo:x86_64-unknown-linux-musl" |
|
- "build:release:cargo:arm-unknown-linux-musleabihf" |
|
- "build:release:cargo:armv7-unknown-linux-musleabihf" |
|
- "build:release:cargo:aarch64-unknown-linux-musl" |
|
# - "build:cargo-deb:x86_64-unknown-linux-gnu" |
|
rules: |
|
- if: '$CI_COMMIT_BRANCH == "master"' |
|
- if: '$CI_COMMIT_BRANCH == "next"' |
|
- if: '$CI_COMMIT_TAG' |
|
image: curlimages/curl:latest |
|
tags: [ "docker" ] |
|
variables: |
|
GIT_STRATEGY: "none" # Don't need a clean copy of the code, we just operate on artifacts |
|
script: |
|
- 'BASE_URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/conduit-${CI_COMMIT_REF_SLUG}/build-${CI_PIPELINE_ID}"' |
|
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file conduit-x86_64-unknown-linux-musl "${BASE_URL}/conduit-x86_64-unknown-linux-musl"' |
|
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file conduit-arm-unknown-linux-musleabihf "${BASE_URL}/conduit-arm-unknown-linux-musleabihf"' |
|
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file conduit-armv7-unknown-linux-musleabihf "${BASE_URL}/conduit-armv7-unknown-linux-musleabihf"' |
|
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file conduit-aarch64-unknown-linux-musl "${BASE_URL}/conduit-aarch64-unknown-linux-musl"' |
|
|
|
|
|
|