Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format Vala code #41

Merged
merged 13 commits into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ indent_style = tab

[*.py]
indent_size = 4

[*.rs]
indent_size = 4

[*.vala]
indent_size = 4
43 changes: 34 additions & 9 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
CI:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -17,16 +17,41 @@ jobs:
node-version: 18
cache: "npm"

# See also https://github.com/flatpak/flatpak-github-actions
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: flatpak flatpak-builder
version: 1.0
- name: Install host dependencies
run: |
sudo apt-get update
sudo apt-get install flatpak flatpak-builder mutter

- name: Cache Flatpak dependencies
uses: actions/cache@v3
# Restore caches
- name: Restore Flatpak dependencies
uses: actions/cache/restore@v3
with:
path: ~/.local/share/flatpak
key: 45
key: ${{ runner.os }}-flatpak-dependencies-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-flatpak-dependencies-
- name: Restore .flatpak-builder
uses: actions/cache/restore@v3
with:
path: Workbench/.flatpak-builder
key: ${{ runner.os }}-flatpak-builder-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-flatpak-builder-

- run: mutter --wayland --no-x11 --headless --wayland-display=wayland-0 --virtual-monitor 1280x720 > /tmp/mutter.log 2>&1 &
- run: make ci
- run: cat /tmp/mutter.log

# Save caches
- name: Save Flatpak dependencies
uses: actions/cache/save@v3
if: always()
with:
path: ~/.local/share/flatpak
key: ${{ runner.os }}-flatpak-dependencies-${{ github.run_id }}
- name: Save .flatpak-builder
uses: actions/cache/save@v3
if: always()
with:
path: Workbench/.flatpak-builder
key: ${{ runner.os }}-flatpak-builder-${{ github.run_id }}
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "Workbench"]
path = Workbench
url = https://github.com/workbenchdev/Workbench.git
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ SHELL:=/bin/bash -O globstar
.DEFAULT_GOAL := ci

setup:
flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak install --or-update --user --noninteractive flathub org.gnome.Sdk//45 org.freedesktop.Sdk.Extension.rust-stable//23.08
npm install
flatpak-builder --ccache --force-clean flatpak build-aux/re.sonny.Workbench.Demos.json
cd Workbench && make build

lint:
# JavaScript
# ./node_modules/.bin/eslint --max-warnings=0 src
./build-aux/fun biome ci demos/
# rustfmt
./build-aux/fun rustfmt --check --edition 2021 demos/**/*.rs
# black
./build-aux/fun black --check demos/**/*.py
./Workbench/build-aux/fun workbench-cli ci javascript demos/**/*.js
# Vala
# ./Workbench/build-aux/fun workbench-cli ci vala demos/**/*.vala
# Blueprint
find demos/ -type f -name "*blp" -print0 | xargs -0 ./build-aux/fun blueprint-compiler format
# ./Workbench/build-aux/fun workbench-cli ci blueprint demos/**/*.blp
# CSS
# ./Workbench/build-aux/fun workbench-cli ci css demos/**/*.css
# Rust
./Workbench/build-aux/fun rustfmt --check --edition 2021 demos/**/*.rs
# Python
./Workbench/build-aux/fun black --check demos/**/*.py
Comment on lines +11 to +20
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I commented those that do not pass yet.

I will fix the demos in a subsequent PR
workbench-cli already uncovered quite a few issues 🎉

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "do not pass" mean? Isn't all vala code formatted with the formatter, so linting should succeed, or is the linter or formater not 100% doing its job? (So that would mean fixing the linter/formater?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look at the code for the context of the comment


test: lint

Expand Down
1 change: 1 addition & 0 deletions Workbench
Submodule Workbench added at 2b23ea
19 changes: 0 additions & 19 deletions biome.json

This file was deleted.

4 changes: 0 additions & 4 deletions build-aux/fun

This file was deleted.

21 changes: 0 additions & 21 deletions build-aux/modules/biome.json

This file was deleted.

11 changes: 0 additions & 11 deletions build-aux/modules/blueprint-compiler.json

This file was deleted.

104 changes: 0 additions & 104 deletions build-aux/modules/python-black.json

This file was deleted.

17 changes: 0 additions & 17 deletions build-aux/re.sonny.Workbench.Demos.json

This file was deleted.

26 changes: 13 additions & 13 deletions demos/About Window/main.vala
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/env -S vala workbench.vala --pkg gtk4 --pkg libadwaita-1
#! /usr/bin/env -S vala workbench.vala --pkg gtk4 --pkg libadwaita-1

sonnyp marked this conversation as resolved.
Show resolved Hide resolved
public void main () {
Gtk.init ();
Gtk.init ();

var button = workbench.builder.get_object ("button") as Gtk.Button;
button.clicked.connect(on_button_clicked);
var button = workbench.builder.get_object ("button") as Gtk.Button;
button.clicked.connect (on_button_clicked);
}

public void on_button_clicked () {
// https://valadoc.org/libadwaita-1/Adw.AboutWindow.html
var dialog = new Adw.AboutWindow() {
var dialog = new Adw.AboutWindow () {
transient_for = workbench.window,
application_icon = "application-x-executable",
application_name = "Typeset",
Expand All @@ -26,17 +26,17 @@ public void on_button_clicked () {
translator_credits = "translator-credits",
};
dialog.add_link (
"Documentation",
"https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.4/class.AboutWindow.html"
"Documentation",
"https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.4/class.AboutWindow.html"
);
dialog.add_legal_section (
"Fonts",
null,
Gtk.License.CUSTOM,
"This application uses font data from <a href='https://example.org'>somewhere</a>."
"Fonts",
null,
Gtk.License.CUSTOM,
"This application uses font data from <a href='https://example.org'>somewhere</a>."
);

dialog.add_acknowledgement_section ("Special thanks to", { "My cat" } );
dialog.add_acknowledgement_section ("Special thanks to", { "My cat" });

dialog.present();
dialog.present ();
}
Loading
Loading