-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (131 loc) · 5.15 KB
/
behave.yml
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
name: Behave Testing
# Behave Testing will run the repository's Behave testing with each feature file
# getting its own runner. All feature files found within the specific path are
# included.
on:
workflow_call:
inputs:
tags:
type: string
required: true
description: |
The behave tags to use. E.g "full". Multiple tags should be specified
separated by a comma, e.g. "owners,redhat".
pr-body:
type: string
required: true
description: |
Every pull request created by this automation will have this pr-body.
behave-logging-level:
type: string
required: false
default: WARNING
description: |
Value passed to behave's --logging-level flag.
# actions/checkout related inputs used for testing. In some cases behave
# calls will use the PR branch instead of the main branch. E.g. went doing
# release testing
checkout-fetch-depth:
type: number
required: false
default: 1 # aligns with actions/checkout default.
description: |
fetch-depth flag to actions/checkout.
If setting to a pull request, caller is responsible
for verifying the user is a trusted user.
checkout-repository:
type: string
required: false
default: ""
description: |
repository flag to actions/checkout
If setting to a pull request, caller is responsible
for verifying the user is a trusted user.
checkout-ref:
type: string
required: false
default: ""
description: |
ref flag to actions/checkout
If setting to a pull request, caller is responsible
for verifying the user is a trusted user.
secrets:
# NOTE(komish): Not technically secret, but must be listed as a secret
# because you can't pass the ${{ secrets }} context as an input in the
# calling workflow, and our repos have this configured as a secret.
bot-name:
required: true
description: |
The name of the GitHub user that will send pull requests.
bot-token:
description: |
A GitHub token for the bot user that will initiate pull
requests for testing. Should NOT be set to GITHUB_TOKEN.
required: true
jobs:
get-features:
runs-on: ubuntu-latest
outputs:
features: ${{ steps.find-features.outputs.features }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
ref: ${{ inputs.checkout-ref }}
repository: ${{ inputs.checkout-repository }}
fetch-depth: ${{ inputs.checkout-fetch-depth }}
- name: find features
id: find-features
# TODO(JOSE) Sanity check - make sure this is more than one feature in length.
run: |
cd tests/functional/behave_features
# echo features=$(find . -name '*.feature' | sed -e 's%\./%%g' | jq -R -s -c 'split("\n") | del(.[] | select(length == 0))') | tee -a $GITHUB_OUTPUT
# NOTE(JOSE): temporarily restrict this to a small number of tests for debugging other things.
# To Revert: remove the next line, and uncomment the line previous this comment.
echo features=$(find . -name '*.feature' | sed -e 's%\./%%g' | jq -R -s -c 'split("\n") | del(.[] | select(length == 0))[:2]') | tee -a $GITHUB_OUTPUT
run-tests:
runs-on: ubuntu-latest
needs: [get-features]
strategy:
fail-fast: false
max-parallel: 4
matrix:
feature-file: ${{ fromJson(needs.get-features.outputs.features) }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
token: ${{ secrets.bot-token }}
ref: ${{ inputs.checkout-ref }}
repository: ${{ inputs.checkout-repository }}
fetch-depth: ${{ inputs.checkout-fetch-depth }}
- name: Set up Python 3
uses: ./.github/actions/setup-python
- name: Set up CI scripts
run: |
# set up python scripts
echo "set up python script in $PWD"
python3 -m venv ve1
cd scripts
../ve1/bin/pip3 install -r requirements.txt
../ve1/bin/pip3 install .
cd ..
# Pull request numbers are included in generated chart names in E2E, so it's included
# as an environment variable which E2E consumes.
- name: Populate PR_NUMBER environment variable
if: github.event_name == 'pull_request_target' || github.event_name == 'pull_request'
run: |
echo "PR_NUMBER=${{ github.event.pull_request.number }}" | tee $GITHUB_ENV
- name: Run Tests
env:
GITHUB_TOKEN: ${{ secrets.github-token }}
BOT_NAME: ${{ secrets.bot-name }}
BOT_TOKEN: ${{ secrets.bot-token }}
PR_BODY: ${{ inputs.pr-body }}
run: |
ve1/bin/behave tests/functional/behave_features/ \
--include ${{ matrix.feature-file }} \
--tags=${{ inputs.tags }} \
--logging-level=${{ inputs.behave-logging-level }} \
--no-capture \
--no-color