Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: gradually reduce null-check errors #3094

Merged
merged 14 commits into from Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/gradual-strict-null-checks.yml
@@ -0,0 +1,50 @@
name: Lower null checks

on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

steps:
- name: Checkout current branch
uses: actions/checkout@v3
with:
path: current
- name: Checkout main branch
uses: actions/checkout@v3
with:
ref: main
path: main
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
cache-dependency-path: |
current/yarn.lock
main/yarn.lock
# intentionally use the same script from current branch against both repositories
- run: |
./current/scripts/gradual-strict-null-checks.sh ./current > ./current-count &
pid1=$!
./current/scripts/gradual-strict-null-checks.sh ./main > ./main-count &
pid2=$!
wait $pid1 && wait $pid2
MAIN=$(cat ./main-count)
CURRENT=$(cat ./current-count)
if [ $CURRENT -gt $MAIN ]; then
echo "The PR is increasing the number of null check errors from ${MAIN} to ${CURRENT}. Check if your branch is up-to-date and consider fixing them before merging"
exit 1
else
echo "The PR has $CURRENT null check errors against $MAIN in main. You're good to go!"
fi
13 changes: 13 additions & 0 deletions scripts/gradual-strict-null-checks.sh
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -e
FOLDER="${1:-.}"

cd "${FOLDER}"

# update strictNullChecks
sed -i 's/\/\/\s*"strictNullChecks":\s*true,/"strictNullChecks": true,/' "./tsconfig.json"

# count errors
ERRORS=$(yarn 2> /dev/null | grep "Found [0-9]* errors" | sed 's/Found \(.*\) errors in .* files./\1/')

echo ${ERRORS:-0}
gastonfournier marked this conversation as resolved.
Show resolved Hide resolved