diff options
| author | Trung Lê <8@tle.id.au> | 2026-06-10 10:04:30 +1000 |
|---|---|---|
| committer | Trung Lê <8@tle.id.au> | 2026-06-10 10:04:30 +1000 |
| commit | f6009527636f8a8017d5b9192efe96a1d03d2028 (patch) | |
| tree | e9d1a229cb32e08534f10cbf0ae489840add73ac /.github | |
| parent | 76ff689850c160e7eca27ee51852dcf17cc1938a (diff) | |
ci: adopt gobject-linter as a blocking static-analysis gate
Add gobject-linter (github.com/bilelmoussaoui/gobject-linter) to CI to catch
GObject/GLib correctness and idiom issues.
Config (gobject-linter.toml):
- min_glib_version = 2.80 (libadwaita >= 1.8)
- default_level = error: every enabled rule blocks CI
- type_style ignored: the project deliberately uses plain C scalar types
- untranslated_string ignored: app is not internationalized yet
- use_auto_cleanup downgraded to warn: it mis-fires on floating GVariant
references (consumed by g_variant_new_tuple/builders) and on objects kept
alive past the function (the GlobalShortcuts GDBusProxy); converting those to
g_autoptr would over-unref and crash, so it advises rather than blocks
Workflow (.github/workflows/gobject-linter.yml): runs the official container
image on push/PR, uploads SARIF to code scanning (non-fatal for fork PRs), and
fails the build on any error-level finding.
Code is brought to a green baseline by applying the auto-fixable findings:
- strcmp -> g_strcmp0 (NULL-safe)
- manual g_free/g_strdup -> g_set_str
- manual source removal -> g_clear_handle_id / g_clear_object / g_clear_pointer
- g_string_free(.., FALSE) -> g_string_free_and_steal
- g_idle_add one-shot -> g_idle_add_once (id now stored and cleared in finalize,
also closing a latent use-after-free if the window is finalized first)
- include ordering and #pragma once
The 37 remaining use_auto_cleanup findings are reported as warnings for
incremental manual review.
Diffstat (limited to '.github')
| -rw-r--r-- | .github/workflows/gobject-linter.yml | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/.github/workflows/gobject-linter.yml b/.github/workflows/gobject-linter.yml new file mode 100644 index 0000000..403871f --- /dev/null +++ b/.github/workflows/gobject-linter.yml @@ -0,0 +1,44 @@ +name: GObject Lint + +# Static analysis of the GObject/GLib C code with gobject-linter. +# Rules and severities are configured in ./gobject-linter.toml. +# This is a blocking gate: the "Lint (blocking)" step fails the build on any +# error-level finding. use_auto_cleanup is configured as a warning and does not +# block (it mis-fires on floating GVariant references; see gobject-linter.toml). + +on: + push: + branches: [ main ] + pull_request: + +permissions: + contents: read + +jobs: + gobject-linter: + runs-on: ubuntu-latest + container: + image: ghcr.io/bilelmoussaoui/gobject-linter:latest + permissions: + contents: read + security-events: write + steps: + - uses: actions/checkout@v4 + + # Produce SARIF for the Security tab and inline PR annotations. + # Never fails the job — the blocking gate below decides pass/fail. + - name: Analyze (SARIF) + run: gobject-linter . --format sarif > gobject-linter.sarif || true + + - name: Upload SARIF + uses: github/codeql-action/upload-sarif@v3 + # Pull requests from forks get a read-only token and cannot upload to + # code scanning; don't let that fail the run. + continue-on-error: true + with: + sarif_file: gobject-linter.sarif + category: gobject-linter + + # Blocking gate: exits non-zero on any error-level finding. + - name: Lint (blocking) + run: gobject-linter . |
