From 95d300379adafafa849f703613dfbaa40ec982c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gast=C3=B3n=20Fournier?= Date: Thu, 16 Feb 2023 13:35:54 +0100 Subject: [PATCH] chore: moved GH action script to the yaml file (#3119) ## 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 --- .../workflows/gradual-strict-null-checks.yml | 28 ++++++++++++++----- scripts/gradual-strict-null-checks.sh | 13 --------- 2 files changed, 21 insertions(+), 20 deletions(-) delete mode 100755 scripts/gradual-strict-null-checks.sh diff --git a/.github/workflows/gradual-strict-null-checks.yml b/.github/workflows/gradual-strict-null-checks.yml index ed3bc21c07a..407393cce70 100644 --- a/.github/workflows/gradual-strict-null-checks.yml +++ b/.github/workflows/gradual-strict-null-checks.yml @@ -34,16 +34,30 @@ jobs: 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 & + - 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=$! - ./current/scripts/gradual-strict-null-checks.sh ./main > ./main-count & + + yarn --mutex network --cwd ./main 2> .stderr-main > .out-main & pid2=$! - wait $pid1 && wait $pid2 - MAIN=$(cat ./main-count) - CURRENT=$(cat ./current-count) + + # 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 - 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" + 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!" diff --git a/scripts/gradual-strict-null-checks.sh b/scripts/gradual-strict-null-checks.sh deleted file mode 100755 index 22a1ab839f9..00000000000 --- a/scripts/gradual-strict-null-checks.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/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} \ No newline at end of file