diff --git a/.github/workflows/file_format.py b/.github/workflows/file_format.py new file mode 100755 index 0000000..d74589c --- /dev/null +++ b/.github/workflows/file_format.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import sys + +if len(sys.argv) < 2: + print("Invalid usage of file_format.py, it should be called with a path to one or multiple files.") + sys.exit(1) + +BOM = b"\xef\xbb\xbf" + +changed = [] +invalid = [] + +for file in sys.argv[1:]: + try: + with open(file, "rt", encoding="utf-8") as f: + original = f.read() + except UnicodeDecodeError: + invalid.append(file) + continue + + if original == "": + continue + + EOL = "\n" + revamp = EOL.join([line.rstrip("\n\r\t ") for line in original.splitlines(True)]).rstrip(EOL) + EOL + + new_raw = revamp.encode(encoding="utf-8") + if new_raw.startswith(BOM): + new_raw = new_raw[len(BOM) :] + + with open(file, "rb") as f: + old_raw = f.read() + + if old_raw != new_raw: + changed.append(file) + with open(file, "wb") as f: + f.write(new_raw) + +if changed: + for file in changed: + print(f"FIXED: {file}") + +if invalid: + for file in invalid: + print(f"REQUIRES MANUAL CHANGES: {file}") + sys.exit(1) diff --git a/.github/workflows/flatpak-builder.yml b/.github/workflows/flatpak-builder.yml index cbb98e3..ed0b965 100644 --- a/.github/workflows/flatpak-builder.yml +++ b/.github/workflows/flatpak-builder.yml @@ -18,4 +18,4 @@ jobs: uses: flatpak/flatpak-github-actions/flatpak-builder@v6.1 with: bundle: io.github.flattool.Warehouse.flatpak - manifest-path: io.github.flattool.Warehouse.json \ No newline at end of file + manifest-path: io.github.flattool.Warehouse.json diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml new file mode 100644 index 0000000..f84b8eb --- /dev/null +++ b/.github/workflows/static_checks.yml @@ -0,0 +1,33 @@ +name: 📊 Static Checks +on: [push, pull_request] + +concurrency: + group: ci-${{ github.actor }}-${{ github.head_ref || github.run_number }}-${{ github.ref }}-static + +jobs: + static-checks: + name: Code style and file formatting + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Install APT dependencies + uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: libxml2-utils + + - name: Install Python dependencies and general setup + run: | + git config diff.wsErrorHighlight all + + - name: Style checks via pre-commit + uses: pre-commit/action@v3.0.1 + with: + extra_args: --all-files + + - name: XML validation via xmllint + run: | + xmllint --noout warehouse.doap data/io.github.flattool.Warehouse.gschema.xml data/io.github.flattool.Warehouse.metainfo.xml.in src/warehouse.gresource.xml diff --git a/.gitignore b/.gitignore index 33951cd..fc04db3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ /subprojects/blueprint-compiler +.DS_Store .flatpak .flatpak-builder +.idea/ +.ruff_cache/ .vscode -.DS_Store diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..d86859a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,33 @@ +default_language_version: + python: python3 + +exclude: | + (?x)^( + CODE_OF_CONDUCT.md + ) + +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.6.6 + hooks: + - id: ruff + args: [--fix] + - id: ruff-format + + - repo: https://github.com/codespell-project/codespell + rev: v2.3.0 + hooks: + - id: codespell + exclude: | + (?x)^( + .*\.po$ + ) + additional_dependencies: [tomli] + + - repo: local + hooks: + - id: file-format + name: file-format + language: python + entry: python .github/workflows/file_format.py + types_or: [text] diff --git a/COPYING b/COPYING index 10926e8..94a9ed0 100644 --- a/COPYING +++ b/COPYING @@ -672,4 +672,3 @@ may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . - diff --git a/README.md b/README.md index 9bc50fe..17e26b6 100644 --- a/README.md +++ b/README.md @@ -56,3 +56,18 @@ You're all set! Launch the application by clicking its icon in your app menu or ```shell flatpak run io.github.flattool.Warehouse ``` + +## 👥 Contributing + +### Compiling from Source + +TODO + +### Formatting + +Warehouse uses [pre-commit](https://pre-commit.com/) for code formatting. +- Install using `pip install pre-commit` +- Run `pre-commit install` in the Warehouse repository root to set up pre-commit for this repo. +- Run `pre-commit run --all-files` to format all files in the repository. + +If you run into a situation where pre-commit is broken, you can use `git commit --no-verfiy` to skip the pre-commit checks. diff --git a/data/io.github.flattool.Warehouse.metainfo.xml.in b/data/io.github.flattool.Warehouse.metainfo.xml.in index 8d7c6c3..d03ccf0 100644 --- a/data/io.github.flattool.Warehouse.metainfo.xml.in +++ b/data/io.github.flattool.Warehouse.metainfo.xml.in @@ -139,7 +139,7 @@
  • Update to GNOME 46 GTK Technologies
  • Updated translations
  • -

    Previous Releases's Bug Fixes

    +

    Previous Releases's Bug Fixes

    -

    Bug Fixes

    +

    Bug Fixes