|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | +# |
| 18 | +--- |
| 19 | +name: Label when reviewed workflow run |
| 20 | +on: # yamllint disable-line rule:truthy |
| 21 | + workflow_run: |
| 22 | + workflows: ["Label when reviewed"] |
| 23 | + types: ['requested'] |
| 24 | +jobs: |
| 25 | + |
| 26 | + label-when-reviewed: |
| 27 | + name: "Label PRs when reviewed workflow run" |
| 28 | + runs-on: ubuntu-latest |
| 29 | + outputs: |
| 30 | + labelSet: ${{ steps.label-when-reviewed.outputs.labelSet }} |
| 31 | + steps: |
| 32 | + - name: "Get information about the original trigger of the run" |
| 33 | + uses: potiuk/get-workflow-origin@2ef0b065db6b688a2231f8a7f464df1aac254328 # v1_2 |
| 34 | + id: source-run-info |
| 35 | + with: |
| 36 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + sourceRunId: ${{ github.event.workflow_run.id }} |
| 38 | + - name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )" |
| 39 | + uses: actions/checkout@v2 |
| 40 | + - name: > |
| 41 | + Event: ${{ steps.source-run-info.outputs.sourceEvent }} |
| 42 | + Repo: ${{ steps.source-run-info.outputs.sourceHeadRepo }} |
| 43 | + Branch: ${{ steps.source-run-info.outputs.sourceHeadBranch }} |
| 44 | + Run id: ${{ github.run_id }} |
| 45 | + Source Run id: ${{ github.event.workflow_run.id }} |
| 46 | + Sha: ${{ github.sha }} |
| 47 | + Source Sha: ${{ steps.source-run-info.outputs.sourceHeadSha }} |
| 48 | + Merge commit Sha: ${{ steps.source-run-info.outputs.mergeCommitSha }} |
| 49 | + Target commit Sha: ${{ steps.source-run-info.outputs.targetCommitSha }} |
| 50 | + run: printenv |
| 51 | + - name: > |
| 52 | + Fetch incoming commit ${{ steps.source-run-info.outputs.targetCommitSha }} with its parent |
| 53 | + uses: actions/checkout@v2 |
| 54 | + with: |
| 55 | + ref: ${{ steps.source-run-info.outputs.targetCommitSha }} |
| 56 | + fetch-depth: 2 |
| 57 | + # checkout the master version again, to use the right script in master workflow |
| 58 | + - name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )" |
| 59 | + uses: actions/checkout@v2 |
| 60 | + - name: Selective checks |
| 61 | + id: selective-checks |
| 62 | + env: |
| 63 | + EVENT_NAME: ${{ steps.source-run-info.outputs.sourceEvent }} |
| 64 | + INCOMING_COMMIT_SHA: ${{ steps.source-run-info.outputs.targetCommitSha }} |
| 65 | + PR_LABELS: ${{ steps.source-run-info.outputs.pullRequestLabels }} |
| 66 | + run: | |
| 67 | + if [[ ${EVENT_NAME} == "pull_request_review" ]]; then |
| 68 | + # Run selective checks |
| 69 | + ./scripts/ci/selective_ci_checks.sh "${INCOMING_COMMIT_SHA}" |
| 70 | + else |
| 71 | + # Run all checks |
| 72 | + ./scripts/ci/selective_ci_checks.sh |
| 73 | + fi |
| 74 | + - name: "Label when approved by committers for PRs that require full tests" |
| 75 | + uses: TobKed/label-when-approved-action@7872312da76508d29f98d4fa68843ea91754cc59 # v1.2 |
| 76 | + id: label-full-test-prs-when-approved-by-commiters |
| 77 | + if: > |
| 78 | + steps.selective-checks.outputs.run-tests == 'true' && |
| 79 | + contains(steps.selective-checks.outputs.test-types, 'Core') |
| 80 | + with: |
| 81 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 82 | + label: 'full tests needed' |
| 83 | + require_committers_approval: 'true' |
| 84 | + pullRequestNumber: ${{ steps.source-run-info.outputs.pullRequestNumber }} |
| 85 | + comment: > |
| 86 | + The PR needs to run all tests because it modifies core of Airflow! Please rebase it to latest |
| 87 | + master or ask committer to re-run it! |
| 88 | + - name: "Initiate GitHub Check forcing rerun of SH ${{ github.event.pull_request.head.sha }}" |
| 89 | + uses: LouisBrunner/checks-action@9f02872da71b6f558c6a6f190f925dde5e4d8798 # v1.1.0 |
| 90 | + id: full-test-check |
| 91 | + if: steps.label-full-test-prs-when-approved-by-commiters.outputs.labelSet == 'true' |
| 92 | + with: |
| 93 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 94 | + name: "Please rebase or re-run to run full tests" |
| 95 | + status: "in_progress" |
| 96 | + sha: ${{ github.event.pull_request.head.sha }} |
| 97 | + details_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 98 | + output: > |
| 99 | + {"summary": |
| 100 | + "The PR needs to run all tests! This was determined via |
| 101 | + [the run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) |
| 102 | + "} |
| 103 | + - name: "Label when approved by committers for PRs that do not require full tests" |
| 104 | + uses: TobKed/label-when-approved-action@7872312da76508d29f98d4fa68843ea91754cc59 # v1.2 |
| 105 | + id: label-simple-test-prs-when-approved-by-commiters |
| 106 | + if: > |
| 107 | + steps.selective-checks.outputs.run-tests == 'true' && |
| 108 | + ! contains(steps.selective-checks.outputs.test-types, 'Core') |
| 109 | + with: |
| 110 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 111 | + label: 'okay to merge' |
| 112 | + require_committers_approval: 'true' |
| 113 | + pullRequestNumber: ${{ steps.source-run-info.outputs.pullRequestNumber }} |
| 114 | + comment: > |
| 115 | + The PR should be OK to be merged with just subset of tests as it does not modify Core of |
| 116 | + Airflow. The committers might merge it or can add a label 'full tests needed' and re-run it |
| 117 | + to run all tests if they see it is needed! |
| 118 | + - name: "Label when approved by committers for PRs that do not require tests at all" |
| 119 | + uses: TobKed/label-when-approved-action@7872312da76508d29f98d4fa68843ea91754cc59 # v1.2 |
| 120 | + id: label-no-test-prs-when-approved-by-commiters |
| 121 | + if: steps.selective-checks.outputs.run-tests != 'true' |
| 122 | + with: |
| 123 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 124 | + label: 'okay to merge' |
| 125 | + pullRequestNumber: ${{ steps.source-run-info.outputs.pullRequestNumber }} |
| 126 | + require_committers_approval: 'true' |
| 127 | + comment: "The PR is ready to be merged. No tests are needed!" |
0 commit comments