fix: Improve handling of futures and threads during refresh. #4853
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2022 Google LLC | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# https://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: Code Coverage | |
on: | |
pull_request: | |
pull_request_target: | |
types: [labeled] | |
# Declare default permissions as read only. | |
permissions: read-all | |
jobs: | |
build: | |
# run job on proper workflow event triggers (skip job for pull_request event from forks and only run pull_request_target for "tests: run" label) | |
if: "${{ (github.event.action != 'labeled' && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name) || github.event.label.name == 'tests: run' }}" | |
name: Coverage check | |
runs-on: ubuntu-latest | |
permissions: | |
issues: write | |
pull-requests: write | |
steps: | |
- name: Remove PR Label | |
if: "${{ github.event.action == 'labeled' && github.event.label.name == 'tests: run' }}" | |
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
try { | |
await github.rest.issues.removeLabel({ | |
name: 'tests: run', | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.payload.pull_request.number | |
}); | |
} catch (e) { | |
console.log('Failed to remove label. Another job may have already removed it!'); | |
} | |
- name: Setup Java | |
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3.11.0 | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
- name: Checkout base branch | |
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
with: | |
ref: ${{ github.base_ref }} | |
- name: Calculate base code coverage | |
run: | | |
mvn clean verify -P coverage | |
export CUR_COVER=$(cat core/target/site/jacoco/index.html | grep -o 'Total[^%]*' | sed 's/<.*>//; s/Total//') | |
echo "CUR_COVER=$CUR_COVER" >> $GITHUB_ENV | |
- name: Checkout PR branch | |
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
- name: Calculate PR code coverage | |
run: | | |
mvn clean verify -P coverage | |
export PR_COVER=$(cat core/target/site/jacoco/index.html | grep -o 'Total[^%]*' | sed 's/<.*>//; s/Total//') | |
echo "PR_COVER=$PR_COVER" >> $GITHUB_ENV | |
- name: Verify code coverage. If your reading this and the step has failed, please add tests to cover your changes. | |
run: | | |
echo "BASE BRANCH CODE COVERAGE is ${{ env.CUR_COVER }}%" | |
echo "PULL REQUEST CODE COVERAGE is ${{ env.PR_COVER }}%" | |
if [ "${{ env.PR_COVER }}" -lt "${{ env.CUR_COVER }}" ]; then | |
exit 1; | |
fi |