Skip to content

Commit 0088c21

Browse files
Ryan FairclothAddon Factory template
Ryan Faircloth
and
Addon Factory template
authored
test: common template rollout changes (#97)
Co-authored-by: Addon Factory template <[email protected]>
1 parent 0880bb5 commit 0088c21

28 files changed

+2399
-271
lines changed

.circleci/config.yml

+113-56
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## SPDX-License-Identifier: LicenseRef-Splunk-1-2020
44
##
55
##
6-
6+
# jscpd:ignore-start
77
version: 2.1
88
orbs:
99
go: circleci/[email protected]
@@ -12,26 +12,44 @@ orbs:
1212
package:
1313
docker:
1414
- image: circleci/buildpack-deps:stable
15-
resource_class: large
15+
resource_class: small
1616
steps:
1717
- checkout
1818
- run:
1919
name: Setup Environment
2020
command: |
2121
sudo apt-get update
2222
sudo apt-get install -y python2 python-pip python-virtualenv python3 python3.7 python3-pip python3-virtualenv
23+
sudo pip3 install poetry
2324
python3.7 -m virtualenv ~/.venv -p python3
2425
source ~/.venv/bin/activate
2526
pip install pip --upgrade
27+
if [ -f "poetry.lock" ]
28+
then
29+
mkdir -p package/lib || true
30+
poetry export --without-hashes -o package/lib/requirements.txt
31+
poetry export --without-hashes --dev -o requirements_dev.txt
32+
fi
2633
pip install -r requirements_dev.txt --use-deprecated=legacy-resolver || true
2734
pip install semantic_version==2.6.0
2835
sudo apt install npm
36+
if [ -f "yarn.lock" ]
37+
then
38+
sudo npm install --global yarn
39+
yarn
40+
fi
41+
2942
- run:
3043
name: Generate Addon
3144
command: |
3245
touch nextRelease.txt
33-
npx -p @semantic-release/exec -p semantic-release semantic-release --dry-run --plugins "@semantic-release/commit-analyzer,@semantic-release/exec" --analyzeCommits @semantic-release/commit-analyzer --verifyRelease @semantic-release/exec --verifyReleaseCmd 'echo ${nextRelease.version} > nextRelease.txt'
34-
sed -i "s/-develop./develop/g" nextRelease.txt
46+
npx -p @semantic-release/exec -p [email protected] -p semantic-release/git -p semantic-release/github \
47+
semantic-release --dry-run \
48+
--plugins "@semantic-release/commit-analyzer,@semantic-release/exec,@semantic-release/git,@semantic-release/github" \
49+
--analyzeCommits @semantic-release/commit-analyzer \
50+
--verifyRelease @semantic-release/exec \
51+
--verifyReleaseCmd 'echo ${nextRelease.version} > nextRelease.txt'
52+
sed -i "s/-beta./b/g" nextRelease.txt
3553
VERSION=$(cat nextRelease.txt)
3654
echo VERSION="$VERSION"
3755
echo CIRCLE_TAG=$CIRCLE_TAG
@@ -43,13 +61,16 @@ orbs:
4361
CIRCLE_TAG=${CIRCLE_TAG:1}
4462
echo CIRCLE_TAG=$CIRCLE_TAG
4563
ucc-gen --ta-version="$CIRCLE_TAG"
46-
fi
64+
fi
65+
if [ -f "yarn.lock" ]
66+
then
67+
yarn run build
68+
fi
4769
- run:
4870
name: Generating package
4971
command: |
5072
PACKAGE_ID=$(ls output/)
5173
BUILD_DIR=output/$PACKAGE_ID
52-
rm -rf $BUILD_DIR/lib/aiohttp/.hash || true
5374
find $BUILD_DIR/lib -executable -type f -exec chmod -x {} \; 2>/dev/null || true
5475
source ~/.venv/bin/activate
5576
slim generate-manifest $BUILD_DIR --update >/tmp/app.manifest || true
@@ -136,6 +157,8 @@ jobs:
136157
default: test
137158
docker:
138159
- image: circleci/python:3.7
160+
resource_class: small
161+
139162
steps:
140163
- checkout
141164
- attach_workspace:
@@ -145,7 +168,7 @@ jobs:
145168
command: |
146169
python -m venv ~/.venv
147170
source ~/.venv/bin/activate
148-
pip install https://download.splunk.com/misc/appinspect/splunk-appinspect-latest.tar.gz
171+
pip install splunk-appinspect
149172
- run:
150173
name: inspect
151174
command: |
@@ -164,43 +187,43 @@ jobs:
164187
cat test-results/$CIRCLE_PROJECT_REPONAME-appinspect-mode-<<parameters.label>>.xml | sed 's/<skipped\/>//g' | sed 's/skipped[^ ]*/skipped=\"0\"/g' >/tmp/$CIRCLE_PROJECT_REPONAME-appinspect-mode-<<parameters.label>>.xml
165188
zip -j /tmp/$CIRCLE_PROJECT_REPONAME-appinspect-mode-<<parameters.label>>.zip /tmp/$CIRCLE_PROJECT_REPONAME-appinspect-mode-<<parameters.label>>.xml
166189
167-
LUUID=$(curl -X POST "$RP_ENDPOINT/api/v1/addonfactory/launch/import" -H "accept: */*" -H "Content-Type: multipart/form-data" -H "Authorization: bearer $RP_UUID" -F "file=@/tmp/$CIRCLE_PROJECT_REPONAME-appinspect-mode-<<parameters.label>>.zip;type=application/zip" 2>/dev/null | sed 's/\(.*id = \)\([^ ]*\)\(.*\)/\2/')
168-
echo LUUID=$LUUID
169-
LID=$(curl -X GET "$RP_ENDPOINT/api/v1/addonfactory/launch/uuid/$LUUID" -H "accept: */*" -H "Authorization: bearer $RP_UUID" 2>/dev/null| jq .id)
170-
echo LID=$LID
171-
APPINSPECTVER=$(splunk-appinspect list version | sed 's/\(.*Version \)\(.*\)/\2/')
172-
UPDATE="
173-
{ \"attributes\":
174-
[
175-
{ \"key\": \"job\",
176-
\"value\": \"${CIRCLE_JOB}\"
177-
},
178-
{ \"key\": \"appinspect\",
179-
\"value\": \"$APPINSPECTVER\"
180-
},
181-
{ \"key\": \"branch\",
182-
\"value\": \"<< pipeline.git.branch >>\"
183-
},
184-
{ \"key\": \"commit\",
185-
\"value\": \"${CIRCLE_SHA1}\"
186-
},
187-
{ \"key\": \"release\",
188-
\"value\": \"${RELEASE}\"
189-
},
190-
{ \"key\": \"version\",
191-
\"value\": \"$(./semtag getcurrent)\"
192-
},
193-
{ \"key\": \"repo\",
194-
\"value\": \"$CIRCLE_PROJECT_REPONAME\"
195-
}
196-
]
197-
}"
198-
echo $UPDATE | jq
199-
curl -X PUT "$RP_ENDPOINT/api/v1/addonfactory/launch/$LID/update" \
200-
-H "accept: */*" \
201-
-H "Content-Type: application/json" \
202-
-H "Authorization: bearer $RP_UUID" \
203-
-d "$UPDATE"
190+
# LUUID=$(curl -X POST "$RP_ENDPOINT/api/v1/addonfactory/launch/import" -H "accept: */*" -H "Content-Type: multipart/form-data" -H "Authorization: bearer $RP_UUID" -F "file=@/tmp/$CIRCLE_PROJECT_REPONAME-appinspect-mode-<<parameters.label>>.zip;type=application/zip" 2>/dev/null | sed 's/\(.*id = \)\([^ ]*\)\(.*\)/\2/')
191+
# echo LUUID=$LUUID
192+
# LID=$(curl -X GET "$RP_ENDPOINT/api/v1/addonfactory/launch/uuid/$LUUID" -H "accept: */*" -H "Authorization: bearer $RP_UUID" 2>/dev/null| jq .id)
193+
# echo LID=$LID
194+
# APPINSPECTVER=$(splunk-appinspect list version | sed 's/\(.*Version \)\(.*\)/\2/')
195+
# UPDATE="
196+
# { \"attributes\":
197+
# [
198+
# { \"key\": \"job\",
199+
# \"value\": \"${CIRCLE_JOB}\"
200+
# },
201+
# { \"key\": \"appinspect\",
202+
# \"value\": \"$APPINSPECTVER\"
203+
# },
204+
# { \"key\": \"branch\",
205+
# \"value\": \"<< pipeline.git.branch >>\"
206+
# },
207+
# { \"key\": \"commit\",
208+
# \"value\": \"${CIRCLE_SHA1}\"
209+
# },
210+
# { \"key\": \"release\",
211+
# \"value\": \"${RELEASE}\"
212+
# },
213+
# { \"key\": \"version\",
214+
# \"value\": \"$(./semtag getcurrent)\"
215+
# },
216+
# { \"key\": \"repo\",
217+
# \"value\": \"$CIRCLE_PROJECT_REPONAME\"
218+
# }
219+
# ]
220+
# }"
221+
# echo $UPDATE | jq
222+
# curl -X PUT "$RP_ENDPOINT/api/v1/addonfactory/launch/$LID/update" \
223+
# -H "accept: */*" \
224+
# -H "Content-Type: application/json" \
225+
# -H "Authorization: bearer $RP_UUID" \
226+
# -d "$UPDATE"
204227
- run:
205228
name: set result
206229
command: |
@@ -224,9 +247,13 @@ jobs:
224247
description: sc4s version
225248
type: string
226249
default: latest
250+
resource_class:
251+
description: Docker CicreCi machine size
252+
type: string
253+
default: large
227254
docker:
228255
- image: circleci/python:3.7
229-
resource_class: xlarge
256+
resource_class: <<parameters.resource_class>>
230257
steps:
231258
- checkout
232259
- run: git submodule sync
@@ -249,6 +276,16 @@ jobs:
249276
ls
250277
rm *.tar.gz
251278
ls
279+
- run:
280+
name: generate requirements
281+
command: |
282+
if [ -f "poetry.lock" ]
283+
then
284+
mkdir -p package/lib || true
285+
pip install poetry
286+
poetry export --without-hashes -o package/lib/requirements.txt
287+
poetry export --without-hashes --dev -o requirements_dev.txt
288+
fi
252289
- run:
253290
name: Splunk Testing
254291
no_output_timeout: 2h
@@ -289,6 +326,11 @@ jobs:
289326
# Saucelab connection
290327
[ -z $BROWSER ] || [ "$UI_TEST_HEADLESS" = "true" ] || docker-compose -f docker-compose-ci.yml up -d sauceconnect
291328
329+
# Start selenium grid if needed.
330+
if [[ "<<parameters.test_set>>" == *"firefox_grid"* ]]; then docker-compose -f docker-compose-ci.yml up -d firefox-grid; fi
331+
if [[ "<<parameters.test_set>>" == *"chrome_grid"* ]]; then docker-compose -f docker-compose-ci.yml up -d chrome-grid; fi
332+
333+
292334
# Start Splunk
293335
docker-compose -f docker-compose-ci.yml up -d splunk
294336
until docker-compose -f docker-compose-ci.yml logs splunk | grep "Ansible playbook complete" ; do sleep 1; done
@@ -339,7 +381,7 @@ jobs:
339381
default: py3-3.7.8
340382
docker:
341383
- image: circleci/python:3.7
342-
resource_class: xlarge
384+
resource_class: small
343385
steps:
344386
- checkout
345387
- run: git submodule sync
@@ -362,6 +404,16 @@ jobs:
362404
ls
363405
rm *.tar.gz
364406
ls
407+
- run:
408+
name: generate requirements
409+
command: |
410+
if [ -f "poetry.lock" ]
411+
then
412+
mkdir -p package/lib || true
413+
pip install poetry
414+
poetry export --without-hashes -o package/lib/requirements.txt
415+
poetry export --without-hashes --dev -o requirements_dev.txt
416+
fi
365417
- run:
366418
name: Splunk Testing
367419
no_output_timeout: 2h
@@ -406,11 +458,12 @@ jobs:
406458

407459
semgrep:
408460
environment:
409-
SEMGREP_REPO_URL: << pipeline.project.git_url >>
410-
SEMGREP_BRANCH: << pipeline.git.branch >>
461+
SEMGREP_REPO_URL: << pipeline.project.git_url >>
462+
SEMGREP_BRANCH: << pipeline.git.branch >>
411463
docker:
412464
- image: returntocorp/semgrep-agent:v1
413465
user: root
466+
resource_class: medium
414467
steps:
415468
- checkout
416469
- run:
@@ -444,7 +497,7 @@ jobs:
444497

445498
release:
446499
docker:
447-
- image: circleci/node:14
500+
- image: circleci/node:12
448501
steps:
449502
- setup_remote_docker:
450503
docker_layer_caching: true
@@ -454,8 +507,8 @@ jobs:
454507
- run:
455508
name: "Apply Release Tag"
456509
command: |
457-
npx semantic-release
458-
510+
npx -p @semantic-release/exec -p [email protected] -p semantic-release/git -p semantic-release/github \
511+
semantic-release
459512
publish-gh:
460513
docker:
461514
- image: circleci/python:3.7
@@ -474,7 +527,6 @@ jobs:
474527
$HOME/go/bin/ghr -t ${GH_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -replace "<< pipeline.git.tag >>" /tmp/workspace/build/package/splunkbase
475528
$HOME/go/bin/ghr -t ${GH_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -replace "<< pipeline.git.tag >>" /tmp/workspace/build/package/deployment
476529
477-
478530
publish-sbase:
479531
docker:
480532
- image: circleci/python:3.7
@@ -500,6 +552,7 @@ jobs:
500552
reuse:
501553
docker:
502554
- image: circleci/python:3.7
555+
resource_class: small
503556
steps:
504557
- setup_remote_docker:
505558
docker_layer_caching: true
@@ -555,9 +608,10 @@ workflows:
555608
matrix:
556609
alias: splunk-app-test-knowledge
557610
parameters:
558-
splunk_version: ["8.1","8.2"]
611+
splunk_version: ["8.0", "8.2"]
559612
sc4s_version: ["1"]
560613
test_set: ["knowledge"]
614+
resource_class: ["medium"]
561615
filters:
562616
branches:
563617
only: /.*/
@@ -570,9 +624,10 @@ workflows:
570624
matrix:
571625
alias: splunk-app-test-ui
572626
parameters:
573-
splunk_version: ["8.1","8.2"]
627+
splunk_version: ["8.0", "8.2"]
574628
sc4s_version: ["1"]
575629
test_set: ["ui-chrome"]
630+
resource_class: ["medium"]
576631
filters:
577632
branches:
578633
only: /.*/
@@ -584,9 +639,10 @@ workflows:
584639
matrix:
585640
alias: splunk-app-test-modinput
586641
parameters:
587-
splunk_version: ["8.1","8.2"]
642+
splunk_version: ["8.0", "8.2"]
588643
sc4s_version: ["1"]
589644
test_set: ["modinput_functional", "modinput_others"]
645+
resource_class: ["large"]
590646
filters:
591647
branches:
592648
only: /.*/
@@ -601,7 +657,7 @@ workflows:
601657
test_set: ["py3-3.7.4", "py3-3.7.8"]
602658
filters:
603659
branches:
604-
only: /.*/
660+
only: /.*/
605661
- approval-release:
606662
requires:
607663
- package
@@ -652,3 +708,4 @@ workflows:
652708
ignore: /.*/
653709
tags:
654710
only: /^v\d*\.\d*\.\d*$/
711+
# jscpd:ignore-end

.github/workflows/agreements.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
path-to-document: "https://github.com/splunk/cla-agreement/blob/main/CLA.md" # e.g. a CLA or a DCO document
2323
# branch should not be protected
2424
branch: "main"
25-
allowlist: dependabot
25+
allowlist: dependabot[bot]
2626
#below are the optional inputs - If the optional inputs are not given, then default values will be taken
2727
remote-organization-name: splunk
2828
remote-repository-name: cla-agreement
@@ -47,7 +47,7 @@ jobs:
4747
path-to-document: "https://github.com/splunk/cla-agreement/blob/main/CODE_OF_CONDUCT.md" # e.g. a COC or a DCO document
4848
# branch should not be protected
4949
branch: "main"
50-
allowlist: dependabot
50+
allowlist: dependabot[bot]
5151
#below are the optional inputs - If the optional inputs are not given, then default values will be taken
5252
remote-organization-name: splunk
5353
remote-repository-name: cla-agreement

0 commit comments

Comments
 (0)