Jessica Wagantall | 675c1a7 | 2023-05-01 14:03:18 -0700 | [diff] [blame] | 1 | --- |
| 2 | name: Gerrit Verify |
| 3 | |
| 4 | # yamllint disable-line rule:truthy |
| 5 | on: |
| 6 | workflow_dispatch: |
| 7 | inputs: |
| 8 | GERRIT_BRANCH: |
| 9 | description: "Branch that change is against" |
| 10 | required: true |
| 11 | type: string |
| 12 | GERRIT_CHANGE_ID: |
| 13 | description: "The ID for the change" |
| 14 | required: true |
| 15 | type: string |
| 16 | GERRIT_CHANGE_NUMBER: |
| 17 | description: "The Gerrit number" |
| 18 | required: true |
| 19 | type: string |
| 20 | GERRIT_CHANGE_URL: |
| 21 | description: "URL to the change" |
| 22 | required: true |
| 23 | type: string |
| 24 | GERRIT_EVENT_TYPE: |
| 25 | description: "Type of Gerrit event" |
| 26 | required: true |
| 27 | type: string |
| 28 | GERRIT_PATCHSET_NUMBER: |
| 29 | description: "The patch number for the change" |
| 30 | required: true |
| 31 | type: string |
| 32 | GERRIT_PATCHSET_REVISION: |
| 33 | description: "The revision sha" |
| 34 | required: true |
| 35 | type: string |
| 36 | GERRIT_PROJECT: |
| 37 | description: "Project in Gerrit" |
| 38 | required: true |
| 39 | type: string |
| 40 | GERRIT_REFSPEC: |
| 41 | description: "Gerrit refspec of change" |
| 42 | required: true |
| 43 | type: string |
| 44 | |
| 45 | concurrency: |
| 46 | group: ${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }} |
| 47 | cancel-in-progress: true |
| 48 | |
| 49 | jobs: |
| 50 | prepare: |
| 51 | runs-on: ubuntu-latest |
| 52 | steps: |
| 53 | - name: Clear votes |
| 54 | uses: lfit/gerrit-review-action@v0.3 |
| 55 | with: |
| 56 | host: ${{ vars.GERRIT_SERVER }} |
| 57 | username: ${{ vars.GERRIT_SSH_USER }} |
| 58 | key: ${{ secrets.GERRIT_SSH_PRIVKEY }} |
| 59 | known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }} |
| 60 | gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }} |
| 61 | gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }} |
| 62 | vote-type: clear |
| 63 | - name: Allow replication |
| 64 | run: sleep 10s |
| 65 | |
Andrew Grimberg | c06ba61 | 2023-05-02 14:10:49 -0700 | [diff] [blame] | 66 | actionlint: |
Andrew Grimberg | 06fbf05 | 2023-05-02 14:35:23 -0700 | [diff] [blame] | 67 | needs: prepare |
Andrew Grimberg | c06ba61 | 2023-05-02 14:10:49 -0700 | [diff] [blame] | 68 | runs-on: ubuntu-latest |
| 69 | steps: |
| 70 | - uses: lfit/checkout-gerrit-change-action@v0.3 |
| 71 | with: |
| 72 | gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }} |
| 73 | delay: "0s" |
| 74 | - name: Download actionlint |
| 75 | id: get_actionlint |
| 76 | run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) |
| 77 | shell: bash |
| 78 | - name: Check workflow files |
| 79 | run: ${{ steps.get_actionlint.outputs.executable }} -color |
| 80 | shell: bash |
| 81 | |
Jessica Wagantall | 675c1a7 | 2023-05-01 14:03:18 -0700 | [diff] [blame] | 82 | # run pre-commit tox env separately to get use of more parallel processing |
| 83 | pre-commit: |
| 84 | needs: prepare |
| 85 | runs-on: ubuntu-latest |
| 86 | steps: |
Andrew Grimberg | c06ba61 | 2023-05-02 14:10:49 -0700 | [diff] [blame] | 87 | - uses: lfit/checkout-gerrit-change-action@v0.3 |
Jessica Wagantall | 675c1a7 | 2023-05-01 14:03:18 -0700 | [diff] [blame] | 88 | with: |
| 89 | gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }} |
| 90 | delay: "0s" |
| 91 | - uses: actions/setup-python@v4 |
| 92 | with: |
| 93 | python-version: "3.11" |
| 94 | - name: Run static analysis and format checkers |
Andrew Grimberg | ef33ef8 | 2023-05-04 10:44:26 -0700 | [diff] [blame] | 95 | run: pipx run pre-commit run --all-files --show-diff-on-failure |
Jessica Wagantall | 675c1a7 | 2023-05-01 14:03:18 -0700 | [diff] [blame] | 96 | |
Jessica Wagantall | 675c1a7 | 2023-05-01 14:03:18 -0700 | [diff] [blame] | 97 | jjb-validation: |
| 98 | needs: prepare |
| 99 | runs-on: ubuntu-latest |
| 100 | steps: |
Andrew Grimberg | c06ba61 | 2023-05-02 14:10:49 -0700 | [diff] [blame] | 101 | - uses: lfit/checkout-gerrit-change-action@v0.3 |
Jessica Wagantall | 675c1a7 | 2023-05-01 14:03:18 -0700 | [diff] [blame] | 102 | with: |
| 103 | gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }} |
| 104 | delay: "0s" |
| 105 | - uses: actions/setup-python@v4 |
| 106 | id: setup-python |
| 107 | with: |
| 108 | python-version: "3.11" |
Jessica Wagantall | 378a76f | 2023-05-02 11:22:39 -0700 | [diff] [blame] | 109 | - name: Clone git submodules |
| 110 | run: git submodule update --init |
Jessica Wagantall | 675c1a7 | 2023-05-01 14:03:18 -0700 | [diff] [blame] | 111 | - name: Run JJB Verify |
| 112 | run: | |
| 113 | python -m pip install --upgrade pip |
| 114 | pip install jenkins-job-builder |
| 115 | mkdir -p "${HOME}/.config/jenkins_jobs" |
| 116 | cat << EOF > "${HOME}/.config/jenkins_jobs/jenkins_jobs.ini" |
| 117 | [job_builder] |
| 118 | ignore_cache=True |
| 119 | keep_descriptions=False |
| 120 | include_path=. |
| 121 | recursive=True |
| 122 | query_plugins_info=False |
| 123 | config-xml=True |
| 124 | EOF |
| 125 | jenkins-jobs test -o archives/job-configs jjb/ |
| 126 | |
| 127 | vote: |
| 128 | if: ${{ always() }} |
Andrew Grimberg | c06ba61 | 2023-05-02 14:10:49 -0700 | [diff] [blame] | 129 | needs: [prepare, actionlint, pre-commit, jjb-validation] |
Jessica Wagantall | 675c1a7 | 2023-05-01 14:03:18 -0700 | [diff] [blame] | 130 | runs-on: ubuntu-latest |
| 131 | steps: |
| 132 | - uses: technote-space/workflow-conclusion-action@v3 |
| 133 | - name: Set vote |
| 134 | uses: lfit/gerrit-review-action@v0.3 |
| 135 | with: |
| 136 | host: ${{ vars.GERRIT_SERVER }} |
| 137 | username: ${{ vars.GERRIT_SSH_USER }} |
| 138 | key: ${{ secrets.GERRIT_SSH_PRIVKEY }} |
| 139 | known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }} |
| 140 | gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }} |
| 141 | gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }} |
| 142 | vote-type: ${{ env.WORKFLOW_CONCLUSION }} |