ci: commitlint: when range is invalid (eg force push), check last 20
This is imperfect but better than nothing, and should avoid spurious failures on force pushes to PRs.
This commit is contained in:
		
							parent
							
								
									4d04da94fb
								
							
						
					
					
						commit
						82b74ec41e
					
				
							
								
								
									
										15
									
								
								.github/workflows/linux.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								.github/workflows/linux.yml
									
									
									
									
										vendored
									
									
								
							| @ -100,14 +100,21 @@ jobs: | ||||
|     #     git log "$GITHUB_BASE_REF".. | ||||
|     #     bin/commitlint "$GITHUB_BASE_REF".. | ||||
| 
 | ||||
|     # keep synced in all workflows which do this | ||||
|     - name: Check commit messages | ||||
|       # For a PR, the range will be: master..origin/$GITHUB_HEAD_REF | ||||
|       # For a push it will be: $BEFORE.. | ||||
|       # For a force push, BEFORE is the previous HEAD, and on github (though not locally) this is an "invalid revision range". | ||||
|       # In this and any case where the range is invalid, we'll just check the last N commits. | ||||
|       # related: https://stackoverflow.com/questions/64708371/how-to-run-github-workflow-on-every-commit-of-a-push | ||||
|       env: | ||||
|         BEFORE: ${{ github.event.before }} | ||||
|       # for a PR this will be: origin/master..origin/$GITHUB_HEAD_REF | ||||
|       # for a push it will be: $BEFORE.. | ||||
|       # for a force push, BEFORE is the previous HEAD, and on github (not locally) this is an "invalid revision range" | ||||
|         NUM:    20 | ||||
|       run: | | ||||
|         bin/commitlint ${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF} | ||||
|         RANGE=${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF} | ||||
|         git rev-list --quiet $RANGE \ | ||||
|           && bin/commitlint  $RANGE \ | ||||
|           || ( echo "could not identify commits, checking last $NUM instead:"; bin/commitlint -$NUM ) | ||||
| 
 | ||||
|     # things to be cached/restored: | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										15
									
								
								.github/workflows/mac.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								.github/workflows/mac.yml
									
									
									
									
										vendored
									
									
								
							| @ -57,14 +57,21 @@ jobs: | ||||
|       with:  | ||||
|         fetch-depth: 0         | ||||
| 
 | ||||
|     # keep synced in all workflows which do this | ||||
|     - name: Check commit messages | ||||
|       # For a PR, the range will be: master..origin/$GITHUB_HEAD_REF | ||||
|       # For a push it will be: $BEFORE.. | ||||
|       # For a force push, BEFORE is the previous HEAD, and on github (though not locally) this is an "invalid revision range". | ||||
|       # In this and any case where the range is invalid, we'll just check the last N commits. | ||||
|       # related: https://stackoverflow.com/questions/64708371/how-to-run-github-workflow-on-every-commit-of-a-push | ||||
|       env: | ||||
|         BEFORE: ${{ github.event.before }} | ||||
|       # for a PR this will be: origin/master..origin/$GITHUB_HEAD_REF | ||||
|       # for a push it will be: $BEFORE.. | ||||
|       # for a force push, BEFORE is the previous HEAD, and on github (not locally) this is an "invalid revision range" | ||||
|         NUM:    20 | ||||
|       run: | | ||||
|         bin/commitlint ${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF} | ||||
|         RANGE=${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF} | ||||
|         git rev-list --quiet $RANGE \ | ||||
|           && bin/commitlint  $RANGE \ | ||||
|           || ( echo "could not identify commits, checking last $NUM instead:"; bin/commitlint -$NUM ) | ||||
| 
 | ||||
|     # things to be cached/restored: | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										15
									
								
								.github/workflows/push.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								.github/workflows/push.yml
									
									
									
									
										vendored
									
									
								
							| @ -64,14 +64,21 @@ jobs: | ||||
|     #     git log "$GITHUB_BASE_REF".. | ||||
|     #     bin/commitlint "$GITHUB_BASE_REF".. | ||||
| 
 | ||||
|     # keep synced in all workflows which do this | ||||
|     - name: Check commit messages | ||||
|       # For a PR, the range will be: master..origin/$GITHUB_HEAD_REF | ||||
|       # For a push it will be: $BEFORE.. | ||||
|       # For a force push, BEFORE is the previous HEAD, and on github (though not locally) this is an "invalid revision range". | ||||
|       # In this and any case where the range is invalid, we'll just check the last N commits. | ||||
|       # related: https://stackoverflow.com/questions/64708371/how-to-run-github-workflow-on-every-commit-of-a-push | ||||
|       env: | ||||
|         BEFORE: ${{ github.event.before }} | ||||
|       # for a PR this will be: master..origin/$GITHUB_HEAD_REF | ||||
|       # for a push it will be: $BEFORE.. | ||||
|       # for a force push, BEFORE is the previous HEAD, and on github (not locally) this is an "invalid revision range" | ||||
|         NUM:    20 | ||||
|       run: | | ||||
|         bin/commitlint ${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF} | ||||
|         RANGE=${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF} | ||||
|         git rev-list --quiet $RANGE \ | ||||
|           && bin/commitlint  $RANGE \ | ||||
|           || ( echo "could not identify commits, checking last $NUM instead:"; bin/commitlint -$NUM ) | ||||
| 
 | ||||
|     # things to be cached/restored: | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										15
									
								
								.github/workflows/windows.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								.github/workflows/windows.yml
									
									
									
									
										vendored
									
									
								
							| @ -47,14 +47,21 @@ jobs: | ||||
|       with:  | ||||
|         fetch-depth: 0         | ||||
| 
 | ||||
|     # keep synced in all workflows which do this | ||||
|     - name: Check commit messages | ||||
|       # For a PR, the range will be: master..origin/$GITHUB_HEAD_REF | ||||
|       # For a push it will be: $BEFORE.. | ||||
|       # For a force push, BEFORE is the previous HEAD, and on github (though not locally) this is an "invalid revision range". | ||||
|       # In this and any case where the range is invalid, we'll just check the last N commits. | ||||
|       # related: https://stackoverflow.com/questions/64708371/how-to-run-github-workflow-on-every-commit-of-a-push | ||||
|       env: | ||||
|         BEFORE: ${{ github.event.before }} | ||||
|       # for a PR this will be: origin/master..origin/$GITHUB_HEAD_REF | ||||
|       # for a push it will be: $BEFORE.. | ||||
|       # for a force push, BEFORE is the previous HEAD, and on github (not locally) this is an "invalid revision range" | ||||
|         NUM:    20 | ||||
|       run: | | ||||
|         bin/commitlint ${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF} | ||||
|         RANGE=${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF} | ||||
|         git rev-list --quiet $RANGE \ | ||||
|           && bin/commitlint  $RANGE \ | ||||
|           || ( echo "could not identify commits, checking last $NUM instead:"; bin/commitlint -$NUM ) | ||||
| 
 | ||||
|     # things to be cached/restored: | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user