Skip to content

test vale gha pr

test vale gha pr #80

Workflow file for this run

name: Lint and suggest
on:
pull_request:
paths:
- '**/*.md'
jobs:
vale: # Vale linting job
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
- name: Install Vale
uses: errata-ai/vale-action@v2
- name: Install jq
run: sudo apt-get install -y jq
- name: Get changed files
id: changed-files
run: |
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]')"
- name: Print Changed Files
run: echo $CHANGED_FILES
- name: Run Vale on changed files
run: |
echo "[]" > rdjson_output.jsonl
for file in $(echo ${{ steps.changed-files.outputs.files }} | jq -r '.[]'); do
echo "Running Vale on $file"
vale --output=JSON $file | jq -c '.[] | {file: "'$file'", line: .Line, column: .Span[0], message: .Message, suggestion: (.Suggestions[0] // "")}' >> rdjson_output.jsonl || echo "Error processing $file"
done
echo "Vale output:"
cat rdjson_output.jsonl
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.REVIEWDOG_GITHUB_API_TOKEN }}
- name: Check if rdjson_output.jsonl exists
run: |
if [ -f rdjson_output.jsonl ]; then
echo "rdjson_output.jsonl exists."
else
echo "rdjson_output.jsonl does not exist."
exit 1
fi
- name: Upload Vale results
uses: actions/upload-artifact@v3
with:
name: vale-results
path: rdjson_output.jsonl
suggest: # Reviewdog suggestion job
runs-on: ubuntu-latest
needs: vale # This ensures the suggest job runs after the vale job
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download Vale results
uses: actions/download-artifact@v3
with:
name: vale-results
- name: List downloaded files
run: ls -l
- name: Check if rdjson_output.jsonl exists
run: |
if [ -f rdjson_output.jsonl ]; then
echo "rdjson_output.jsonl exists."
else
echo "rdjson_output.jsonl does not exist."
exit 1
fi
- name: Run Reviewdog Suggestion Action
uses: reviewdog/action-suggester@v1
with:
github_token: ${{ secrets.REVIEWDOG_GITHUB_API_TOKEN }}
tool_name: Vale
level: "warning"
filter_mode: "diff_context"
fail_on_error: "false"
reviewdog_flags: ""
cleanup: "true"
- name: Run Reviewdog with Vale results
run: |
cat rdjson_output.jsonl
reviewdog -f=rdjsonl -name="Vale" -reporter=github-pr-review -level=warning -filter-mode=nofilter < rdjson_output.jsonl
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.REVIEWDOG_GITHUB_API_TOKEN }}