67e597ad064b07aa8eeeddfa50503801f4b05873
[com/pylog.git] / .github / workflows / gerrit-novote-merge.yaml
1 ---
2 name: Gerrit Merge
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     secrets:
45       SONAR_TOKEN:
46         description: "Sonar Cloud access token"
47         required: true
48
49 concurrency:
50   # yamllint disable-line rule:line-length
51   group: gerrit-merge-${{ github.workflow }}-${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }}
52   cancel-in-progress: true
53
54 env:
55   TOX_ENVS: '["docs","docs-linkcheck"]'
56
57 jobs:
58   notify:
59     runs-on: ubuntu-latest
60     steps:
61       - name: Notify job start
62         # yamllint disable-line rule:line-length
63         uses: lfit/gerrit-review-action@7c30179c3c9389545fccb0d458df59879372ae6a  # v0.6
64         with:
65           host: ${{ vars.GERRIT_SERVER }}
66           username: ${{ vars.GERRIT_SSH_USER }}
67           key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
68           known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
69           gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
70           gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
71           vote-type: clear
72           comment-only: true
73       - name: Allow replication
74         run: sleep 10s
75
76   call-gerrit-tox-and-sonarcloud:
77     runs-on: ubuntu-latest
78     needs: notify
79     strategy:
80       matrix:
81         tox-env: ${{ fromJSON(env.TOX_ENVS) }}
82     steps:
83       - uses: actions/checkout@v4
84         with:
85           ref: ${{ inputs.GERRIT_BRANCH }}
86           submodules: "true"
87       - name: Run Tox verify
88         # yamllint disable-line rule:line-length
89         uses: lfit/releng-reusable-workflows/.github/actions/tox-run-action@main
90         with:
91           tox-envs: ${{ matrix.tox-env }}
92       - name: Run SonarCloud Scan
93         uses: sonarsource/sonarcloud-github-action@master
94         env:
95           SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
96         with:
97           args:
98           SONAR_ARGS: >
99             -Dsonar.build.sourceEncoding=UTF-8
100             -Dsonar.organization=o-ran-sc
101             -Dsonar.projectBaseDir=.
102             -Dsonar.projectKey=o-ran-sc_com-pylog
103             -Dsonar.projectName=com-pylog
104             -Dsonar.python.coverage.reportPaths=./coverage.xm
105             -Dsonar.sources=mdclogpy
106             -Dsonar.verbose=true
107
108   report-status:
109     if: ${{ always() }}
110     needs: [notify, call-gerrit-tox-and-sonarcloud]
111     runs-on: ubuntu-latest
112     steps:
113       - name: Get workflow conclusion
114         uses: technote-space/workflow-conclusion-action@v3
115       - name: Report workflow conclusion
116         # yamllint disable-line rule:line-length
117         uses: lfit/gerrit-review-action@7c30179c3c9389545fccb0d458df59879372ae6a  # v0.6
118         with:
119           host: ${{ vars.GERRIT_SERVER }}
120           username: ${{ vars.GERRIT_SSH_USER }}
121           key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
122           known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
123           gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
124           gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
125           vote-type: ${{ env.WORKFLOW_CONCLUSION }}
126           comment-only: true