2018-06-04 23:06:12 +00:00
|
|
|
image: "rust:slim"
|
|
|
|
|
|
|
|
stages:
|
|
|
|
- check
|
2018-06-23 15:02:02 +00:00
|
|
|
- build
|
2018-06-04 23:06:12 +00:00
|
|
|
- test
|
|
|
|
- release
|
|
|
|
|
|
|
|
variables:
|
|
|
|
RUST_VERSION: stable
|
|
|
|
|
2018-11-20 15:23:32 +00:00
|
|
|
# Cache rust/cargo/build artifacts
|
|
|
|
cache:
|
|
|
|
key: "$CI_PIPELINE_ID-$RUST_VERSION"
|
|
|
|
paths:
|
|
|
|
- /usr/local/cargo/registry/
|
|
|
|
- /usr/local/rustup/toolchains/
|
|
|
|
- /usr/local/rustup/update-hashes/
|
|
|
|
- target/
|
|
|
|
|
2018-06-04 23:06:12 +00:00
|
|
|
# Install compiler and OpenSSL dependencies
|
|
|
|
before_script:
|
2018-06-23 15:02:02 +00:00
|
|
|
- apt-get update
|
2018-06-04 23:06:12 +00:00
|
|
|
- apt-get install -y --no-install-recommends build-essential pkg-config libssl-dev
|
2018-06-23 15:02:02 +00:00
|
|
|
- |
|
|
|
|
rustup install $RUST_VERSION
|
|
|
|
rustup default $RUST_VERSION
|
|
|
|
- |
|
|
|
|
rustc --version
|
|
|
|
cargo --version
|
2018-06-04 23:06:12 +00:00
|
|
|
|
2018-06-18 17:20:55 +00:00
|
|
|
# Variable defaults
|
|
|
|
variables:
|
|
|
|
RUST_VERSION: stable
|
|
|
|
|
2018-06-04 23:06:12 +00:00
|
|
|
# Check on stable, beta and nightly
|
|
|
|
.check-base: &check-base
|
|
|
|
stage: check
|
|
|
|
script:
|
2018-06-23 15:02:02 +00:00
|
|
|
- cargo check --verbose
|
|
|
|
- cargo check --no-default-features --verbose
|
|
|
|
- cargo check --features no-color --verbose
|
2018-06-18 18:31:36 +00:00
|
|
|
rust-stable:
|
2018-06-04 23:06:12 +00:00
|
|
|
<<: *check-base
|
2018-06-18 18:31:36 +00:00
|
|
|
rust-beta:
|
2018-06-04 23:06:12 +00:00
|
|
|
<<: *check-base
|
|
|
|
variables:
|
|
|
|
RUST_VERSION: beta
|
2018-06-18 18:31:36 +00:00
|
|
|
rust-nightly:
|
2018-06-04 23:06:12 +00:00
|
|
|
<<: *check-base
|
|
|
|
variables:
|
|
|
|
RUST_VERSION: nightly
|
2018-06-23 15:02:02 +00:00
|
|
|
|
|
|
|
# Build using Rust stable
|
|
|
|
build:
|
|
|
|
stage: build
|
|
|
|
script:
|
|
|
|
- cargo build --release --verbose
|
|
|
|
- mv target/release/ffsend ./ffsend
|
|
|
|
artifacts:
|
|
|
|
name: build-dynamic
|
|
|
|
paths:
|
|
|
|
- ffsend
|
|
|
|
expire_in: 1 month
|
|
|
|
|
|
|
|
# Build a static version
|
|
|
|
build-static:
|
|
|
|
stage: build
|
|
|
|
script:
|
|
|
|
# Install the static target
|
|
|
|
- rustup target add x86_64-unknown-linux-musl
|
|
|
|
|
|
|
|
# Build OpenSSL statically
|
|
|
|
- apt install -y build-essential wget musl-tools
|
|
|
|
- wget https://www.openssl.org/source/openssl-1.0.2o.tar.gz
|
|
|
|
- tar xzvf openssl-1.0.2o.tar.gz
|
|
|
|
- cd openssl-1.0.2o
|
|
|
|
- ./config -fPIC --openssldir=/usr/local/ssl --prefix=/usr/local
|
|
|
|
- make
|
|
|
|
- make install
|
|
|
|
- cd ..
|
|
|
|
|
|
|
|
# Statically build ffsend
|
|
|
|
- export OPENSSL_STATIC=1
|
|
|
|
- export OPENSSL_LIB_DIR=/usr/local/lib
|
|
|
|
- export OPENSSL_INCLUDE_DIR=/usr/local/include
|
|
|
|
- cargo build --target=x86_64-unknown-linux-musl --release --verbose
|
|
|
|
|
|
|
|
# Prepare the release artifact
|
|
|
|
- find . -name ffsend -exec ls -lah {} \;
|
|
|
|
- mv target/x86_64-unknown-linux-musl/release/ffsend ./ffsend
|
|
|
|
artifacts:
|
|
|
|
name: build-static
|
|
|
|
paths:
|
|
|
|
- ffsend
|
|
|
|
expire_in: 1 month
|
2018-06-04 23:06:12 +00:00
|
|
|
|
2018-06-18 16:54:14 +00:00
|
|
|
# Run the unit tests through Cargo
|
2018-06-18 18:31:36 +00:00
|
|
|
cargo-test:
|
2018-06-04 23:06:12 +00:00
|
|
|
stage: test
|
2018-06-23 15:02:02 +00:00
|
|
|
dependencies: []
|
2018-06-04 23:06:12 +00:00
|
|
|
script:
|
2018-06-23 15:02:02 +00:00
|
|
|
- cargo test --verbose
|
2018-06-04 23:06:12 +00:00
|
|
|
|
|
|
|
# Run integration test with the public Send service
|
2018-06-18 18:31:36 +00:00
|
|
|
public-send-test:
|
2018-06-23 15:02:02 +00:00
|
|
|
stage: test
|
|
|
|
dependencies:
|
|
|
|
- build-static
|
|
|
|
variables:
|
|
|
|
GIT_STRATEGY: none
|
|
|
|
before_script: []
|
2018-06-04 23:06:12 +00:00
|
|
|
script:
|
2018-11-21 21:10:52 +00:00
|
|
|
# Generate random file, upload/download and assert equality
|
2018-11-21 21:12:22 +00:00
|
|
|
- "head -c16m </dev/urandom >testfile"
|
|
|
|
- "./ffsend upload testfile -n testfile.bin -a -d 10 -p secret -I"
|
2018-11-21 21:13:15 +00:00
|
|
|
- "./ffsend download $(./ffsend history -q) -p secret -I -o downloadfile"
|
2018-11-21 21:12:22 +00:00
|
|
|
- "cmp --silent ./testfile ./downloadfile || (echo ERROR: Downloaded file is different than original; exit 1)"
|
2018-10-17 15:48:37 +00:00
|
|
|
|
|
|
|
# Cargo crate release
|
|
|
|
crate:
|
|
|
|
stage: release
|
|
|
|
only:
|
|
|
|
- /^v(\d+\.)*\d+$/
|
|
|
|
script:
|
|
|
|
- echo "Creating release crate to publish on crates.io..."
|
|
|
|
- echo $CARGO_TOKEN | cargo login
|
|
|
|
- echo "Publishing crate to crates.io..."
|
2018-10-17 18:26:25 +00:00
|
|
|
- cargo publish --verbose --allow-dirty
|