From 832e1665a46270ecca64f4569f4ebd0299ca70bc Mon Sep 17 00:00:00 2001 From: Simon Sawert Date: Sat, 23 Nov 2024 22:00:29 +0100 Subject: [PATCH 1/2] Add workflow to check sorting --- .github/workflows/check_sorting.sh | 42 ++++++++++++++++++++++ .github/workflows/pr.yaml | 57 ++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 .github/workflows/check_sorting.sh create mode 100644 .github/workflows/pr.yaml diff --git a/.github/workflows/check_sorting.sh b/.github/workflows/check_sorting.sh new file mode 100644 index 0000000..cf0ae40 --- /dev/null +++ b/.github/workflows/check_sorting.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +file="awesome-generator/awesome.toml" +exit_code=0 + +IFS=";" + +# shellcheck disable=SC2207 +# This just feels like the easiest to understand. I don't know how to split the +# file on multiple newlines any better way. +# Ref: https://stackoverflow.com/a/62608718/2274551 +sections=($(awk -v RS= -v ORS=";" '{print}' "$file")) + +for section in "${sections[@]}"; do + header=$(echo "$section" | head -n 1) + rows=$(echo "$section" | tail -n +2) + sorted=$(echo "$rows" | sort) + + if [ "$rows" != "$sorted" ]; then + invalid_sections+=("$header") + exit_code=1 + fi +done + +if [ $exit_code -ne 0 ]; then + cat <<-EOF +Thanks for adding new resources to this project! + +To help with consistency and easie maintenance, e.g. spot duplicates the items in each section is sorted alphanumerically + +Your change doesn't conform to this so please ensure the section(s) you've edited are sorted! + +These sections are currently not sorted: + +EOF + + for s in "${invalid_sections[@]}"; do + echo " - \\\`$s\\\`" + done +fi + +exit $exit_code diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml new file mode 100644 index 0000000..f5924dc --- /dev/null +++ b/.github/workflows/pr.yaml @@ -0,0 +1,57 @@ +name: Validate `awesome.toml` + +on: + workflow_dispatch: + push: + branches: + - main + pull_request: + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Validate sections + id: validate + run: | + set +e # Allow the script to fail but capture its output + { + echo "output<> "$GITHUB_OUTPUT" + + echo "exit_code=$exit_code" >> "$GITHUB_OUTPUT" + + exit "$exit_code" + + - name: Post PR Comment + if: always() + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + run: | + PR_NUMBER=${{ github.event.pull_request.number }} + COMMENT_BODY="${{ steps.validate.outputs.output }}" + EXIT_CODE="${{ steps.validate.outputs.exit_code }}" + EXISTING_COMMENT=$(gh pr view "$PR_NUMBER" \ + --json comments \ + --jq '.comments[] | select(.author.login=="github-actions")') + + if [ "$EXIT_CODE" -ne 0 ]; then + if [ -n "$EXISTING_COMMENT" ]; then + gh pr comment "$PR_NUMBER" --body "$COMMENT_BODY" --edit-last + else + gh pr comment "$PR_NUMBER" --body "$COMMENT_BODY" + fi + else + if [ -n "$EXISTING_COMMENT" ]; then + # Currently the gh cli and the API fail to delete comments so we + # just update any existing one for now. + gh pr comment "$PR_NUMBER" --body "Thanks for fixing the CI issues!" --edit-last + fi + fi From 5d71926d6dea6eec5bd70d6b3fc5c1d873908607 Mon Sep 17 00:00:00 2001 From: Simon Sawert Date: Sat, 23 Nov 2024 22:03:38 +0100 Subject: [PATCH 2/2] Sort `device_apps` --- awesome-generator/awesome.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awesome-generator/awesome.toml b/awesome-generator/awesome.toml index 00c20b2..d769a63 100644 --- a/awesome-generator/awesome.toml +++ b/awesome-generator/awesome.toml @@ -408,6 +408,7 @@ [device_apps] "https://github.com/333fred/fta-monitor-garmin-watchapp" = {} +"https://github.com/BleachDev/GarminQ" = {} "https://github.com/BleachDev/Rainy" = {} "https://github.com/CernovApps/rubik-watch-timer" = { description = "This is a timer for Rubik Cube, with features that makes it similar to the WCA rules." } "https://github.com/Cybermite/GolfApp" = {} @@ -563,7 +564,6 @@ "https://gitlab.com/ravenfeld/Connect-IQ-App-ChronoGym" = { name = "Chrono Gym", description = "Set count and rest timer" } "https://gitlab.com/ravenfeld/Connect-IQ-App-Compass" = { name = "Compass App", description = "Compass" } "https://gitlab.com/ravenfeld/Connect-IQ-App-Timer" = { name = "Timer", description = "Add several timer already registered" } -"https://github.com/BleachDev/GarminQ" = {} [audio_content_providers] "https://github.com/memen45/SubMusic" = {}