From 2def59e147d1714a951c37a8ed48aa4fef4d0d01 Mon Sep 17 00:00:00 2001 From: kuya-carlo <106532351+kuya-carlo@users.noreply.github.com> Date: Mon, 30 Mar 2026 22:16:32 +0800 Subject: [PATCH] feat: add .pre-commit-config.yaml for vala-lint Integrate vala-lint to automate code style checks. See: https://github.com/vala-lang/vala-lint ci: add build and lint workflows ci: add vala-lint.conf --- .github/workflows/build.yml | 36 ++++++++++++++++++++++++++++++++++ .github/workflows/lint.yml | 39 +++++++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 9 +++++++++ vala-lint.conf | 27 +++++++++++++++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .pre-commit-config.yaml create mode 100644 vala-lint.conf diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..645bc62 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,36 @@ +name: Test building commits + +on: + push: + pull_request: + + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Install System Dependencies + run: | + sudo apt-get update + sudo apt-get install -y \ + meson ninja-build valac \ + libgtk-4-dev libadwaita-1-dev \ + libgranite-7-dev libgee-0.8-dev \ + libglib2.0-dev dbus-x11 libvala-0.56-dev\ + libjson-glib-dev libjson-glib-1.0-0 \ + gettext libgtksourceview-5-0 libgtksourceview-5-dev \ + desktop-file-utils appstream dbus-x11 + + - name: Configure and Build Folio + run: | + meson setup builddir --prefix=/usr + meson compile -C builddir + + - name: Run Tests + env: + GIO_USE_VFS: local + run: | + dbus-run-session -- meson test -C builddir --no-suite blueprint-compiler diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..d8c87f5 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,39 @@ +name: Check commits for Lint errors + +on: + push: + pull_request: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Install System Dependencies + run: | + sudo apt-get update + sudo apt-get install -y \ + meson ninja-build valac \ + libgtk-4-dev libadwaita-1-dev \ + libgranite-7-dev libgee-0.8-dev \ + libglib2.0-dev dbus-x11 libvala-0.56-dev libjson-glib-dev libjson-glib-1.0-0 + + - name: Build vala-lint + run: | + git clone https://github.com/elementary/vala-lint.git --depth 1 + cd vala-lint + meson setup builddir --prefix=/usr + meson compile -C builddir + sudo meson install -C builddir + cd .. + + - name: Lint Code + shell: bash + env: + GIO_USE_VFS: local + run: | + dbus-run-session -- io.elementary.vala-lint src/ + + diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..b7a9ba8 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,9 @@ +repos: + - repo: local + hooks: + - id: vala-lint + name: Vala-Lint + entry: env LD_LIBRARY_PATH=/usr/local/lib64 GIO_USE_VFS=local dbus-run-session -- io.elementary.vala-lint -c vala-lint.conf --fix . + language: system + files: \.(vala|gs)$ + diff --git a/vala-lint.conf b/vala-lint.conf new file mode 100644 index 0000000..9bbf582 --- /dev/null +++ b/vala-lint.conf @@ -0,0 +1,27 @@ +[Checks] +block-opening-brace-space-before=error +double-semicolon=error +double-spaces=error +ellipsis=error +line-length=warn +naming-convention=error +no-space=error +note=warn +space-before-paren=error +use-of-tabs=off +trailing-newlines=error +trailing-whitespace=error +unnecessary-string-template=error + +[Disabler] +disable-by-inline-comments=true + +[line-length] +max-line-length=120 +ignore-comments=true + +[naming-convention] +exceptions=UUID, + +[note] +keywords=TODO,FIXME,