Skip to content

Commit

Permalink
Test counting different branches
Browse files Browse the repository at this point in the history
  • Loading branch information
gastonfournier committed Feb 13, 2023
1 parent d45a5a1 commit e627ae3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/gradual-strict-null-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: ./current/scripts/gradual-strict-null-checks.sh
- run: ./current/scripts/gradual-strict-null-checks.sh ./current > ./current-count
- run: ./current/scripts/gradual-strict-null-checks.sh ./main > ./main-count
- run: cat ./current-count
- run: cat ./main-count
27 changes: 8 additions & 19 deletions scripts/gradual-strict-null-checks.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
#!/usr/bin/env bash
SCRIPT_DIR=$( dirname -- "$0" )
CURRENT_BRANCH=$(git branch --show-current)
MAIN_BRANCH_DIR=${1:-../main}
set -e
FOLDER="${1:-.}"

# update strictNullChecks in main and current branch
sed -i 's/\/\/\s*"strictNullChecks":\s*true,/"strictNullChecks": true,/' "${MAIN_BRANCH_DIR}/tsconfig.json"
sed -i 's/\/\/\s*"strictNullChecks":\s*true,/"strictNullChecks": true,/' "${SCRIPT_DIR}/../tsconfig.json"
cd "${FOLDER}"

# count errors
MAIN_ERRORS=$(cd "${MAIN_BRANCH}"; yarn 2> /dev/null | grep "Found [0-9]* errors" | sed 's/Found \(.*\) errors in .* files./\1/')
BRANCH_ERRORS=$(yarn 2> /dev/null | grep "Found [0-9]* errors" | sed 's/Found \(.*\) errors in .* files./\1/')
# update strictNullChecks
sed -i 's/\/\/\s*"strictNullChecks":\s*true,/"strictNullChecks": true,/' "./tsconfig.json"

# reset tsconfig changes
git checkout -- "${SCRIPT_DIR}/../tsconfig.json"
$(cd "${MAIN_BRANCH}"; git checkout -- tsconfig.json)
# count errors
ERRORS=$(yarn 2> /dev/null | grep "Found [0-9]* errors" | sed 's/Found \(.*\) errors in .* files./\1/')

if [ $BRANCH_ERRORS -gt $MAIN_ERRORS ]; then
echo "Null check errors in ${CURRENT_BRANCH} are higher than in ${MAIN_BRANCH}: ${BRANCH_ERRORS} vs ${MAIN_ERRORS}. Please fix them before merging."
exit 1
else
echo "Branch null check errors: ${BRANCH_ERRORS} vs ${MAIN_BRANCH}: ${MAIN_ERRORS} - You're good to go!"
exit 0
fi
echo ${ERRORS:-0}

0 comments on commit e627ae3

Please sign in to comment.