From 2d29b6ff5cc7a6720a17d5b8fddc6fbc725d4d8f Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Thu, 19 Sep 2024 17:09:36 +0100 Subject: [PATCH 01/13] lsusb.py: mention both usb.ids paths Loosely based on patch from Alpine Linux Signed-off-by: Emil Velikov --- lsusb.py.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lsusb.py.in b/lsusb.py.in index f26e8e9..bbc4dbb 100755 --- a/lsusb.py.in +++ b/lsusb.py.in @@ -64,7 +64,7 @@ def myenum(*args): return type('MyEnum', (), enums) def parse_usb_ids(): - "Parse /usr/share/usb.ids and fill usbvendors, usbproducts, usbclasses" + "Parse /usr/share/{hwdata/,}usb.ids and fill usbvendors, usbproducts, usbclasses" vid = 0 did = 0 modes = myenum('Vendor', 'Class', 'Misc') @@ -467,7 +467,7 @@ def usage(): print(" -C, --no-color disable colors") print(" -e, --endpoints display endpoint info") print(" -f FILE, --usbids-path FILE") - print(" override filename for /usr/share/usb.ids") + print(" override filename for /usr/share/{hwdata/,}usb.ids") print(" -w, --wakeup display power wakeup setting") print() print("Use lsusb.py -ciu to get a nice overview of your USB devices.") From 5d193309274b202b388395ea591ecd9579acbb6e Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Thu, 19 Sep 2024 17:45:09 +0100 Subject: [PATCH 02/13] Rename .in files to their final state With the earlier commits we've removed any processing done on these in(put) files. Just rename them to their final form. Signed-off-by: Emil Velikov --- lsusb.8.in => lsusb.8 | 0 lsusb.py.in => lsusb.py | 0 lsusb.py.1.in => lsusb.py.1 | 0 meson.build | 16 +++------------- usb-devices.1.in => usb-devices.1 | 0 usbhid-dump.8.in => usbhid-dump.8 | 0 usbreset.1.in => usbreset.1 | 0 7 files changed, 3 insertions(+), 13 deletions(-) rename lsusb.8.in => lsusb.8 (100%) rename lsusb.py.in => lsusb.py (100%) rename lsusb.py.1.in => lsusb.py.1 (100%) rename usb-devices.1.in => usb-devices.1 (100%) rename usbhid-dump.8.in => usbhid-dump.8 (100%) rename usbreset.1.in => usbreset.1 (100%) diff --git a/lsusb.8.in b/lsusb.8 similarity index 100% rename from lsusb.8.in rename to lsusb.8 diff --git a/lsusb.py.in b/lsusb.py similarity index 100% rename from lsusb.py.in rename to lsusb.py diff --git a/lsusb.py.1.in b/lsusb.py.1 similarity index 100% rename from lsusb.py.1.in rename to lsusb.py.1 diff --git a/meson.build b/meson.build index 01f45ef..1b061ea 100644 --- a/meson.build +++ b/meson.build @@ -77,15 +77,8 @@ mandir = join_paths(get_option('prefix'), get_option('mandir')) man1dir = join_paths(mandir, 'man1') man8dir = join_paths(mandir, 'man8') -# This can probably be cleaned up a lot to work on a list -# instead of doing it by hand. -usb_devices_man = configure_file(input: files('usb-devices.1.in'), output: 'usb-devices.1', configuration: config) -lsusb_py_man = configure_file(input: files('lsusb.py.1.in'), output: 'lsusb.py.1', configuration: config) -install_man([usb_devices_man, lsusb_py_man], install_dir: man1dir) - -lsusb_man = configure_file(input: files('lsusb.8.in'), output: 'lsusb.8', configuration: config) -usbhid_dump_man = configure_file(input: files('usbhid-dump.8.in'), output: 'usbhid-dump.8', configuration: config) -install_man([lsusb_man, usbhid_dump_man], install_dir: man8dir) +install_man(files('usb-devices.1', 'lsusb.py.1'), install_dir: man1dir) +install_man(files('lsusb.8', 'usbhid-dump.8'), install_dir: man8dir) ########################## @@ -122,8 +115,6 @@ usbreset_sources = [ 'usbreset.c' ] -usbreset_man = configure_file(input: files('usbreset.1.in'), output: 'usbreset.1', configuration: config) - # By default, usbreset does not get installed as it could cause problems, it's # in the repo for those that wish to try it out. executable('usbreset', usbreset_sources, install: false) @@ -142,7 +133,6 @@ install_data(usb_devices_sources, install_dir: get_option('bindir'), install_mod ############################# # lsusb.py build instructions ############################# -lsusb_py = configure_file(input: files('lsusb.py.in'), output: 'lsusb.py', configuration: config) # Also a hack, like was done for usb-devices, as this is "just" a script and # doesn't need to be compiled. -install_data(lsusb_py, install_dir: get_option('bindir'), install_mode: 'rwxr-xr-x') +install_data(files('lsusb.py'), install_dir: get_option('bindir'), install_mode: 'rwxr-xr-x') diff --git a/usb-devices.1.in b/usb-devices.1 similarity index 100% rename from usb-devices.1.in rename to usb-devices.1 diff --git a/usbhid-dump.8.in b/usbhid-dump.8 similarity index 100% rename from usbhid-dump.8.in rename to usbhid-dump.8 diff --git a/usbreset.1.in b/usbreset.1 similarity index 100% rename from usbreset.1.in rename to usbreset.1 From 7cbfe23b93e6efe92179a30f88a3f2267d358baa Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Thu, 19 Sep 2024 18:02:08 +0100 Subject: [PATCH 03/13] Update .gitignore files With the switch to meson and removing the .in files, ~90% of the .gitignore can go \o/ The one in usbhid-dump can be removed all together. Signed-off-by: Emil Velikov --- .gitignore | 27 +++------------------------ usbhid-dump/.gitignore | 18 ------------------ 2 files changed, 3 insertions(+), 42 deletions(-) delete mode 100644 usbhid-dump/.gitignore diff --git a/.gitignore b/.gitignore index 440f513..fd0ff97 100644 --- a/.gitignore +++ b/.gitignore @@ -1,28 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only # Copyright (c) 2014-2021 Greg Kroah-Hartman # Copyright (c) 2009 Greg Kroah-Hartman -*.o + +*~ *.swp -.deps/ -Makefile -Makefile.in -config.h -config.h.in -config.log -config.status -configure -stamp-h1 -aclocal.m4 -autom4te.cache/ -depcomp -install-sh -missing -compile -lsusb -lsusb.py -lsusb.8 -usb-devices.1 -usbreset -usbhid-dump.8 -*.gz -*.bz2 +build* diff --git a/usbhid-dump/.gitignore b/usbhid-dump/.gitignore deleted file mode 100644 index 34ab140..0000000 --- a/usbhid-dump/.gitignore +++ /dev/null @@ -1,18 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later -# Copyright (c) 2010 Nikolai Kondrashov -/config.h.in -/autom4te.cache -/aclocal.m4 -/Makefile.in -/configure -/config.h -/config.log -/config.status -/libtool -/Makefile -/stamp-h1 -/auxdir -/ChangeLog -*.o -*.lo -*.la From 3ccc314d731d449b048d9e2fa1774111bc06ea11 Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Thu, 19 Sep 2024 17:17:51 +0100 Subject: [PATCH 04/13] meson: convert Wswitch-enum to Wswitch and enable The latter warns on missing cases in the switch. The former also warns even if there is a default statement. We extensively use defaults so, opt for the saner warning. Signed-off-by: Emil Velikov --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 1b061ea..189c47e 100644 --- a/meson.build +++ b/meson.build @@ -38,7 +38,7 @@ add_project_arguments( '-Wshadow', '-Wsign-compare', '-Wstrict-prototypes', - # '-Wswitch-enum', + '-Wswitch', '-Wtype-limits', '-Wundef', '-Wuninitialized', From 3be17cd1bd0251f65efc177cb653a1616c184a8e Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Thu, 19 Sep 2024 17:20:08 +0100 Subject: [PATCH 05/13] meson: enable commented out warnings The code is warning free, so flip those on. Flip the Wformat=2 and Wformat order, since the latter is =1 and overrides the former. Signed-off-by: Emil Velikov --- meson.build | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index 189c47e..3db73ec 100644 --- a/meson.build +++ b/meson.build @@ -18,14 +18,14 @@ cc = meson.get_compiler('c') add_project_arguments( cc.get_supported_arguments([ '-Wbad-function-cast', - # '-Wcast-align', + '-Wcast-align', '-Wchar-subscripts', - # '-Wempty-body', + '-Wempty-body', + '-Wformat', '-Wformat=2', - # '-Wformat', - # '-Wformat-nonliteral', - # '-Wformat-security', - # '-Wformat-y2k', + '-Wformat-nonliteral', + '-Wformat-security', + '-Wformat-y2k', '-Winit-self', '-Winline', '-Wmissing-declarations', From 8481dc25100af4e418b3b6a6166b146b3735902e Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Thu, 19 Sep 2024 17:32:01 +0100 Subject: [PATCH 06/13] meson: add a bunch more warnings to the mix Random collection of bits from other projects that I hack on. The suggestions are currently disabled until resolved. Signed-off-by: Emil Velikov --- meson.build | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/meson.build b/meson.build index 3db73ec..96a541a 100644 --- a/meson.build +++ b/meson.build @@ -28,15 +28,23 @@ add_project_arguments( '-Wformat-y2k', '-Winit-self', '-Winline', + '-Wint-conversion', '-Wmissing-declarations', + '-Wmissing-format-attribute', '-Wmissing-include-dirs', '-Wmissing-prototypes', + '-Wmissing-noreturn', '-Wnested-externs', '-Wold-style-definition', + '-Wold-style-declaration', '-Wpointer-arith', '-Wredundant-decls', '-Wshadow', '-Wsign-compare', + #'-Wsuggest-attribute=const', + #'-Wsuggest-attribute=noreturn', + #'-Wsuggest-attribute=malloc', + #'-Wsuggest-attribute=returns_nonnull', '-Wstrict-prototypes', '-Wswitch', '-Wtype-limits', @@ -44,6 +52,7 @@ add_project_arguments( '-Wuninitialized', '-Wunused', '-Wunused-variable', + '-Wvla', '-Wwrite-strings', '-fdiagnostics-color=auto', # warnings disabled on purpose From 58ebb31a6984af2f94fceef353042c14375b891d Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Wed, 18 Sep 2024 20:53:38 +0100 Subject: [PATCH 07/13] travis: remove travis-ci files These have been unused for a number of years now, so let's remove them. Signed-off-by: Emil Velikov --- .travis.yml | 29 -------------------------- travis-autogen.sh | 53 ----------------------------------------------- 2 files changed, 82 deletions(-) delete mode 100644 .travis.yml delete mode 100755 travis-autogen.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4fe01e7..0000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -# Copyright 2016 Stephan Linz - -language: c - -matrix: - include: - - os: linux - dist: trusty - sudo: required - compiler: gcc - - os: linux - dist: trusty - sudo: required - compiler: clang - -addons: - apt: - packages: - - meson - - libudev-dev - - libusb-dev - - libusb-1.0-0-dev - sources: - - ubuntu-toolchain-r-test - -script: - - ./autogen.sh - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./travis-autogen.sh && make -j4; fi diff --git a/travis-autogen.sh b/travis-autogen.sh deleted file mode 100755 index 9101995..0000000 --- a/travis-autogen.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# SPDX-License-Identifier: GPL-2.0-only -# Copyright 2016 Stephan Linz - -# -Wsign-compare -Wtype-limits -# Warnings enabled -CFLAGS="-Wall -Wextra" - -CFLAGS+=" -Wbad-function-cast" -#CFLAGS+=" -Wcast-align" -CFLAGS+=" -Wchar-subscripts" -CFLAGS+=" -Wempty-body" -CFLAGS+=" -Wformat=2" -#CFLAGS+=" -Wformat" -#CFLAGS+=" -Wformat-nonliteral" -#CFLAGS+=" -Wformat-security" -#CFLAGS+=" -Wformat-y2k" -CFLAGS+=" -Winit-self" -CFLAGS+=" -Winline" -CFLAGS+=" -Wmissing-declarations" -CFLAGS+=" -Wmissing-include-dirs" -CFLAGS+=" -Wmissing-prototypes" -CFLAGS+=" -Wnested-externs" -CFLAGS+=" -Wold-style-definition" -CFLAGS+=" -Wpointer-arith" -CFLAGS+=" -Wredundant-decls" -CFLAGS+=" -Wshadow" -CFLAGS+=" -Wstrict-prototypes" -CFLAGS+=" -Wswitch-enum" -CFLAGS+=" -Wundef" -CFLAGS+=" -Wuninitialized" -CFLAGS+=" -Wunused" -CFLAGS+=" -Wunused-variable" -CFLAGS+=" -Wsign-compare" -CFLAGS+=" -Wtype-limits" -CFLAGS+=" -Wwrite-strings" -# clang only: CFLAGS+=" -fdiagnostics-color=auto" - -# warnings disabled on purpose -CFLAGS+=" -Wno-unused-parameter" -CFLAGS+=" -Wno-unused-function" -CFLAGS+=" -Wno-deprecated-declarations" - -# should be removed and the code fixed -CFLAGS+=" -Wno-incompatible-pointer-types-discards-qualifiers" -CFLAGS+=" -Wno-missing-field-initializers" - -# fails on warning -- leave it diesabled; not all flags are -# compatible with both compiler (gcc/clang) -#CFLAGS+=" -Werror" - -export CFLAGS -./autogen.sh "$@" From 4c9d9202292b23679250da8c3cd2ff486b27760b Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Wed, 18 Sep 2024 22:40:26 +0100 Subject: [PATCH 08/13] ci: add build ci (Alpline) based on kmod's Signed-off-by: Emil Velikov --- .github/actions/setup-alpine/action.yml | 16 +++++++ .github/dependabot.yml | 17 ++++++++ .github/workflows/main.yml | 56 +++++++++++++++++++++++++ build-dev.ini | 5 +++ 4 files changed, 94 insertions(+) create mode 100644 .github/actions/setup-alpine/action.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/main.yml create mode 100644 build-dev.ini diff --git a/.github/actions/setup-alpine/action.yml b/.github/actions/setup-alpine/action.yml new file mode 100644 index 0000000..7979c52 --- /dev/null +++ b/.github/actions/setup-alpine/action.yml @@ -0,0 +1,16 @@ +name: 'setup Alpine' +description: 'Setup an Alpine container for running CI' +runs: + using: 'composite' + steps: + - name: Install dependencies + shell: sh + run: | + apk update + apk add \ + build-base \ + eudev-dev \ + git \ + libusb-dev \ + linux-headers \ + meson diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..6f114e9 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,17 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + commit-message: + prefix: "ci" + groups: + all-actions: + patterns: + - "*" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..b33e77f --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,56 @@ +name: Build and Test + +on: + push: + branches: [master, ci-test] + pull_request: + branches: [master] + schedule: + - cron: "30 2 * * 0" + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - container: 'alpine:latest' + + container: + image: ${{ matrix.container }} + + steps: + - name: Sparse checkout the local actions + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + sparse-checkout: .github + + - uses: ./.github/actions/setup-alpine + if: ${{ startsWith(matrix.container, 'alpine') }} + + - name: Checkout the whole project + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Set the environment + run: | + # The second checkout above claims to set safe.directory, yet it + # doesn't quite work. Perhaps our double/sparse checkout is to blame? + git config --global --add safe.directory '*' + + - name: configure + run: | + mkdir build && cd build + meson setup --native-file ../build-dev.ini . .. + + - name: build + run: meson compile -C build + + - name: install + run: meson install -C build --destdir $PWD/inst + + - name: distcheck + run: meson dist -C build diff --git a/build-dev.ini b/build-dev.ini new file mode 100644 index 0000000..0e40c97 --- /dev/null +++ b/build-dev.ini @@ -0,0 +1,5 @@ +[project options] +werror = true + +[built-in options] +buildtype = 'debugoptimized' From 1106ebeb3f2c5e5f0f2b75239d3d4450c7d57ee3 Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Thu, 19 Sep 2024 18:13:07 +0100 Subject: [PATCH 09/13] ci: add Arch permutation Both 64bit and multilib (32bit) one, to catch moar issues :troll: Signed-off-by: Emil Velikov --- .github/actions/setup-archlinux/action.yml | 28 ++++++++++++++++++++++ .github/cross-files/arch-cross.ini | 9 +++++++ .github/workflows/main.yml | 15 ++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 .github/actions/setup-archlinux/action.yml create mode 100644 .github/cross-files/arch-cross.ini diff --git a/.github/actions/setup-archlinux/action.yml b/.github/actions/setup-archlinux/action.yml new file mode 100644 index 0000000..60d12db --- /dev/null +++ b/.github/actions/setup-archlinux/action.yml @@ -0,0 +1,28 @@ +name: 'setup Archlinux' +description: 'Setup an Archlinux container for running CI' +runs: + using: 'composite' + steps: + - name: Install dependencies + shell: bash + run: | + # Enable multilib, for building 32bit binaries + echo -e '[multilib]\nInclude = /etc/pacman.d/mirrorlist' >> /etc/pacman.conf + # Semi-regularly the packager key may have (temporarily) expired. + # Somewhat robust solution is to wipe the local keyring and + # regenerate/reinstall it prior to any other packages on the system. + rm -rf /etc/pacman.d/gnupg + pacman-key --init + pacman-key --populate + pacman --noconfirm -Sy archlinux-keyring + + pacman --noconfirm -Su \ + base-devel \ + git \ + lib32-libusb \ + lib32-systemd \ + libusb \ + linux-headers \ + multilib-devel \ + meson \ + systemd diff --git a/.github/cross-files/arch-cross.ini b/.github/cross-files/arch-cross.ini new file mode 100644 index 0000000..719c1df --- /dev/null +++ b/.github/cross-files/arch-cross.ini @@ -0,0 +1,9 @@ +[binaries] +c = ['gcc', '-m32'] +pkgconfig = 'i686-pc-linux-gnu-pkg-config' + +[host_machine] +system = 'linux' +cpu_family = 'x86' +cpu = 'i686' +endian = 'little' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b33e77f..45d38fc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,6 +19,8 @@ jobs: matrix: include: - container: 'alpine:latest' + - container: 'archlinux:base-devel' + crossfile: 'arch-cross.ini' container: image: ${{ matrix.container }} @@ -31,6 +33,8 @@ jobs: - uses: ./.github/actions/setup-alpine if: ${{ startsWith(matrix.container, 'alpine') }} + - uses: ./.github/actions/setup-archlinux + if: ${{ startsWith(matrix.container, 'archlinux') }} - name: Checkout the whole project uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 @@ -54,3 +58,14 @@ jobs: - name: distcheck run: meson dist -C build + + - name: configure (32bit) + if: ${{ matrix.crossfile != '' }} + run: | + cp .github/cross-files/${{ matrix.crossfile }} cross.ini + mkdir build32 && cd build32 + meson setup --native-file ../build-dev.ini --cross-file ../cross.ini . .. + + - name: build (32bit) + if: ${{ matrix.crossfile != '' }} + run: meson compile -C build32 From c2fdd3cf31b82bf10a43581218ecd37d079b4f48 Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Thu, 19 Sep 2024 18:14:49 +0100 Subject: [PATCH 10/13] ci: add Debian permutation Signed-off-by: Emil Velikov --- .github/actions/setup-debian/action.yml | 23 +++++++++++++++++++++++ .github/cross-files/debian-cross.ini | 9 +++++++++ .github/workflows/main.yml | 4 ++++ 3 files changed, 36 insertions(+) create mode 100644 .github/actions/setup-debian/action.yml create mode 100644 .github/cross-files/debian-cross.ini diff --git a/.github/actions/setup-debian/action.yml b/.github/actions/setup-debian/action.yml new file mode 100644 index 0000000..263e425 --- /dev/null +++ b/.github/actions/setup-debian/action.yml @@ -0,0 +1,23 @@ +name: 'setup Debian' +description: 'Setup a Debian container for running CI' +runs: + using: 'composite' + steps: + - name: Install dependencies + shell: bash + run: | + dpkg --add-architecture i386 + apt-get update + apt-get install --yes \ + build-essential \ + crossbuild-essential-i386 \ + gcc \ + git \ + libudev-dev \ + libudev-dev:i386 \ + libusb-1.0-0-dev \ + libusb-1.0-0-dev:i386 \ + linux-libc-dev \ + meson \ + pkgconf \ + pkgconf:i386 diff --git a/.github/cross-files/debian-cross.ini b/.github/cross-files/debian-cross.ini new file mode 100644 index 0000000..d2a8398 --- /dev/null +++ b/.github/cross-files/debian-cross.ini @@ -0,0 +1,9 @@ +[binaries] +c = 'i686-linux-gnu-gcc' +pkgconfig = 'i686-linux-gnu-pkg-config' + +[host_machine] +system = 'linux' +cpu_family = 'x86' +cpu = 'i686' +endian = 'little' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 45d38fc..afbdf03 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,6 +21,8 @@ jobs: - container: 'alpine:latest' - container: 'archlinux:base-devel' crossfile: 'arch-cross.ini' + - container: 'debian:unstable' + crossfile: 'debian-cross.ini' container: image: ${{ matrix.container }} @@ -35,6 +37,8 @@ jobs: if: ${{ startsWith(matrix.container, 'alpine') }} - uses: ./.github/actions/setup-archlinux if: ${{ startsWith(matrix.container, 'archlinux') }} + - uses: ./.github/actions/setup-debian + if: ${{ startsWith(matrix.container, 'debian') }} - name: Checkout the whole project uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 From 1e507bb1a187cf5a8592cd3dee2f0cfbd4738980 Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Thu, 19 Sep 2024 18:15:42 +0100 Subject: [PATCH 11/13] ci: add Fedora permutation Signed-off-by: Emil Velikov --- .github/actions/setup-fedora/action.yml | 16 ++++++++++++++++ .github/workflows/main.yml | 3 +++ 2 files changed, 19 insertions(+) create mode 100644 .github/actions/setup-fedora/action.yml diff --git a/.github/actions/setup-fedora/action.yml b/.github/actions/setup-fedora/action.yml new file mode 100644 index 0000000..b94768c --- /dev/null +++ b/.github/actions/setup-fedora/action.yml @@ -0,0 +1,16 @@ +name: 'setup Fedora' +description: 'Setup a Fedora container for running CI' +runs: + using: 'composite' + steps: + - name: Install dependencies + shell: bash + run: | + dnf update -y + dnf install -y \ + gcc \ + git \ + kernel-devel \ + libudev-devel \ + libusb1-devel \ + meson diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index afbdf03..de6af5f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,6 +23,7 @@ jobs: crossfile: 'arch-cross.ini' - container: 'debian:unstable' crossfile: 'debian-cross.ini' + - container: 'fedora:latest' container: image: ${{ matrix.container }} @@ -39,6 +40,8 @@ jobs: if: ${{ startsWith(matrix.container, 'archlinux') }} - uses: ./.github/actions/setup-debian if: ${{ startsWith(matrix.container, 'debian') }} + - uses: ./.github/actions/setup-fedora + if: ${{ startsWith(matrix.container, 'fedora') }} - name: Checkout the whole project uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 From fe64d6a9aa943ec9e40a4360c1f2de0cc98a9696 Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Thu, 19 Sep 2024 18:16:06 +0100 Subject: [PATCH 12/13] ci: add Ubuntu permutation Signed-off-by: Emil Velikov --- .github/actions/setup-ubuntu/action.yml | 23 +++++++++++++++++++++++ .github/cross-files/ubuntu-cross.ini | 9 +++++++++ .github/workflows/main.yml | 4 ++++ 3 files changed, 36 insertions(+) create mode 100644 .github/actions/setup-ubuntu/action.yml create mode 100644 .github/cross-files/ubuntu-cross.ini diff --git a/.github/actions/setup-ubuntu/action.yml b/.github/actions/setup-ubuntu/action.yml new file mode 100644 index 0000000..a1dad18 --- /dev/null +++ b/.github/actions/setup-ubuntu/action.yml @@ -0,0 +1,23 @@ +name: 'setup Ubuntu' +description: 'Setup an Ubuntu container for running CI' +runs: + using: 'composite' + steps: + - name: Install dependencies + shell: bash + run: | + dpkg --add-architecture i386 + apt-get update + apt-get install --yes \ + build-essential \ + crossbuild-essential-i386 \ + gcc \ + git \ + libudev-dev \ + libudev-dev:i386 \ + libusb-1.0-0-dev \ + libusb-1.0-0-dev:i386 \ + linux-libc-dev \ + meson \ + pkgconf \ + pkgconf:i386 diff --git a/.github/cross-files/ubuntu-cross.ini b/.github/cross-files/ubuntu-cross.ini new file mode 100644 index 0000000..d2a8398 --- /dev/null +++ b/.github/cross-files/ubuntu-cross.ini @@ -0,0 +1,9 @@ +[binaries] +c = 'i686-linux-gnu-gcc' +pkgconfig = 'i686-linux-gnu-pkg-config' + +[host_machine] +system = 'linux' +cpu_family = 'x86' +cpu = 'i686' +endian = 'little' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index de6af5f..324d5b9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,6 +24,8 @@ jobs: - container: 'debian:unstable' crossfile: 'debian-cross.ini' - container: 'fedora:latest' + - container: 'ubuntu:24.04' + crossfile: 'ubuntu-cross.ini' container: image: ${{ matrix.container }} @@ -42,6 +44,8 @@ jobs: if: ${{ startsWith(matrix.container, 'debian') }} - uses: ./.github/actions/setup-fedora if: ${{ startsWith(matrix.container, 'fedora') }} + - uses: ./.github/actions/setup-ubuntu + if: ${{ startsWith(matrix.container, 'ubuntu') }} - name: Checkout the whole project uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 From 15f33f0dc49ec58c8761fa33da2afc0486164610 Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Thu, 19 Sep 2024 18:27:50 +0100 Subject: [PATCH 13/13] ci: add codeql (static analysis) based on main.yml Signed-off-by: Emil Velikov --- .github/workflows/codeql.yml | 64 ++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..c7d28f5 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,64 @@ +name: CodeQL + +on: + push: + branches: [master, ci-test] + pull_request: + branches: [master] + schedule: + - cron: "30 2 * * 0" + +permissions: + contents: read + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + security-events: write + + strategy: + fail-fast: false + matrix: + include: + - container: 'ubuntu:24.04' + + container: + image: ${{ matrix.container }} + + steps: + - name: Sparse checkout the local actions + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + sparse-checkout: .github + + - uses: ./.github/actions/setup-ubuntu + if: ${{ startsWith(matrix.container, 'ubuntu') }} + + - name: Checkout the whole project + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Set the environment + run: | + # The second checkout above claims to set safe.directory, yet it + # doesn't quite work. Perhaps our double/sparse checkout is to blame? + git config --global --add safe.directory '*' + + - name: Initialize CodeQL + uses: github/codeql-action/init@8214744c546c1e5c8f03dde8fab3a7353211988d # v3.26.7 + with: + languages: cpp + queries: +security-and-quality + + - name: Build + run: | + mkdir build && cd build + meson setup --native-file ../build-dev.ini . .. + meson compile + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@8214744c546c1e5c8f03dde8fab3a7353211988d # v3.26.7 + with: + category: "/language:cpp"