From 477333137fc27dfc8c8877ab02b31cac2bf20e0f Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Tue, 6 Feb 2024 09:27:09 -0500 Subject: [PATCH] Lint .desktop files in CI This ports the `lint-desktop-files` CI job from the securedrop-builder repository. --- .github/workflows/ci.yml | 23 +++++++++++++++++++++++ Makefile | 22 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 Makefile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..5a976dec23 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,23 @@ +name: CI +on: [push, pull_request] + +defaults: + run: + shell: bash + +jobs: + lint-desktop: + strategy: + matrix: + debian_version: + - bullseye + - bookworm + runs-on: ubuntu-latest + container: debian:${{ matrix.debian_version }} + steps: + - run: | + apt-get update && apt-get install --yes git make desktop-file-utils + - uses: actions/checkout@v4 + - name: Lint .desktop files + run: | + make lint-desktop diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..68464757eb --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +.PHONY: all +all: help + +.PHONY: lint-desktop +lint-desktop: ## Lint .desktop files + find . -name *.desktop -type f -not -path '*/\.git/*' | xargs desktop-file-validate + + +# Explanation of the below shell command should it ever break. +# 1. Set the field separator to ": ##" and any make targets that might appear between : and ## +# 2. Use sed-like syntax to remove the make targets +# 3. Format the split fields into $$1) the target name (in blue) and $$2) the target description +# 4. Pass this file as an arg to awk +# 5. Sort it alphabetically +# 6. Format columns with colon as delimiter. +.PHONY: help +help: ## Print this message and exit. + @printf "Makefile for developing and testing the SecureDrop client.\n" + @printf "Subcommands:\n\n" + @awk 'BEGIN {FS = ":.*?## "} /^[0-9a-zA-Z_-]+:.*?## / {printf "\033[36m%s\033[0m : %s\n", $$1, $$2}' $(MAKEFILE_LIST) \ + | sort \ + | column -s ':' -t