Skip to content

Commit

Permalink
Merge branch 'test-vale' into test-vale-pr
Browse files Browse the repository at this point in the history
  • Loading branch information
mirnawong1 authored Jun 17, 2024
2 parents 583a616 + 4b3f76b commit a579a3c
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions .github/workflows/vale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@ on:
paths:
- '**/*.md'

permissions:
contents: read
checks: write
issues: write
pull-requests: write

jobs:
vale:
vale: # Vale linting job
runs-on: ubuntu-latest

steps:
Expand All @@ -33,14 +27,14 @@ 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 "::set-output name=files::$(echo $CHANGED_FILES | jq -R -s -c 'split("\n")[:-1]')"
echo "CHANGED_FILES=$(echo $CHANGED_FILES | jq -R -s -c 'split(\"\n\")[:-1]')" >> $GITHUB_ENV
- name: Print Changed Files
run: echo $CHANGED_FILES

- name: Run Vale on changed files
run: |
for file in $(echo ${{ steps.changed-files.outputs.files }} | jq -r '.[]'); do
for file in ${{ env.CHANGED_FILES }}; do
echo "Running Vale on $file"
vale --output=JSON $file > "vale_output_${file//\//_}.json"
vale --output=edit $file > "vale_output_${file//\//_}_edit.md"
Expand All @@ -52,7 +46,7 @@ jobs:
run: |
mkdir -p original_files
mkdir -p corrected_files
for file in $(echo ${{ steps.changed-files.outputs.files }} | jq -r '.[]'); do
for file in ${{ env.CHANGED_FILES }}; do
echo "Copying $file to original_files/${file//\//_}.original"
cp "$file" "original_files/${file//\//_}.original"
echo "Copying vale_output_${file//\//_}_edit.md to corrected_files/${file//\//_}"
Expand All @@ -62,8 +56,6 @@ jobs:
ls -l original_files
echo "Corrected files:"
ls -l corrected_files
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.REVIEWDOG_GITHUB_API_TOKEN }}
- name: Upload original files
uses: actions/upload-artifact@v3
Expand All @@ -77,9 +69,9 @@ jobs:
name: corrected-files
path: corrected_files/

suggest:
suggest: # Reviewdog suggestion job
runs-on: ubuntu-latest
needs: vale
needs: vale # This ensures the suggest job runs after the vale job

steps:
- name: Checkout code
Expand Down Expand Up @@ -115,18 +107,13 @@ jobs:

- name: Run Reviewdog with corrected files
run: |
mkdir -p temp_diff
for file in original_files/*.original; do
original="$file"
corrected="corrected_files/$(basename "$file" .original)"
diff_output=$(diff -u "$original" "$corrected")
if [[ -n "$diff_output" ]]; then
echo "$diff_output" > "temp_diff/$(basename "$file" .original).diff"
echo "$diff_output" | reviewdog -f=diff -name="Vale" -reporter=github-pr-review -level=warning -filter-mode=nofilter
fi
done
ls temp_diff/
for diff_file in temp_diff/*.diff; do
reviewdog -f=diff -name="Vale" -reporter=github-pr-review -level=warning -filter-mode=nofilter < "$diff_file"
done
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.REVIEWDOG_GITHUB_API_TOKEN }}

0 comments on commit a579a3c

Please sign in to comment.