-
-
Notifications
You must be signed in to change notification settings - Fork 23
244 lines (232 loc) · 8.32 KB
/
Package.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
---
name: Package
# on: workflow_call
on:
workflow_call:
outputs:
isrelease:
value: ${{ jobs.Package_For_PIP.outputs.isrelease }}
ismilestone:
value: ${{ jobs.Package_For_PIP.outputs.ismilestone }}
numver:
value: ${{ jobs.Package_For_PIP.outputs.numver }}
version:
value: ${{ jobs.Package_For_PIP.outputs.version }}
runagent:
value: ${{ jobs.Package_For_PIP.outputs.runagent }}
runmanager:
value: ${{ jobs.Package_For_PIP.outputs.runmanager }}
runreporter:
value: ${{ jobs.Package_For_PIP.outputs.runreporter }}
jobs:
Package_For_PIP:
runs-on: ubuntu-latest
outputs:
isrelease: ${{ env.isrelease }}
ismilestone: ${{ env.ismilestone }}
numver: ${{ env.numver }}
version: ${{ env.version }}
runagent: ${{ steps.run_agent.outputs.files }}
runmanager: ${{ steps.run_manager.outputs.files }}
runreporter: ${{ steps.run_reporter.outputs.files }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Apt Update
run: |
sudo apt update -y
- name: PIP Install
run: pip install --upgrade build setuptools twine wheel
- name: Get Branch Name
run: |
branchname=$(git rev-parse --abbrev-ref HEAD)
echo "branchname=$branchname" >> "$GITHUB_ENV"
- name: Get Current Release Tag
run: |
currrelease=$(git describe --abbrev=0 --tags)
echo "currrelease=$currrelease" >> "$GITHUB_ENV"
- name: Determine if this is a release branch
run: |
isrelease=0
if [[ $branchname =~ v[0-9]\. ]]; then
isrelease=1
fi
echo "isrelease=$isrelease" >> "$GITHUB_ENV"
- name: Determine if this is master branch
run: |
ismaster=0
if [[ $branchname == master ]]; then
ismaster=1
fi
echo "ismaster=$ismaster" >> "$GITHUB_ENV"
echo "base=" >> "$GITHUB_ENV"
- name: Check Branch for Issue Number with Milestone
# if: ${{ env.isrelease == 1 }}
shell: python
# https://api.github.com/repos/damies13/rfswarm/milestones
# \\d escaped for surper-linter@v6
run: |
import os
import re
import requests
branchname = os.getenv("branchname")
milestonever="master"
ismilestone=0
print('branchname :', branchname)
m = re.search("#(\\d*)", branchname)
if m is not None:
issueno = m[1]
print('issueno :', issueno)
issueresp = requests.get("https://api.github.com/repos/damies13/rfswarm/issues/{}".format(issueno))
issuedata = issueresp.json()
# print('issuedata', issuedata)
if 'milestone' in issuedata:
milestone = issuedata['milestone']
if 'title' in milestone:
milestonever = milestone['title']
print('milestonever :', milestonever)
ismilestone=1
env_file = os.getenv('GITHUB_ENV')
with open(env_file, "a") as myfile:
myfile.write("milestone={}\n".format(milestonever))
myfile.write("ismilestone={}\n".format(ismilestone))
myfile.write("base={}\n".format(milestonever))
- name: Get Date String
if: ${{ env.isrelease == 0 && env.ismaster == 0 }}
run: |
datestr=$(date +%Y%m%d%H%M%S)
echo "datestr=$datestr" >> "$GITHUB_ENV"
- name: Set Version Number to Branch Name
if: ${{ env.isrelease == 1 }}
run: |
numver=$(echo "$branchname" | sed -E 's/v([^-]*)/\1/')
echo "numver=$numver" >> "$GITHUB_ENV"
version=v$numver
echo "version=$version" >> "$GITHUB_ENV"
- name: Set Version Number to Milestone Name
if: ${{ env.ismilestone == 1 }}
run: |
numver=$(echo "$milestone" | sed -E 's/v([^-]*)/\1/')
numver=$numver.dev$datestr
echo "numver=$numver" >> "$GITHUB_ENV"
version=v$numver
echo "version=$version" >> "$GITHUB_ENV"
- name: Set New Version Number
if: ${{ env.isrelease == 0 && env.ismilestone == 0 }}
run: |
numver=$(echo "$currrelease" | sed -E 's/v([^-]*)/\1/')
mapfile -d . -t numverparts < <(echo "$numver")
len=${#numverparts[@]}
if [ "$len" -gt "2" ]; then
numver=${numverparts[0]}.${numverparts[1]}.$(( numverparts[2] + 1))
elif [ "$len" -eq "2" ]; then
numver=${numverparts[0]}.${numverparts[1]}.1
else
numver=${numverparts[0]}.0.1
fi
numver=$numver.dev$datestr
echo "numver=$numver" >> "$GITHUB_ENV"
version=v$numver
echo "version=$version" >> "$GITHUB_ENV"
- name: "Echo Vars 2"
run: |
echo numver: ${{ env.numver }}
echo version: ${{ env.version }}
- name: Update Version Number in python files
run: |
pwd
ls -la
# echo "get files"
files=$(find . -name 'rfswarm*.py')
for file in $files
do
# echo "version variable : $file"
sed -i -e "s/version = \"[^\"]*\"^/version = \"${numver}\"/" "$file"
sed -i -e "s/version=\"[^\"]*\"^/version = \"${numver}\"/" "$file"
# echo "version comment : $file"
sed -i -e "s/# Version .*/# Version ${numver}/" "$file"
done
files=$(find . -name 'setup-*.py')
for file in $files
do
# echo "version variable : $file"
sed -i -e "s/version = \"[^\"]*\"/version=\"${numver}\"/" "$file"
sed -i -e "s/version=\"[^\"]*\"/version=\"${numver}\"/" "$file"
# echo "version comment : $file"
# sed -i -e "s/# Version .*/# Version ${numver}/" "$file"
done
# echo "--------------- head rfswarm_agent.py ---------------"
# head -50 rfswarm_agent/rfswarm_agent.py
echo "--------------- head setup-manager.py ---------------"
head -10 setup-manager.py
echo "--------------- end head setup-manager.py ---------------"
- name: Clear Dist
run: |
rm -fR dist/
- name: Clear Build for Manager
run: |
rm -fR build/
- name: Build Manager
run: |
python3 setup-manager.py sdist bdist_wheel
- name: Clear Build for Agent
run: |
rm -fR build/
- name: Build Agent
run: |
python3 setup-agent.py sdist bdist_wheel
- name: Clear Build for Reporter
run: |
rm -fR build/
- name: Build Reporter
run: |
python3 setup-reporter.py sdist bdist_wheel
- name: Show Dist
run: |
ls -la dist
- name: Archive pip packages in dist
uses: actions/upload-artifact@v4
# https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts#passing-data-between-jobs-in-a-workflow
with:
name: dist
path: dist
retention-days: 5
- name: Check Run Agent Tests
id: run_agent
uses: dorny/paths-filter@v3
with:
base: '${{ env.base }}'
filters: |
files:
- 'rfswarm_agent/**'
- 'Tests/Regression/Agent/**'
- '.github/workflows/Regression_Tests_Agent.yaml'
- 'setup-agent.py'
- name: Check Run Manager Tests
id: run_manager
uses: dorny/paths-filter@v3
with:
base: '${{ env.base }}'
filters: |
files:
- 'rfswarm_manager/**'
- 'Tests/Regression/Manager/**'
- '.github/workflows/Regression_Tests_Manager.yaml'
- 'setup-manager.py'
- name: Check Run Reporter Tests
id: run_reporter
uses: dorny/paths-filter@v3
with:
base: '${{ env.base }}'
filters: |
files:
- 'rfswarm_reporter/**'
- 'Tests/Regression/Reporter/**'
- '.github/workflows/Regression_Tests_Reporter.yaml'
- 'setup-reporter.py'
#