Closed cjyetman closed 3 years ago
could be as easy as adding another regex to exclude (No such file or directory)$
, like...
- name: list all changed files with the wrong encoding
run: |
files=$(git diff --name-only origin/$GITHUB_BASE_REF...${{ github.sha }})
IFS=$'\n'; files=($files); unset IFS; # split the string into an array
! file --mime "${files[@]}" | grep -v "charset=utf-8\|charset=us-ascii\|charset=binary\|(No such file or directory)$"
Note to self: Maybe to follow up in https://github.com/2DegreesInvesting/r2dii.usethis/pull/38
Note to self: Maybe to follow up in https://github.com/2DegreesInvesting/r2dii.usethis/pull/38
Ah, right. Maybe that's the best place to fix it since this isn't even functional?
I can't edit the PR at #38, but I tested this change here and got the expected result with...
name: check file encodings in PR
on: [pull_request]
jobs:
file-encoding:
name: file encooding check
runs-on: ubuntu-latest
steps:
- name: run the checkout action
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: list all changed files
run: |
files=$(git diff --name-only origin/$GITHUB_BASE_REF...${{ github.sha }})
IFS=$'\n'; files=($files); unset IFS; # split the string into an array
file --mime "${files[@]}"
- name: list all changed files with the wrong encoding
run: |
files=$(git diff --name-only origin/$GITHUB_BASE_REF...${{ github.sha }})
IFS=$'\n'; files=($files); unset IFS; # split the string into an array
! file --mime "${files[@]}" | grep -v "charset=utf-8\|charset=us-ascii\|charset=binary\| (No such file or directory)$"
The action specification for pr-file-encodings.yml should take into account that in a PR some files will be removed completely, and therefore their encoding will be unable to be determined, and the result of the critical command might look like...
thanks to @jacobvjk for reporting here: https://github.com/2DegreesInvesting/r2dii.stress.test.data/pull/16#issuecomment-870410694