From 537e756a7bb39551ea8bbae8487e359a32cd4c1e Mon Sep 17 00:00:00 2001 From: Dmitry Pankratov Date: Sun, 15 Dec 2024 22:41:24 +0100 Subject: [PATCH] Added CI --- .github/workflows/rust.yml | 21 +++++++++++++++++++++ README.md | 3 +++ ci/build.bash | 22 ++++++++++++++++++++++ ci/clippy.bash | 15 +++++++++++++++ ci/common.bash | 6 ++++++ ci/set_rust_version.bash | 5 +++++ ci/test.bash | 16 ++++++++++++++++ 7 files changed, 88 insertions(+) create mode 100644 .github/workflows/rust.yml create mode 100755 ci/build.bash create mode 100755 ci/clippy.bash create mode 100644 ci/common.bash create mode 100755 ci/set_rust_version.bash create mode 100755 ci/test.bash diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..cceba5a --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,21 @@ +name: CI + +on: [push, pull_request] + +jobs: + linux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: git submodule update --init + - run: sudo apt-get update && sudo apt-get install -yqq build-essential pkg-config libssl-dev libgtk-3-dev + - run: ci/set_rust_version.bash ${{ matrix.channel }} ${{ matrix.target }} + - run: ci/clippy.bash cargo ${{ matrix.target }} + - run: ci/test.bash cargo ${{ matrix.target }} + + strategy: + fail-fast: false + matrix: + channel: [stable] + target: + - x86_64-unknown-linux-gnu diff --git a/README.md b/README.md index 0682e31..69df3cc 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Open Source Linux Client for Check Point VPN Tunnels +[![github actions](https://github.com/ancwrd1/snx-rs/workflows/CI/badge.svg)](https://github.com/ancwrd1/snx-rs/actions) +[![license](https://img.shields.io/badge/License-AGPL-v3.svg)](https://opensource.org/license/agpl-v3) + This project contains the source code for an unofficial Linux client for Check Point VPN, written in Rust. ## Advantages Over the Official SNX Client for Linux diff --git a/ci/build.bash b/ci/build.bash new file mode 100755 index 0000000..6684a48 --- /dev/null +++ b/ci/build.bash @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# Script for building your rust projects. +set -e + +source ci/common.bash + +# $1 {path} = Path to cross/cargo executable +CROSS=$1 +# $2 {string} = +TARGET_TRIPLE=$2 +# $3 {boolean} = Whether or not building for release or not. +RELEASE_BUILD=$3 + +required_arg "$CROSS" 'CROSS' +required_arg "$TARGET_TRIPLE" '' + +if [ -z "$RELEASE_BUILD" ]; then + $CROSS build --target "$TARGET_TRIPLE" --workspace + $CROSS build --target "$TARGET_TRIPLE" --all-features --workspace +else + $CROSS build --target $TARGET_TRIPLE --all-features --release --workspace +fi diff --git a/ci/clippy.bash b/ci/clippy.bash new file mode 100755 index 0000000..5f3627c --- /dev/null +++ b/ci/clippy.bash @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# Script for building your rust projects. +set -e + +source ci/common.bash + +# $1 {path} = Path to cross/cargo executable +CROSS=$1 +# $2 {string} = +TARGET_TRIPLE=$2 + +required_arg "$CROSS" 'CROSS' +required_arg "$TARGET_TRIPLE" '' + +$CROSS clippy --target "$TARGET_TRIPLE" --all-features --workspace diff --git a/ci/common.bash b/ci/common.bash new file mode 100644 index 0000000..6b0a21a --- /dev/null +++ b/ci/common.bash @@ -0,0 +1,6 @@ +required_arg() { + if [ -z "$1" ]; then + echo "Required argument $2 missing" + exit 1 + fi +} diff --git a/ci/set_rust_version.bash b/ci/set_rust_version.bash new file mode 100755 index 0000000..da2ba4f --- /dev/null +++ b/ci/set_rust_version.bash @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -e +rustup update +rustup default "$1" +rustup target add "$2" diff --git a/ci/test.bash b/ci/test.bash new file mode 100755 index 0000000..4150150 --- /dev/null +++ b/ci/test.bash @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Script for building your rust projects. +set -e + +source ci/common.bash + +# $1 {path} = Path to cross/cargo executable +CROSS=$1 +# $2 {string} = +TARGET_TRIPLE=$2 + +required_arg "$CROSS" 'CROSS' +required_arg "$TARGET_TRIPLE" '' + +$CROSS test --target "$TARGET_TRIPLE" --workspace +$CROSS build --target "$TARGET_TRIPLE" --all-features --workspace