merge ci steps

This commit is contained in:
Aleksandr Trushkin
2021-01-10 15:52:45 +03:00
parent e120989e5c
commit dd53a86c2d
5 changed files with 257 additions and 29 deletions

View File

@ -1,42 +1,96 @@
---
kind: pipeline
type: docker
name: build-check-deploy
name: default
platform:
os: "linux"
arch: "arm"
os: linux
arch: arm
steps:
# Fetch deps and check the code
- name: "validate"
image: "rust:1.49"
volumes:
- name: "cache"
path: "./target"
- name: validate
image: rust:1.49
commands:
- "apt-get update && apt-get install -yqq musl-tools"
- "rustup target add armv7-unknown-linux-musleabihf"
- "CC=musl-gcc cargo check --release --target=armv7-unknown-linux-musleabihf"
- "CC=musl-gcc cargo test --release --target=armv7-unknown-linux-musleabihf"
- "CC=musl-gcc cargo build --release --target=armv7-unknown-linux-musleabihf"
# Deploy it somewhere.
- name: "deploy"
image: "rust:1.49"
depends_on:
- "validate"
- cargo test --release --target=armv7-unknown-linux-gnueabihf
environment:
SSH_PRIVATE_KEY:
from_secret: SSH_PRIVATE_KEY
SSH_PARAMS: '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/tmp/known_hosts'
TARGET_DIR: "./.target/armv7-unknown-linux-musleabihf/release"
APP_NAME: deploytest
CARGO_TARGET_DIR: /cache/target
volumes:
- name: cargo
path: /usr/local/cargo
- name: target
path: /cache/target
- name: rustup
path: /usr/local/rustup
- name: test
image: rust:1.49
commands:
# Start the SSH Agent and insert ssh private key.
- "eval $(ssh-agent -s)"
- "echo '${SSH_PRIVATE_KEY}' | tr -d '\r' | ssh-add -"
# Copy the binary file to it.
- "scp ${SSH_PARAMS} ${TARGET_DIR}/alterego ${SSH_USER}@${SSH_HOST}:/home/pi/alterego"
- cargo test --release --target=armv7-unknown-linux-gnueabihf
environment:
APP_NAME: deploytest
CARGO_TARGET_DIR: /cache/target
volumes:
- name: cargo
path: /usr/local/cargo
- name: target
path: /cache/target
- name: rustup
path: /usr/local/rustup
depends_on:
- validate
- name: build
image: rust:1.49
commands:
- cargo build --release --target=armv7-unknown-linux-gnueabihf
environment:
APP_NAME: deploytest
CARGO_TARGET_DIR: /cache/target
volumes:
- name: cargo
path: /usr/local/cargo
- name: target
path: /cache/target
- name: rustup
path: /usr/local/rustup
depends_on:
- test
- name: deploy
image: rust:1.49
commands:
- sh scripts/deploy.sh
environment:
APP_NAME: deploytest
CARGO_TARGET_DIR: /cache/target
SSH_PRIVATE_KEY:
from_secret: ssh_pk_base64
SSH_USER:
from_secret: SSH_USER
TARGET_DIR: /cache/target/armv7-unknown-linux-gnueabihf/release
volumes:
- name: cargo
path: /usr/local/cargo
- name: target
path: /cache/target
- name: rustup
path: /usr/local/rustup
depends_on:
- build
volumes:
- name: "cache"
- name: target
temp: {}
- name: cargo
host:
path: /home/pi/.cargo
- name: rustup
host:
path: /home/pi/.rustup
---
kind: signature
hmac: 5d42ee9863b09aa2c5b1140903b659ec25660acdab89f20a6d070c30d46898b0
...