mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-23 00:22:19 +01:00
## About the changes - Actions are not counting successfully: https://github.com/Unleash/unleash/actions/runs/4181713524/jobs/7243938807#step:5:17 - This should fix an issue with running yarn concurrently (which might be leading to the zero counts) - Move the code to a GH action so it's easier to debug - Added a diff of the reported errors to help the PR author identify the potential cause
64 lines
2.1 KiB
YAML
64 lines
2.1 KiB
YAML
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
|
|
- name: Compare errors if enabling strictNullChecks
|
|
run: |
|
|
set -x
|
|
sed -i 's/\/\/\s*"strictNullChecks":\s*true,/"strictNullChecks": true,/' "current/tsconfig.json"
|
|
sed -i 's/\/\/\s*"strictNullChecks":\s*true,/"strictNullChecks": true,/' "main/tsconfig.json"
|
|
|
|
yarn --mutex network --cwd ./current 2> .stderr-current > .out-current &
|
|
pid1=$!
|
|
|
|
yarn --mutex network --cwd ./main 2> .stderr-main > .out-main &
|
|
pid2=$!
|
|
|
|
# wait for the processes that are expected to fail
|
|
set +e
|
|
wait $pid1
|
|
wait $pid2
|
|
set -e
|
|
|
|
CURRENT=$(grep "Found [0-9]* errors" .out-current | sed 's/Found \(.*\) errors in .* files./\1/')
|
|
MAIN=$(grep "Found [0-9]* errors" .out-main | sed 's/Found \(.*\) errors in .* files./\1/')
|
|
|
|
if [ $CURRENT -gt $MAIN ]; then
|
|
diff .out-current .out-main
|
|
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. The diff above should give you some details"
|
|
exit 1
|
|
else
|
|
echo "The PR has $CURRENT null check errors against $MAIN in main. You're good to go!"
|
|
fi |