mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	chore: comment outcome of null check action (#3133)
## About the change Post a comment in the Pull Request rather than echo in the console in case of an error. Also, [reduced the null check errors by 26](https://github.com/Unleash/unleash/actions/runs/4196924954/jobs/7278564622#step:5:40)
This commit is contained in:
		
							parent
							
								
									8289ab4adf
								
							
						
					
					
						commit
						4d26088603
					
				
							
								
								
									
										18
									
								
								.github/workflows/gradual-strict-null-checks.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								.github/workflows/gradual-strict-null-checks.yml
									
									
									
									
										vendored
									
									
								
							@ -10,6 +10,8 @@ concurrency:
 | 
			
		||||
jobs:
 | 
			
		||||
  build:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    env:
 | 
			
		||||
      MAIN_BRANCH: main
 | 
			
		||||
 | 
			
		||||
    strategy:
 | 
			
		||||
      matrix:
 | 
			
		||||
@ -23,7 +25,7 @@ jobs:
 | 
			
		||||
      - name: Checkout main branch
 | 
			
		||||
        uses: actions/checkout@v3
 | 
			
		||||
        with:
 | 
			
		||||
          ref: main
 | 
			
		||||
          ref: ${{ env.MAIN_BRANCH }}
 | 
			
		||||
          path: main
 | 
			
		||||
      - name: Use Node.js ${{ matrix.node-version }}
 | 
			
		||||
        uses: actions/setup-node@v3
 | 
			
		||||
@ -33,10 +35,18 @@ jobs:
 | 
			
		||||
          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
 | 
			
		||||
        env:
 | 
			
		||||
          URL: ${{ github.event.pull_request.comments_url }}
 | 
			
		||||
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 | 
			
		||||
        run: |
 | 
			
		||||
          set -x
 | 
			
		||||
          comment () {
 | 
			
		||||
            curl -X POST $URL \
 | 
			
		||||
              -H "Content-Type: application/json" \
 | 
			
		||||
              -H "Authorization: token $GITHUB_TOKEN" \
 | 
			
		||||
              --data "{ \"body\": \"${1}\" }"
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
          sed -i 's/\/\/\s*"strictNullChecks":\s*true,/"strictNullChecks": true,/' "current/tsconfig.json"
 | 
			
		||||
          sed -i 's/\/\/\s*"strictNullChecks":\s*true,/"strictNullChecks": true,/' "main/tsconfig.json"
 | 
			
		||||
 | 
			
		||||
@ -56,8 +66,8 @@ jobs:
 | 
			
		||||
          MAIN=$(grep "Found [0-9]* errors" .out-main | sed 's/Found \(.*\) errors in .* files./\1/')
 | 
			
		||||
 | 
			
		||||
          if [ $CURRENT -gt $MAIN ]; then
 | 
			
		||||
            comment "After enabling strictNullChecks this PR would be increasing the number of null check errors from ${MAIN} to ${CURRENT}. Make sure your branch is up-to-date with ${MAIN_BRANCH} and check the diff in the console output to gather more details"
 | 
			
		||||
            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!"
 | 
			
		||||
 | 
			
		||||
@ -9,7 +9,7 @@ export function parseEnvVarNumber(envVar: string, defaultVal: number): number {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function parseEnvVarBoolean(
 | 
			
		||||
    envVar: string,
 | 
			
		||||
    envVar: string | undefined,
 | 
			
		||||
    defaultVal: boolean,
 | 
			
		||||
): boolean {
 | 
			
		||||
    if (envVar) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user