Github actions

This commit is contained in:
Dennis Schwerdel 2020-04-17 22:06:09 +02:00
parent fd45da489a
commit 45fa0bf36f
10 changed files with 211 additions and 19 deletions

20
.github/actions/build-deb/Dockerfile vendored Normal file
View File

@ -0,0 +1,20 @@
FROM ubuntu:16.04
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
curl \
gcc-aarch64-linux-gnu \
gcc-arm-linux-gnueabihf \
libc6-dev-arm64-cross \
libc6-dev-armhf-cross \
libc6-dev-i386 \
gcc-5-multilib \
ruby-ronn \
&& rm -rf /var/cache/dpkg
RUN ln -s asm-generic/ /usr/include/asm
ADD entrypoint.sh /entrypoint.sh
ENTRYPOINT /entrypoint.sh

11
.github/actions/build-deb/action.yml vendored Normal file
View File

@ -0,0 +1,11 @@
name: 'build-deb'
description: 'Create deb packages'
inputs:
rust:
description: Rust version
default: 'stable'
runs:
using: 'docker'
image: 'Dockerfile'
env:
RUST: ${{ inputs.rust }}

33
.github/actions/build-deb/entrypoint.sh vendored Executable file
View File

@ -0,0 +1,33 @@
#!/bin/bash
set -e
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain ${RUST}
source $HOME/.cargo/env
rustup target add i686-unknown-linux-gnu
rustup target add armv7-unknown-linux-gnueabihf
rustup target add aarch64-unknown-linux-gnu
cargo install cargo-deb
VERSION=$(grep -e '^version =' Cargo.toml | sed -e 's/version = "\(.*\)"/\1/')
mkdir dist
cargo deb
cp target/debian/vpncloud_${VERSION}_amd64.deb dist/vpncloud_${VERSION}_amd64.deb
# i386 deb
cargo deb --target i686-unknown-linux-gnu
cp target/i686-unknown-linux-gnu/debian/vpncloud_${VERSION}_i386.deb dist/vpncloud_${VERSION}_i386.deb
# arm7hf deb
cargo deb --target armv7-unknown-linux-gnueabihf
cp target/armv7-unknown-linux-gnueabihf/debian/vpncloud_${VERSION}_armhf.deb dist/vpncloud_${VERSION}_armhf.deb
# aarch64 deb
cargo deb --target aarch64-unknown-linux-gnu
cp target/aarch64-unknown-linux-gnu/debian/vpncloud_${VERSION}_arm64.deb dist/vpncloud_${VERSION}_arm64.deb

10
.github/actions/build-rpm/Dockerfile vendored Normal file
View File

@ -0,0 +1,10 @@
FROM centos:7
RUN yum groupinstall -y 'Development Tools'
RUN yum-config-manager --add-repo http://springdale.math.ias.edu/data/puias/computational/7/x86_64 \
&& yum install --nogpgcheck -y rubygem-ronn
ADD entrypoint.sh /entrypoint.sh
ENTRYPOINT /entrypoint.sh

11
.github/actions/build-rpm/action.yml vendored Normal file
View File

@ -0,0 +1,11 @@
name: 'build-deb'
description: 'Create deb packages'
inputs:
rust:
description: Rust version
default: 'stable'
runs:
using: 'docker'
image: 'Dockerfile'
env:
RUST: ${{ inputs.rust }}

19
.github/actions/build-rpm/entrypoint.sh vendored Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
set -e
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain ${RUST}
source $HOME/.cargo/env
rustup target add i686-unknown-linux-gnu
rustup target add armv7-unknown-linux-gnueabihf
cargo install cargo-rpm
VERSION=$(grep -e '^version =' Cargo.toml | sed -e 's/version = "\(.*\)"/\1/')
mkdir dist
cargo build --release
cargo rpm build
cp target/release/rpmbuild/RPMS/x86_64/vpncloud-${VERSION}-1.x86_64.rpm dist/vpncloud_${VERSION}.x86_64.rpm

12
.github/workflows/audit.yml vendored Normal file
View File

@ -0,0 +1,12 @@
name: Security audit
on:
schedule:
- cron: '0 0 * * *'
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,19 +0,0 @@
name: Build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install latest nightly
run: rustup toolchain install 1.40.0
- name: Set default toolchain
run: rustup default 1.40.0
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose

50
.github/workflows/check.yml vendored Normal file
View File

@ -0,0 +1,50 @@
name: Checks
on: [push]
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: check
test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test
coverage:
name: Coverage
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Run cargo-tarpaulin
uses: actions-rs/tarpaulin@v0.1
with:
version: '0.9.0'
args: '-o Html -- --test-threads=1'
- name: Archive code coverage results
uses: actions/upload-artifact@v1
with:
name: code-coverage-report
path: tarpaulin-report.html

45
.github/workflows/package.yml vendored Normal file
View File

@ -0,0 +1,45 @@
on:
release:
types: [created]
name: Build packages
jobs:
deb:
name: "Build deb packages"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run builder
uses: ./.github/actions/build-deb
with:
rust: '1.40.0'
- name: Archive artifacts
uses: actions/upload-artifact@v1
with:
name: packages
path: dist
- name: Upload artifacts
uses: skx/github-action-publish-binaries@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: 'dist/*.deb'
rpm:
name: "Build rpm packages"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run builder
uses: ./.github/actions/build-rpm
with:
rust: '1.40.0'
- name: Archive artifacts
uses: actions/upload-artifact@v1
with:
name: packages
path: dist
- name: Upload artifacts
uses: skx/github-action-publish-binaries@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: 'dist/*.rpm'