-
Notifications
You must be signed in to change notification settings - Fork 9
150 lines (144 loc) · 4.9 KB
/
gerrit-compose-required-tox-verify.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
---
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2023 The Linux Foundation
name: Compose Tox Verify
# yamllint disable-line rule:truthy
on:
workflow_call:
inputs:
# gerrit-to-platform required
GERRIT_BRANCH:
description: "Branch that change is against"
required: true
type: string
GERRIT_CHANGE_ID:
description: "The ID for the change"
required: true
type: string
GERRIT_CHANGE_NUMBER:
description: "The Gerrit number"
required: true
type: string
GERRIT_CHANGE_URL:
description: "URL to the change"
required: true
type: string
GERRIT_EVENT_TYPE:
description: "Type of Gerrit event"
required: true
type: string
GERRIT_PATCHSET_NUMBER:
description: "The patch number for the change"
required: true
type: string
GERRIT_PATCHSET_REVISION:
description: "The revision sha"
required: true
type: string
GERRIT_PROJECT:
description: "Project in Gerrit"
required: true
type: string
GERRIT_REFSPEC:
description: "Gerrit refspec of change"
required: true
type: string
# Inputs passed to tox-run-action.
# These should be defined by the calling workflow ("with:"), not listed
# as inputs.
TARGET_REPO:
# yamllint disable-line rule:line-length
description: "The target GitHub repository needing the required workflow"
required: false
default: ${{ github.repository }}
type: string
TOX_DIR:
description: "Directory containing tox.ini file"
required: false
default: "."
type: string
TOX_ENVS:
description: >
List of envs to run. These MUST be passed as a string representing
a list of strings, e.g.:
'["lint", "build"]'
required: true
type: string
PYTHON_VERSION:
description: "Version of python to use"
required: false
default: "3.12"
type: string
PARALLEL:
description: "Whether to run jobs in parallel"
required: false
type: string
PRE_BUILD_SCRIPT:
description: "Pre-build script to trigger before verify run"
required: false
default: ""
type: string
PRE_BUILD_SCRIPT_PATH:
description: "Path to pre-build script to trigger before verify run"
required: false
default: ""
type: string
PRE_BUILD_SCRIPT_URL:
description: "URL of pre-build script to trigger before verify run"
required: false
default: ""
type: string
concurrency:
# yamllint disable-line rule:line-length
group: compose-tox-verify-${{ github.workflow }}-${{ github.event.inputs.GERRIT_BRANCH}}-${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }}
cancel-in-progress: true
jobs:
run-tox:
runs-on: ubuntu-latest
strategy:
matrix:
tox-env: ${{ fromJSON(inputs.TOX_ENVS) }}
env:
PRE_BUILD: "/dev/null"
steps:
- name: Gerrit checkout
# yamllint disable-line rule:line-length
uses: lfit/checkout-gerrit-change-action@54d751e8bd167bc91f7d665dabe33fae87aaaa63 # v0.9
with:
gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
gerrit-project: ${{ inputs.GERRIT_PROJECT }}
gerrit-url: ${{ vars.GERRIT_URL }}
delay: "0s"
repository: ${{ inputs.TARGET_REPO }}
ref: refs/heads/${{ inputs.GERRIT_BRANCH }}
- name: Actions checkout # Needed for local action reference
uses: actions/checkout@v4
with:
repository: lfit/releng-reusable-workflows
sparse-checkout: .github/actions/tox-run-action
path: reusable-tox-run-action
- name: Pre-build path
if: ${{ inputs.PRE_BUILD_SCRIPT_PATH != '' }}
# yamllint disable-line rule:line-length
run: |
echo "PRE_BUILD=${{ inputs.PRE_BUILD_SCRIPT_PATH }}" >> "$GITHUB_ENV"
- name: Pre-build script
if: ${{ inputs.PRE_BUILD_SCRIPT != '' }}
run: |
echo "${{ inputs.PRE_BUILD_SCRIPT }}" > "${{ github.run_id }}.sh"
chmod +x "${{ github.run_id }}.sh"
echo "PRE_BUILD=${{ github.run_id }}.sh" >> "$GITHUB_ENV"
- name: Pre-build URL
if: ${{ inputs.PRE_BUILD_SCRIPT_URL != '' }}
run: |
curl "${{ inputs.PRE_BUILD_SCRIPT_URL }}" > "${{ github.run_id }}.sh"
chmod +x "${{ github.run_id }}.sh"
echo "PRE_BUILD=${{ github.run_id }}.sh" >> "$GITHUB_ENV"
- name: Run tox
uses: ./reusable-tox-run-action/.github/actions/tox-run-action
with:
tox-dir: ${{ inputs.TOX_DIR }}
py-version: ${{ inputs.PYTHON_VERSION }}
tox-envs: ${{ matrix.tox-env }}
parallel: ${{ inputs.PARALLEL }}
pre-build-script: "$PRE_BUILD"