From 45fa0bf36f5816893acd89b82946662006705232 Mon Sep 17 00:00:00 2001 From: Dennis Schwerdel Date: Fri, 17 Apr 2020 22:06:09 +0200 Subject: [PATCH] Github actions --- .github/actions/build-deb/Dockerfile | 20 ++++++++++ .github/actions/build-deb/action.yml | 11 ++++++ .github/actions/build-deb/entrypoint.sh | 33 ++++++++++++++++ .github/actions/build-rpm/Dockerfile | 10 +++++ .github/actions/build-rpm/action.yml | 11 ++++++ .github/actions/build-rpm/entrypoint.sh | 19 ++++++++++ .github/workflows/audit.yml | 12 ++++++ .github/workflows/build.yml | 19 ---------- .github/workflows/check.yml | 50 +++++++++++++++++++++++++ .github/workflows/package.yml | 45 ++++++++++++++++++++++ 10 files changed, 211 insertions(+), 19 deletions(-) create mode 100644 .github/actions/build-deb/Dockerfile create mode 100644 .github/actions/build-deb/action.yml create mode 100755 .github/actions/build-deb/entrypoint.sh create mode 100644 .github/actions/build-rpm/Dockerfile create mode 100644 .github/actions/build-rpm/action.yml create mode 100755 .github/actions/build-rpm/entrypoint.sh create mode 100644 .github/workflows/audit.yml delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/check.yml create mode 100644 .github/workflows/package.yml diff --git a/.github/actions/build-deb/Dockerfile b/.github/actions/build-deb/Dockerfile new file mode 100644 index 0000000..3513cf8 --- /dev/null +++ b/.github/actions/build-deb/Dockerfile @@ -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 diff --git a/.github/actions/build-deb/action.yml b/.github/actions/build-deb/action.yml new file mode 100644 index 0000000..9840a23 --- /dev/null +++ b/.github/actions/build-deb/action.yml @@ -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 }} diff --git a/.github/actions/build-deb/entrypoint.sh b/.github/actions/build-deb/entrypoint.sh new file mode 100755 index 0000000..e739653 --- /dev/null +++ b/.github/actions/build-deb/entrypoint.sh @@ -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 + + diff --git a/.github/actions/build-rpm/Dockerfile b/.github/actions/build-rpm/Dockerfile new file mode 100644 index 0000000..d1a66c7 --- /dev/null +++ b/.github/actions/build-rpm/Dockerfile @@ -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 diff --git a/.github/actions/build-rpm/action.yml b/.github/actions/build-rpm/action.yml new file mode 100644 index 0000000..9840a23 --- /dev/null +++ b/.github/actions/build-rpm/action.yml @@ -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 }} diff --git a/.github/actions/build-rpm/entrypoint.sh b/.github/actions/build-rpm/entrypoint.sh new file mode 100755 index 0000000..c2b34ce --- /dev/null +++ b/.github/actions/build-rpm/entrypoint.sh @@ -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 diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml new file mode 100644 index 0000000..5b62966 --- /dev/null +++ b/.github/workflows/audit.yml @@ -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 }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 6361268..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -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 diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..009c065 --- /dev/null +++ b/.github/workflows/check.yml @@ -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 diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml new file mode 100644 index 0000000..85634ce --- /dev/null +++ b/.github/workflows/package.yml @@ -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'