From 111eb86d3d473459c86f448ef4895d79ab89f1cc Mon Sep 17 00:00:00 2001 From: Frank Morgner Date: Tue, 18 Jan 2022 17:47:36 +0100 Subject: [PATCH] CI added GitHub actions --- .github/build-ccid.sh | 27 ++++++++++ .github/build-pcsc-relay.sh | 58 ++++++++++++++++++++++ .github/build-virtualsmartcard.sh | 42 ++++++++++++++++ .github/workflows/ci.yml | 82 +++++++++++++++++++++++++++++++ .github/workflows/coverity.yml | 22 +++++++++ 5 files changed, 231 insertions(+) create mode 100755 .github/build-ccid.sh create mode 100755 .github/build-pcsc-relay.sh create mode 100755 .github/build-virtualsmartcard.sh create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/coverity.yml diff --git a/.github/build-ccid.sh b/.github/build-ccid.sh new file mode 100755 index 0000000..d76267d --- /dev/null +++ b/.github/build-ccid.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# CI script to build for "ubuntu", "coverity" + +set -ex -o xtrace + +# todo openpace + +pushd ccid +git submodule update --init . + +sudo apt-get install gengetopt help2man libpcsclite-dev + +autoreconf -vis + +./configure + +case "$1" in + ubuntu) + make distcheck + ;; + coverity) + # exclude opensc from analysis by building it here + make -C src/OpenSC +esac + +popd diff --git a/.github/build-pcsc-relay.sh b/.github/build-pcsc-relay.sh new file mode 100755 index 0000000..ea37d42 --- /dev/null +++ b/.github/build-pcsc-relay.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +# CI script to build for "ubuntu", "coverity", "mingw-32", "mingw-64", "macos" + +set -ex -o xtrace + +pushd pcsc-relay + +DEPS="gengetopt help2man automake" + +case "$1" in + ubuntu|coverity) + DEPS="$DEPS libnfc-dev libpcsclite-dev" + ;; + mingw-32) + DEPS="$DEPS binutils-mingw-w64-i686 gcc-mingw-w64-i686 mingw-w64-i686-dev" + ;; + mingw-64) + DEPS="$DEPS binutils-mingw-w64-x86-64 gcc-mingw-w64-x86-64 mingw-w64-x86-64-dev" + ;; + macos) + DEPS="$DEPS libnfc" + ;; +esac + +case "$1" in + ubuntu|coverity|mingw-32|mingw-64) + sudo apt-get install -y $DEPS + ;; + macos) + brew install $DEPS + ;; +esac + +autoreconf -vis + +case "$1" in + ubuntu|coverity|macos) + ./configure + ;; + mingw-32) + env ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes ./configure --host=i686-w64-mingw32 --target=i686-w64-mingw32 CFLAGS=-I/usr/i686-w64-mingw32/include LDFLAGS=-L/usr/i686-w64-mingw32/lib PCSC_LIBS=-lwinscard + ;; + mingw-64) + env ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes ./configure --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 CFLAGS=-I/usr/x86_64-w64-mingw32/include LDFLAGS=-L/usr/x86_64-w64-mingw32/lib PCSC_LIBS=-lwinscard + ;; +esac + +case "$1" in + ubuntu|macos) + make distcheck + ;; + mingw-32|mingw-64) + make + ;; +esac + +popd diff --git a/.github/build-virtualsmartcard.sh b/.github/build-virtualsmartcard.sh new file mode 100755 index 0000000..35a9be9 --- /dev/null +++ b/.github/build-virtualsmartcard.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# CI script to build for "ubuntu", "coverity", "macos" + +set -ex -o xtrace + +pushd virtualsmartcard + +DEPS="help2man automake libtool" + +case "$1" in + ubuntu|coverity) + DEPS="$DEPS libpcsclite-dev libqrencode-dev" + ;; + macos) + DEPS="$DEPS gengetopt" + ;; +esac + +case "$1" in + ubuntu|coverity) + sudo apt-get install -y $DEPS + ;; + macos) + brew install $DEPS + ;; +esac + +autoreconf -vis + +./configure + +case "$1" in + ubuntu) + make distcheck + ;; + macos) + make osx + ;; +esac + +popd diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6503d60 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,82 @@ +name: Build + +on: + pull_request: + paths: + - '**.c' + - '**.h' + - '**.in' + - '**.sh' + - '**.py' + - '**.java' + - .github/workflows/ci.yml + push: + + +jobs: + virtualsmartcard-macos: + runs-on: macos-11 + steps: + - uses: actions/checkout@v2 + - run: .github/build-virtualsmartcard.sh macos + - uses: actions/upload-artifact@v2 + with: + name: virtualsmartcard-macos + path: + virtualsmartcard/virtualsmartcard*.dmg + + virtualsmartcard-ubuntu: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - run: .github/build-virtualsmartcard.sh ubuntu + - uses: actions/upload-artifact@v2 + with: + name: virtualsmartcard + path: + virtualsmartcard/virtualsmartcard*.tar.gz + + ccid-ubuntu: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - run: .github/build-ccid.sh ubuntu + - uses: actions/upload-artifact@v2 + with: + name: ccid-emulator + path: + ccid/ccid-emulator*.tar.gz + + pcsc-relay-macos: + runs-on: macos-11 + steps: + - uses: actions/checkout@v2 + - run: .github/build-pcsc-relay.sh macos + + pcsc-relay-ubuntu: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - run: .github/build-pcsc-relay.sh ubuntu + - uses: actions/upload-artifact@v2 + with: + name: pcsc-relay + path: + pcsc-relay/pcsc-relay*.tar.gz + +# pcsc-relay-mingw-32: +# runs-on: ubuntu-20.04 +# steps: +# - uses: actions/checkout@v2 +# - run: .github/build-pcsc-relay.sh mingw-32 + + pcsc-relay-mingw-64: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - run: .github/build-pcsc-relay.sh mingw-64 + - uses: actions/upload-artifact@v2 + with: + name: pcsc-relay-mingw-64 + path: + pcsc-relay/src/pcsc-relay.exe diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml new file mode 100644 index 0000000..0aeaeb1 --- /dev/null +++ b/.github/workflows/coverity.yml @@ -0,0 +1,22 @@ +name: Coverity Scan + +# We only want to test master or explicitly via coverity branch +on: + push: + branches: [master, coverity] + + +jobs: + build: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - run: .github/build-virtualsmartcard.sh coverity + - run: .github/build-ccid.sh coverity + - run: .github/build-pcsc-relay.sh coverity + - uses: vapier/coverity-scan-action@v0 + with: + project: frankmorgner%2Fvsmartcard + token: ${{ secrets.COVERITY_SCAN_TOKEN }} + email: 'frankmorgner@gmail.com' + command: 'make -C $GITHUB_WORKSPACE/virtualsmartcard; make -C $GITHUB_WORKSPACE/ccid; make -C $GITHUB_WORKSPACE/pcsc-relay'