From ad9c03835152fcaf0e2fe32d8ff6e0a047618f10 Mon Sep 17 00:00:00 2001 From: paspo Date: Sat, 10 Aug 2024 12:14:50 +0200 Subject: [PATCH 1/3] markdownlint per le PR --- .gitea/workflows/markdownlint_pr.sh | 20 ++++++++++++++++++++ .gitea/workflows/unicode_check.yaml | 21 +++++++++++++++++++++ .markdownlint.yaml | 4 ++++ 3 files changed, 45 insertions(+) create mode 100644 .gitea/workflows/markdownlint_pr.sh create mode 100644 .gitea/workflows/unicode_check.yaml create mode 100644 .markdownlint.yaml diff --git a/.gitea/workflows/markdownlint_pr.sh b/.gitea/workflows/markdownlint_pr.sh new file mode 100644 index 0000000..62a68de --- /dev/null +++ b/.gitea/workflows/markdownlint_pr.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +echo +echo "Initial commit: $1" +echo "Final commit: $2" +echo + +# recupera ogni file modificato in questa PR (tra le 2 commit) +# considera solo i file che terminano con .md +# ogni file viene controllato con markdownlint, con la config comune + +EXIT=0 + +while read -r LINE; do + echo + echo "testing file: $LINE" + markdownlint --config .markdownlint.yaml "$LINE" || EXIT=1 +done < <(git diff --name-only "$1" "$2" content/ | grep \.md$) + +exit ${EXIT} diff --git a/.gitea/workflows/unicode_check.yaml b/.gitea/workflows/unicode_check.yaml new file mode 100644 index 0000000..980c883 --- /dev/null +++ b/.gitea/workflows/unicode_check.yaml @@ -0,0 +1,21 @@ +--- +name: Linting markdown on PR + +on: + pull_request: + +jobs: + unicode-check: + runs-on: ubuntu-latest + container: + image: catthehacker/ubuntu:act-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: run markdownlint on changed files + uses: docker://ghcr.io/igorshubovych/markdownlint-cli + with: + entrypoint: /bin/sh + args: -c 'apk -U add git bash ; bash .gitea/workflows/markdownlint_pr.sh ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}' diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..c0f2752 --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,4 @@ +# vedi: https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml + +default: true +MD013: false -- 2.45.2 From 8312aaf2af38a50917e908d046b66c95f033a4ce Mon Sep 17 00:00:00 2001 From: paspo Date: Sat, 10 Aug 2024 13:41:48 +0200 Subject: [PATCH 2/3] unwanted unicode --- .gitea/workflows/unicode_check.yaml | 4 ++++ .../workflows/unwanted_unicode_patterns.grep | 6 +++++ .gitea/workflows/unwanted_unicode_pr.sh | 23 +++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 .gitea/workflows/unwanted_unicode_patterns.grep create mode 100644 .gitea/workflows/unwanted_unicode_pr.sh diff --git a/.gitea/workflows/unicode_check.yaml b/.gitea/workflows/unicode_check.yaml index 980c883..ca6419a 100644 --- a/.gitea/workflows/unicode_check.yaml +++ b/.gitea/workflows/unicode_check.yaml @@ -19,3 +19,7 @@ jobs: with: entrypoint: /bin/sh args: -c 'apk -U add git bash ; bash .gitea/workflows/markdownlint_pr.sh ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}' + + - name: check for unwanted unicode runes + run: | + bash .gitea/workflows/unwanted_unicode_pr.sh ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}' diff --git a/.gitea/workflows/unwanted_unicode_patterns.grep b/.gitea/workflows/unwanted_unicode_patterns.grep new file mode 100644 index 0000000..2447505 --- /dev/null +++ b/.gitea/workflows/unwanted_unicode_patterns.grep @@ -0,0 +1,6 @@ +— +‘ +’ +“ +” +… diff --git a/.gitea/workflows/unwanted_unicode_pr.sh b/.gitea/workflows/unwanted_unicode_pr.sh new file mode 100644 index 0000000..e00ee2e --- /dev/null +++ b/.gitea/workflows/unwanted_unicode_pr.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +echo +echo "Initial commit: $1" +echo "Final commit: $2" +echo + +# recupera ogni file modificato in questa PR (tra le 2 commit) +# considera solo i file che terminano con .md +# ogni file viene controllato con grep, con i pattern definiti +# nel file di configurazione + +EXIT=0 + +while read -r LINE; do + if [ -r "$LINE" ] ; then + echo + echo "testing file: $LINE" + grep --color -f .gitea/workflows/unwanted_unicode_patterns.grep "$LINE" && EXIT=1 + fi +done < <(git diff --name-only "$1" "$2" content/ | grep \.md$) + +exit ${EXIT} -- 2.45.2 From b6a5246ec07c823d03f53fdbc5f599608abc5276 Mon Sep 17 00:00:00 2001 From: paspo Date: Sat, 10 Aug 2024 13:58:38 +0200 Subject: [PATCH 3/3] fix copypaste typo --- .gitea/workflows/unicode_check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/unicode_check.yaml b/.gitea/workflows/unicode_check.yaml index ca6419a..2c10314 100644 --- a/.gitea/workflows/unicode_check.yaml +++ b/.gitea/workflows/unicode_check.yaml @@ -22,4 +22,4 @@ jobs: - name: check for unwanted unicode runes run: | - bash .gitea/workflows/unwanted_unicode_pr.sh ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}' + bash .gitea/workflows/unwanted_unicode_pr.sh ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} -- 2.45.2