From ab06ba419e3596ecd861d5ad1f411d01f3a972ff Mon Sep 17 00:00:00 2001 From: Stephan Lachnit Date: Tue, 25 May 2021 00:14:58 +0200 Subject: [PATCH] Switch to GitHub Actions Signed-off-by: Stephan Lachnit --- .github/workflows/build-and-test.yml | 38 ++++++++++++++++++++++++++++ .travis.yml | 25 ------------------ README.md | 2 +- bootstrap.sh | 20 ++++++++------- scripts/format-check.sh | 16 ++++++++++++ scripts/static-analyser-check.sh | 9 +++---- 6 files changed, 70 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/build-and-test.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..81e0f55 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,38 @@ +name: Build and test +on: [push, pull_request] + +jobs: + build-and-test: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install dependencies + run: | + sudo apt install build-essential meson appstream clang clang-format clang-tools libdbus-1-dev libinih-dev libsystemd-dev + - name: Check format + env: + CI: "true" + run: | + ./scripts/format-check.sh + - name: Build and install + env: + CI: "true" + run: | + ./bootstrap.sh -Dwith-examples=true + - name: Tests + run: | + meson test -C builddir + - name: Simulate game + run: | + dbus-run-session -- gamemode-simulate-game + - name: Static analyser check + run: | + ./scripts/static-analyser-check.sh + - name: Upload logs + if: ${{ always() }} + uses: actions/upload-artifact@v2 + with: + name: logs + path: | + builddir/meson-logs/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0f1fb90..0000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -os: linux -dist: focal -language: c -compiler: gcc - -addons: - apt: - packages: - - appstream - - clang - - clang-format - - libinih-dev - - libdbus-1-dev - - libsystemd-dev - - meson - artifacts: - paths: - - $(git ls-files -o | tr "\n" ":") - -script: - - ./scripts/format-check.sh - - ./bootstrap.sh -Dwith-examples=true - - meson test -C builddir - - dbus-run-session -- gamemode-simulate-game - - ./scripts/static-analyser-check.sh diff --git a/README.md b/README.md index 9b0d3ba..c63fcae 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ Other apps which can integrate with GameMode include: * Lutris - Enables GameMode for all games by default if available (must have both 32- and 64-bit GameMode libraries installed), configurable in preferences. --- -## Development [![Build Status](https://travis-ci.org/FeralInteractive/gamemode.svg?branch=master)](https://travis-ci.org/FeralInteractive/gamemode) +## Development [![Build and test](https://github.com/FeralInteractive/gamemode/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/FeralInteractive/gamemode/actions/workflows/build-and-test.yml) The design of GameMode has a clear-cut abstraction between the host daemon and library (`gamemoded` and `libgamemode`), and the client loaders (`libgamemodeauto` and `gamemode_client.h`) that allows for safe use without worrying about whether the daemon is installed or running. This design also means that while the host library currently relies on `systemd` for exchanging messages with the daemon, it's entirely possible to implement other internals that still work with the same clients. diff --git a/bootstrap.sh b/bootstrap.sh index 22ac240..b89d1fb 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -14,9 +14,9 @@ if [ ! -f "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" ]; then echo "This probably means that you have disabled processor scheduling features in your BIOS. See README.md (or GitHub issue #44) for more information." echo "This means GameMode's CPU governor control feature will not work (other features will still work)." - if [ "$TRAVIS" != "true" ]; then + if [ "$CI" != "true" ]; then # Allow to continue the install, as gamemode has other useful features - read -p "Would you like to continue anyway [Y/N]? " -r + read -p "Would you like to continue anyway [y/N]? " -r [[ $REPLY =~ ^[Yy]$ ]] fi fi @@ -31,7 +31,7 @@ ninja -C builddir # Verify user wants to install set +x -if [ "$TRAVIS" != "true" ]; then +if [ "$CI" != "true" ]; then read -p "Install to $prefix? [y/N] " -r [[ $REPLY =~ ^[Yy]$ ]] fi @@ -39,10 +39,12 @@ set -x sudo ninja install -C builddir -# Restart polkit so we don't get pop-ups whenever we pkexec -if systemctl list-unit-files |grep -q polkit.service; then - sudo systemctl try-restart polkit -fi +if [ "$CI" != "true" ]; then + # Restart polkit so we don't get pop-ups whenever we pkexec + if systemctl list-unit-files | grep -q polkit.service; then + sudo systemctl try-restart polkit + fi -# Reload systemd configuration so that it picks up the new service. -systemctl --user daemon-reload + # Reload systemd configuration so that it picks up the new service. + systemctl --user daemon-reload +fi diff --git a/scripts/format-check.sh b/scripts/format-check.sh index 99f54fa..d0dcca2 100755 --- a/scripts/format-check.sh +++ b/scripts/format-check.sh @@ -10,6 +10,21 @@ if [[ "$1" == "--pre-commit" ]]; then git-clang-format exit fi + +if [[ "$CI" == "true" ]]; then + # used in ci, assumes clean repo + clang-format -i $(find . -name '*.[ch]' -not -path "*subprojects/*") + GIT_DIFF_OUTPUT=$(git diff) + if [[ ! -z ${GIT_DIFF_OUTPUT} ]]; then + echo "Failed clang format check:" + echo "${GIT_DIFF_OUTPUT}" + exit 1 + else + echo "Passed clang format check" + exit 0 + fi +fi + CLANG_FORMAT_OUTPUT=$(git-clang-format HEAD^ HEAD --diff) if [[ ! ${CLANG_FORMAT_OUTPUT} == "no modified files to format" ]] && [[ ! -z ${CLANG_FORMAT_OUTPUT} ]]; then echo "Failed clang format check:" @@ -17,4 +32,5 @@ if [[ ! ${CLANG_FORMAT_OUTPUT} == "no modified files to format" ]] && [[ ! -z ${ exit 1 else echo "Passed clang format check" + exit 0 fi diff --git a/scripts/static-analyser-check.sh b/scripts/static-analyser-check.sh index 50c3510..bc7e388 100755 --- a/scripts/static-analyser-check.sh +++ b/scripts/static-analyser-check.sh @@ -1,11 +1,10 @@ #!/bin/bash -# Exit on failure -set -e +# Ensure we are at the project root +cd "$(dirname $0)"/.. # Collect scan-build output -ninja scan-build -C builddir | tee /tmp/scan-build-results.txt +ninja scan-build -C builddir | tee builddir/meson-logs/scan-build.txt # Invert the output - if this string exists it's a fail -! grep -E '[0-9]+ bugs? found.' /tmp/scan-build-results.txt - \ No newline at end of file +exit ! grep -E '[0-9]+ bugs? found.' builddir/meson-logs/scan-build.txt