diff --git a/.github/scripts/build-and-test.sh b/.github/scripts/build-and-test.sh new file mode 100755 index 0000000..781af13 --- /dev/null +++ b/.github/scripts/build-and-test.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# Run the build and tests +set -e + +./autogen.sh +mkdir build +cd build +../configure +make -j V=0 +make -j check V=0 +make -j distcheck diff --git a/.github/scripts/install-dependencies-macos.sh b/.github/scripts/install-dependencies-macos.sh new file mode 100755 index 0000000..3f13107 --- /dev/null +++ b/.github/scripts/install-dependencies-macos.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# Install dependencies to build and test on Ubuntu runners +brew install \ + autoconf \ + automake \ + libtool \ + pkg-config \ + python3 \ + gettext \ + libusb \ + hidapi \ + doxygen \ + rsync \ + cmocka + +exit 0 diff --git a/.github/scripts/install-dependencies-ubuntu.sh b/.github/scripts/install-dependencies-ubuntu.sh new file mode 100755 index 0000000..c0f6c08 --- /dev/null +++ b/.github/scripts/install-dependencies-ubuntu.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# Install dependencies to build and test on Ubuntu runners +sudo apt-get update +sudo apt-get install -y \ + autoconf \ + automake \ + libtool \ + pkg-config \ + python3 \ + gettext \ + autopoint \ + libusb-1.0-0-dev \ + libhidapi-dev \ + libevdev-dev \ + doxygen \ + rsync \ + libcmocka-dev \ + faketime + +exit 0 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..d76cf5f --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,37 @@ +name: Build/Test + +on: + push: + branches: + - '*' + - '!gh-pages' + pull_request: + branches: [ master ] + +jobs: + build: + name: ${{ join(matrix.*, '/') }} + runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.os == 'macos-latest' }} + env: + CC: ${{ matrix.cc }} + + strategy: + matrix: + os: ['ubuntu-16.04', 'ubuntu-18.04', 'ubuntu-20.04', 'macos-latest'] + cc: ['gcc', 'clang'] + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install dependencies (Ubuntu) + run: ./.github/scripts/install-dependencies-ubuntu.sh + if: ${{ matrix.os != 'macos-latest' }} + + - name: Install dependencies (MacOS) + run: ./.github/scripts/install-dependencies-macos.sh + if: ${{ matrix.os == 'macos-latest' }} + + - name: Build and Test + run: ./.github/scripts/build-and-test.sh diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..826d11b --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,57 @@ +name: "CodeQL" + +on: + push: + branches: ['*', '!gh-pages'] + pull_request: + # The branches below must be a subset of the branches above + branches: [master] + schedule: + - cron: '0 7 * * 1' + +jobs: + analyse: + name: Analyse + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + # We must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head. + fetch-depth: 2 + + - name: Install dependencies + run: ./.github/scripts/install-dependencies-ubuntu.sh + + # If this run was triggered by a pull request event, then checkout + # the head of the pull request instead of the merge commit. + - run: git checkout HEAD^2 + if: ${{ github.event_name == 'pull_request' }} + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + # Override language selection by uncommenting this and choosing your languages + # with: + # languages: go, javascript, csharp, python, cpp, java + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # âœī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..701e9d5 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,48 @@ +name: Create Release + +on: + push: + tags: + - 'v*' + +jobs: + build: + name: Upload Release Asset + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install dependencies + run: ./.github/scripts/install-dependencies-ubuntu.sh + + - name: Build project + run: ./.github/scripts/build-and-test.sh + + - name: Find release tarball + id: find_release + run: | + echo "::set-output name=path::$(find $PWD -name 'x52pro-linux*.tar*')" + echo "::set-output name=asset::$(find . -name 'x52pro-linux*.tar*' -exec basename {} \; | sed 's/x52pro-linux-\(.*\)\.tar/x52pro-linux_\1.orig.tar/')" + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + + - name: Upload Release Tarball + id: upload-release-tarball + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ${{ steps.find_release.outputs.path }} + asset_name: ${{ steps.find_release.outputs.asset }} + asset_content_type: application/gzip