Verified Commit 0b8e5e7f authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

first commit

parents
stages:
- test
- build
- publish
include:
- project: 'sschuepbach/ci-templates'
ref: 'modular'
file: 'helm/default.yml'
default:
image: rust:alpine
variables:
BIN_NAME: dummy-app
###############
# Stage: test #
###############
test:
stage: test
before_script:
- rustup self update
- rustup component add clippy
script:
- cargo test --bin $BIN_NAME
- cargo clippy --bin $BIN_NAME
except:
- tags
################
# Stage: build #
################
build:
stage: build
script:
- cargo build --release --bin $BIN_NAME
- strip target/release/$BIN_NAME
- upx --best -q --lzma target/release/$BIN_NAME
- mv target/release/$BIN_NAME app
artifacts:
name: "${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
paths:
- app
expire_in: 1 hour
public: false
when: on_success
##################
# Stage: publish #
##################
.build-image:
stage: publish
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- mkdir -p /kaniko/.docker
- 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/Dockerfile.ci --destination $IMAGE_TAG
build-tagged-image:
extends: .build-image
variables:
IMAGE_TAG: "$CI_REGISTRY_IMAGE:$BIN_NAME-$CI_COMMIT_TAG"
only:
- tags
build-latest-image:
extends: .build-image
variables:
IMAGE_TAG: "$CI_REGISTRY_IMAGE:$BIN_NAME-latest"
only:
- master
build-feature-branch-image:
extends: .build-image
variables:
IMAGE_TAG: "$CI_REGISTRY_IMAGE:$BIN_NAME-$CI_COMMIT_REF_NAME"
except:
- master
- tags
pages:
stage: publish
only:
- master
script:
- cargo doc --no-deps
- mv target/doc public
artifacts:
paths:
- public
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "dummy-app"
version = "0.1.0"
[package]
name = "dummy-app"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
FROM scratch
WORKDIR /app
COPY app app
ENTRYPOINT ["/app/app"]
use std::thread::sleep;
use std::time::{Duration, SystemTime};
fn main() {
let now = SystemTime::now();
loop {
if let Ok(elapsed) = &now.elapsed() {
let hours = elapsed.as_secs() % 3600;
println!(
"App running for {} hour{}",
hours,
if hours != 1 { "s" } else { "" }
);
} else {
println!("App running");
}
sleep(Duration::from_secs(3600));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment