Skip to content

Commit 246fe3f

Browse files
committed
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 - fix: add src/, lib/ to code checks
1 parent aa4aee2 commit 246fe3f

4 files changed

Lines changed: 111 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Test building commits
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout Code
13+
uses: actions/checkout@v4
14+
15+
- name: Install System Dependencies
16+
run: |
17+
sudo apt-get update
18+
sudo apt-get install -y \
19+
meson ninja-build valac \
20+
libgtk-4-dev libadwaita-1-dev \
21+
libgranite-7-dev libgee-0.8-dev \
22+
libglib2.0-dev dbus-x11 libvala-0.56-dev\
23+
libjson-glib-dev libjson-glib-1.0-0 \
24+
gettext libgtksourceview-5-0 libgtksourceview-5-dev \
25+
desktop-file-utils appstream dbus-x11
26+
27+
- name: Configure and Build Folio
28+
run: |
29+
meson setup builddir --prefix=/usr
30+
meson compile -C builddir
31+
32+
- name: Run Tests
33+
env:
34+
GIO_USE_VFS: local
35+
run: |
36+
dbus-run-session -- meson test -C builddir --no-suite blueprint-compiler

.github/workflows/lint.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Check commits for Lint errors
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
lint:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout Code
12+
uses: actions/checkout@v4
13+
14+
- name: Install System Dependencies
15+
run: |
16+
sudo apt-get update
17+
sudo apt-get install -y \
18+
meson ninja-build valac \
19+
libgtk-4-dev libadwaita-1-dev \
20+
libgranite-7-dev libgee-0.8-dev \
21+
libglib2.0-dev dbus-x11 libvala-0.56-dev libjson-glib-dev libjson-glib-1.0-0
22+
23+
- name: Build vala-lint
24+
run: |
25+
git clone https://github.com/elementary/vala-lint.git --depth 1
26+
cd vala-lint
27+
meson setup builddir --prefix=/usr
28+
meson compile -C builddir
29+
sudo meson install -C builddir
30+
cd ..
31+
32+
- name: Lint Code
33+
shell: bash
34+
env:
35+
GIO_USE_VFS: local
36+
run: |
37+
dbus-run-session -- io.elementary.vala-lint src/ lib/
38+
39+

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: vala-lint
5+
name: Vala-Lint
6+
entry: env LD_LIBRARY_PATH=/usr/local/lib64 GIO_USE_VFS=local dbus-run-session -- io.elementary.vala-lint -c vala-lint.conf --fix src/ lib/
7+
language: system
8+
files: \.(vala|gs)$
9+

vala-lint.conf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[Checks]
2+
block-opening-brace-space-before=error
3+
double-semicolon=error
4+
double-spaces=error
5+
ellipsis=error
6+
line-length=warn
7+
naming-convention=error
8+
no-space=error
9+
note=warn
10+
space-before-paren=error
11+
use-of-tabs=off
12+
trailing-newlines=error
13+
trailing-whitespace=error
14+
unnecessary-string-template=error
15+
16+
[Disabler]
17+
disable-by-inline-comments=true
18+
19+
[line-length]
20+
max-line-length=120
21+
ignore-comments=true
22+
23+
[naming-convention]
24+
exceptions=UUID,
25+
26+
[note]
27+
keywords=TODO,FIXME,

0 commit comments

Comments
 (0)