From ad96cd9f01c518746aabb35cd679b3d003c88ce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?= Date: Fri, 7 May 2021 22:10:54 +0200 Subject: [PATCH 1/2] Add tab detection to CI tests. --- .github/workflows/tab-finder.yml | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/tab-finder.yml diff --git a/.github/workflows/tab-finder.yml b/.github/workflows/tab-finder.yml new file mode 100644 index 0000000000000..fc8f727e504cb --- /dev/null +++ b/.github/workflows/tab-finder.yml @@ -0,0 +1,39 @@ +# Find tabs in modified text files +name: Tab finder +on: [push, pull_request] +env: + MAIN_BRANCH: dev +jobs: + build: + name: Tab finder + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v2 + with: + fetch-depth: 0 # needed to get the full history and pull from upstream + - name: Pull from upstream + run: | + # Update from upstream to avoid including missing commits in the diff + git config --global user.name "Nemo" # required on some servers + git config pull.rebase false + git remote add upstream https://github.com/AliceO2Group/AliceO2.git || exit 1 + git pull upstream ${{ env.MAIN_BRANCH }} || exit 1 + - name: Find tabs + run: | + # Find tabs in modified text files and show where they are + status=0 + # loop over changed files + for f in $(git diff --name-only upstream/${{ env.MAIN_BRANCH }}); do + # ignore binary files + file -bi "$f" | grep -q "charset=binary" && continue + # find tabs in file + echo "Scanning file: $f" + if grep -q -P "\t" "$f"; then + status=1 + echo "Found some tabs:" + # print out where the tabs are + grep -P -n -C 1 "\t" "$f" + fi + done + exit $status From 8b532c020aad68a25cda76af701a179272473352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?= Date: Mon, 17 May 2021 00:05:40 +0200 Subject: [PATCH 2/2] Improve diffing. --- .github/workflows/tab-finder.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tab-finder.yml b/.github/workflows/tab-finder.yml index fc8f727e504cb..4fca06d65efaf 100644 --- a/.github/workflows/tab-finder.yml +++ b/.github/workflows/tab-finder.yml @@ -11,20 +11,22 @@ jobs: - name: Checkout Code uses: actions/checkout@v2 with: - fetch-depth: 0 # needed to get the full history and pull from upstream - - name: Pull from upstream + fetch-depth: 0 # needed to get the full history + - name: Fetch upstream run: | - # Update from upstream to avoid including missing commits in the diff + # Fetch the main upstream branch to find the common ancestor git config --global user.name "Nemo" # required on some servers - git config pull.rebase false git remote add upstream https://github.com/AliceO2Group/AliceO2.git || exit 1 - git pull upstream ${{ env.MAIN_BRANCH }} || exit 1 + git fetch upstream ${{ env.MAIN_BRANCH }} || exit 1 - name: Find tabs run: | # Find tabs in modified text files and show where they are status=0 + # Get the common ancestor of the current branch and the main upstream branch + BASE_COMMIT=$(git merge-base HEAD upstream/${{ env.MAIN_BRANCH }}) # loop over changed files - for f in $(git diff --name-only upstream/${{ env.MAIN_BRANCH }}); do + echo "Diffing against: $BASE_COMMIT" + for f in $(git diff --diff-filter d --name-only $BASE_COMMIT); do # ignore binary files file -bi "$f" | grep -q "charset=binary" && continue # find tabs in file