From 1c20c18f1caef4f027d01da712c967c3bfe3da70 Mon Sep 17 00:00:00 2001 From: mirnawong1 Date: Mon, 17 Jun 2024 11:30:52 +0100 Subject: [PATCH 1/2] add --- styles/custom/Typos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/styles/custom/Typos.yml b/styles/custom/Typos.yml index 5d56dec1097..5940d57a48e 100644 --- a/styles/custom/Typos.yml +++ b/styles/custom/Typos.yml @@ -1,6 +1,6 @@ extends: substitution -message: "Oops there's a typo! Consider changing '{{.Match}}' to '{{.Suggestions}}.'" +message: "Oops there's a typo! Consider changing '%s' instead of '%s'" level: warning swap: - teh: the From 2e7be86084679df4e7d46c4e69fd72fcf746f988 Mon Sep 17 00:00:00 2001 From: mirnawong1 Date: Mon, 17 Jun 2024 11:32:32 +0100 Subject: [PATCH 2/2] add --- .github/workflows/vale.yml | 39 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/.github/workflows/vale.yml b/.github/workflows/vale.yml index 85903a3a9fd..efb4d8ae498 100644 --- a/.github/workflows/vale.yml +++ b/.github/workflows/vale.yml @@ -1,4 +1,4 @@ -name: Lint and suggest +name: Lint and Suggest on: pull_request: @@ -10,20 +10,19 @@ permissions: pull-requests: write jobs: - vale: # Vale linting job + vale: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 with: - fetch-depth: 0 # Fetch all history so we can access all commits + fetch-depth: 0 - name: Install Vale uses: errata-ai/vale-action@v2 - - - name: Install jq - run: sudo apt-get install -y jq + with: + version: latest - name: Get changed files id: changed-files @@ -31,27 +30,25 @@ jobs: BASE_SHA=$(git merge-base origin/${{ github.event.pull_request.base.ref }} ${{ github.sha }}) CHANGED_FILES=$(git diff --name-only $BASE_SHA ${{ github.sha }} -- '*.md') echo "CHANGED_FILES=$CHANGED_FILES" >> $GITHUB_ENV - echo "CHANGED_FILES=$(echo $CHANGED_FILES | jq -R -s -c 'split(\"\n\")[:-1]')" >> $GITHUB_ENV + echo "::set-output name=files::$(echo $CHANGED_FILES | jq -R -s -c 'split(\"\\n\")[:-1]')" - name: Print Changed Files run: echo $CHANGED_FILES - name: Run Vale on changed files run: | - for file in ${{ env.CHANGED_FILES }}; do + for file in $(echo ${{ steps.changed-files.outputs.files }} | jq -r '.[]'); do echo "Running Vale on $file" - vale --output=JSON $file > "vale_output_${file//\//_}.json" - vale --output=edit $file > "vale_output_${file//\//_}_edit.md" + vale --output=JSON "$file" > "vale_output_${file//\//_}.json" done echo "Vale outputs:" ls -l - - name: Simulate Vale changes + - name: Apply Vale suggestions run: | - mkdir -p simulated_changes + mkdir -p suggested_changes for file in $(echo ${{ steps.changed-files.outputs.files }} | jq -r '.[]'); do - cp "$file" "simulated_changes/$(basename "$file")" - vale --output=edit "simulated_changes/$(basename "$file")" + vale --output=line "$file" | grep -oP 'Consider changing.*' > suggested_changes/"$(basename "$file")".suggestions done - name: Upload Vale results @@ -60,27 +57,27 @@ jobs: name: vale-results path: '*.json' - - name: Upload simulated changes + - name: Upload suggested changes uses: actions/upload-artifact@v3 with: - name: simulated-changes - path: simulated_changes + name: suggested-changes + path: suggested_changes/ suggest: runs-on: ubuntu-latest - needs: vale # This ensures the suggest job runs after the vale job + needs: vale steps: - name: Checkout code uses: actions/checkout@v3 - - name: Download simulated changes + - name: Download suggested changes uses: actions/download-artifact@v3 with: - name: simulated-changes + name: suggested-changes - name: List downloaded files - run: ls -l simulated_changes + run: ls -l suggested_changes - name: Suggest changes uses: parkerbxyz/suggest-changes@v1