Add github actions workflows (#267)
* Run linters and unit tests with github actions * Reformat with black, 22.1.0 (compiled: yes) * Remove native deps as should no longer be needed * Remove pylint from workflows * Remove unused Gtk dependency in test_daemon.py * Install subset of python deps with apt-get for cipull/298/head
parent
162e7fcbf7
commit
ee6b48ac32
@ -0,0 +1,25 @@
|
|||||||
|
name: Lint
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
black:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: ["3.10"]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
scripts/ci-install-deps.sh
|
||||||
|
pip install black
|
||||||
|
- name: Analysing the code with black --check --diff
|
||||||
|
run: |
|
||||||
|
black --check --diff ./inputremapper ./tests
|
||||||
|
|
@ -0,0 +1,46 @@
|
|||||||
|
---
|
||||||
|
name: reviewdog
|
||||||
|
# run reviewdog for PR only because "github-check" option is failing :(
|
||||||
|
# https://github.com/reviewdog/reviewdog/issues/924
|
||||||
|
on: [pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
reviewdog_python:
|
||||||
|
name: reviewdog - Python lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: ["3.10"]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- uses: reviewdog/action-setup@master
|
||||||
|
with:
|
||||||
|
reviewdog_version: latest
|
||||||
|
- name: Install dependencies
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
scripts/ci-install-deps.sh
|
||||||
|
pip install flake8 pylint mypy black
|
||||||
|
- name: Set env for PR
|
||||||
|
if: github.event_name == 'pull_request'
|
||||||
|
shell: bash
|
||||||
|
run: echo "REWIEVDOG_REPORTER=github-pr-review" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Set env for push
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
shell: bash
|
||||||
|
run: echo "REWIEVDOG_REPORTER=github-check" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Run reviewdog
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
reviewdog -list
|
||||||
|
reviewdog -tee -runners=mypy,black -reporter=${{ env.REWIEVDOG_REPORTER }} -fail-on-error=false
|
@ -0,0 +1,28 @@
|
|||||||
|
name: Test
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
continue-on-error: true
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: ["3.7", "3.10"] # min and max supported versions?
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
# Install deps as root since we will run tests as root
|
||||||
|
sudo scripts/ci-install-deps.sh
|
||||||
|
sudo pip install .
|
||||||
|
- name: Run tests
|
||||||
|
run: |
|
||||||
|
# FIXME: Had some permissions issues, currently worked around by running tests as root
|
||||||
|
mkdir test_tmp
|
||||||
|
TMPDIR="$(realpath test_tmp)" sudo python tests/test.py --start-dir unit
|
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
runner:
|
||||||
|
mypy:
|
||||||
|
name: mypy
|
||||||
|
cmd: mypy --show-column-numbers inputremapper tests --ignore-missing-imports
|
||||||
|
errorformat:
|
||||||
|
- "%f:%l:%c: %m"
|
||||||
|
|
||||||
|
pylint:
|
||||||
|
name: pylint
|
||||||
|
cmd: pylint inputremapper tests --extension-pkg-whitelist=evdev
|
||||||
|
errorformat:
|
||||||
|
- "%f:%l:%c: %t%n: %m"
|
||||||
|
|
||||||
|
flake8:
|
||||||
|
cmd: flake8 inputremapper tests
|
||||||
|
format: flake8
|
||||||
|
|
||||||
|
black:
|
||||||
|
cmd: black --diff --quiet --check ./inputremapper ./tests
|
||||||
|
format: black
|
@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Called from multiple CI pipelines in .github/workflows
|
||||||
|
set -xeuo pipefail
|
||||||
|
|
||||||
|
# native deps
|
||||||
|
# gettext required to generate translations, others are python deps
|
||||||
|
sudo apt-get install -y gettext python3-evdev python3-pydbus python3-pydantic
|
||||||
|
|
||||||
|
# ensure pip and setuptools/wheel up to date so can install all pip modules
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install wheel setuptools
|
||||||
|
|
||||||
|
# install test deps which aren't in setup.py
|
||||||
|
pip install psutil
|
@ -0,0 +1,48 @@
|
|||||||
|
# shell.nix - used with nix-shell to get a development environment with necessary dependencies
|
||||||
|
# Should be enough to run unit tests, integration tests and the service won't work
|
||||||
|
# If you don't use nix, don't worry about/use this file
|
||||||
|
let
|
||||||
|
pkgs = import <nixpkgs> { };
|
||||||
|
python = pkgs.python310;
|
||||||
|
in
|
||||||
|
pkgs.mkShell {
|
||||||
|
nativeBuildInputs = [
|
||||||
|
pkgs.pkg-config
|
||||||
|
pkgs.wrapGAppsHook
|
||||||
|
];
|
||||||
|
buildInputs = [
|
||||||
|
pkgs.gobject-introspection
|
||||||
|
pkgs.gtk3
|
||||||
|
pkgs.bashInteractive
|
||||||
|
pkgs.gobject-introspection
|
||||||
|
pkgs.xlibs.xmodmap
|
||||||
|
pkgs.gtksourceview4
|
||||||
|
(python.withPackages (
|
||||||
|
python-packages: with python-packages; [
|
||||||
|
pip
|
||||||
|
wheel
|
||||||
|
setuptools # for pkg_resources
|
||||||
|
types-setuptools
|
||||||
|
|
||||||
|
evdev
|
||||||
|
pydbus
|
||||||
|
pygobject3
|
||||||
|
pydantic
|
||||||
|
|
||||||
|
psutil # only used in tests
|
||||||
|
]
|
||||||
|
))
|
||||||
|
];
|
||||||
|
# https://nixos.wiki/wiki/Python#Emulating_virtualenv_with_nix-shell
|
||||||
|
shellHook = ''
|
||||||
|
# Tells pip to put packages into $PIP_PREFIX instead of the usual locations.
|
||||||
|
# See https://pip.pypa.io/en/stable/user_guide/#environment-variables.
|
||||||
|
export PIP_PREFIX=$(pwd)/venv
|
||||||
|
export PYTHONPATH="$PIP_PREFIX/${python.sitePackages}:$PYTHONPATH"
|
||||||
|
export PATH="$PIP_PREFIX/bin:$PATH"
|
||||||
|
unset SOURCE_DATE_EPOCH
|
||||||
|
|
||||||
|
python setup.py egg_info
|
||||||
|
pip install `grep -v '^\[' *.egg-info/requires.txt` || true
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in New Issue