Skip to content

Merge pull request #81 from reviewdog/depup/reviewdog #197

Merge pull request #81 from reviewdog/depup/reviewdog

Merge pull request #81 from reviewdog/depup/reviewdog #197

Workflow file for this run

name: Test
on:
push:
branches:
- master
pull_request:
jobs:
test-empty:
name: runner / black-format (empty)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./
with:
github_token: ${{ secrets.github_token }}
reporter: github-check
level: info
workdir: ./testdata/emptyfolder
- name: Check if code is left untouched (not formatted)
run: |
changed_files=$(git diff --name-only -- testdata/emptyfolder/ | wc -l)
if [[ ${changed_files} -eq 0 ]]; then
echo "No changes detected!"
else
echo "Changes detected!"
exit 1
fi
test-check:
name: runner / black-format (github-check)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./
with:
github_token: ${{ secrets.github_token }}
reporter: github-check
level: info
workdir: ./testdata/
- name: Check if code is left untouched (not formatted)
run: |
changed_files=$(git diff --name-only -- testdata/ | wc -l)
if [[ ${changed_files} -eq 0 ]]; then
echo "No changes detected!"
else
echo "Changes detected!"
exit 1
fi
- name: Check black would format the expected files
run: |
expected_files=(num_guess.py num_guess.ipynb subfolder/queen_problem.py subfolder/queen_problem.ipynb)
checked_files=(${{ env.BLACK_CHECK_FILE_PATHS }})
# Check whether the expected files are checked
for file in ${expected_files[@]}; do
if ! [[ " ${checked_files[*]} " == *"${file}"* ]]; then
echo "Black forgot to check file ${file}!"
exit 1
fi
done
# Check whether black checks files that should not be checked
for file in ${checked_files[@]}; do
trimmed_file="${file#${GITHUB_WORKSPACE}/testdata/}"
if ! [[ " ${expected_files[*]} " == *"${trimmed_file}"* ]]; then
echo "Unexpected file ${trimmed_file} got checked!"
exit 1
fi
done
echo "Black checked the expected files: [${expected_files[@]}] successfully!"
test-pr-check:
if: github.event_name == 'pull_request'
name: runner / black-format (github-pr-check)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
level: warning
workdir: ./testdata/
test-pr-review:
if: github.event_name == 'pull_request'
name: runner / black-format (github-pr-review)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
level: error
reviewdog_flags: -filter-mode=file -fail-on-error
workdir: ./testdata/