Skip to content

Commit 5e16c12

Browse files
mkolasinski-splunkartemrysmbruzda-splunk
authored
chore(release): split dev deps and add reusable validate-docs and update-to-splunkbase workflows (#443)
### Description - use split dev deps in dev_deps directory - add reusable workflows validate-docs and upload-to-splunkbase - allow maximum time for test execution to be 5 hours ### Checklist - [ ] `README.md` has been updated or is not required - [ ] push trigger tests - [ ] manual release test - [ ] automated releases test - [x] pull request trigger tests - [ ] schedule trigger tests - [ ] workflow errors/warnings reviewed and addressed ### Testing done https://github.com/splunk/splunk-add-on-for-google-cloud-platform/actions/runs/19062264865 https://github.com/splunk/splunk-add-on-for-microsoft-cloud-services/actions/runs/19063205677 https://github.com/splunk/splunk-add-on-for-google-workspace/actions/runs/19062623500 https://github.com/splunk/splunk-add-on-for-microsoft-office-365/actions/runs/19059588124/job/54436959442 https://github.com/splunk/splunk-add-on-for-okta-identity-cloud/actions/runs/19062635352 https://github.com/splunk/splunk-add-on-for-salesforce/actions/runs/19062647886 --------- Co-authored-by: Artem Rys <rysartem@gmail.com> Co-authored-by: Marcin Bruzda <94437843+mbruzda-splunk@users.noreply.github.com>
1 parent d659ddf commit 5e16c12

File tree

4 files changed

+248
-34
lines changed

4 files changed

+248
-34
lines changed

.github/workflows/reusable-build-test-release.yml

Lines changed: 88 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ on:
9797
SPL_COM_PASSWORD:
9898
description: password to splunk.com
9999
required: true
100+
GSSA_AWS_ACCESS_KEY_ID:
101+
description: GSSA AWS access key id
102+
required: true
103+
GSSA_AWS_SECRET_ACCESS_KEY:
104+
description: GSSA AWS secret access key
105+
required: true
100106
permissions:
101107
contents: read
102108
packages: read
@@ -107,6 +113,8 @@ env:
107113
PYTHON_VERSION: "3.9"
108114
POETRY_VERSION: "2.1.4"
109115
POETRY_EXPORT_PLUGIN_VERSION: "1.9.0"
116+
GS_IMAGE_VERSION: "1.0.0"
117+
GS_VERSION: "0.3"
110118
jobs:
111119
validate-custom-version:
112120
runs-on: ubuntu-latest
@@ -481,24 +489,30 @@ jobs:
481489
run: |
482490
if [ -f "poetry.lock" ]
483491
then
492+
python${{ env.PYTHON_VERSION }} -m pip install poetry==${{ env.POETRY_VERSION }} poetry-plugin-export==${{ env.POETRY_EXPORT_PLUGIN_VERSION }}
484493
mkdir -p package/lib || true
485-
python${{ env.PYTHON_VERSION }} -m pip install poetry==${{ env.POETRY_VERSION }} poetry-plugin-export==${{ env.POETRY_EXPORT_PLUGIN_VERSION }}
486-
poetry check
494+
poetry check --lock
487495
poetry export --without-hashes -o package/lib/requirements.txt
488-
poetry export --without-hashes --with dev -o requirements_dev.txt
489496
fi
490-
if [ ! -f requirements_dev.txt ]; then echo no requirements;exit 0 ;fi
497+
if [ ! -f dev_deps/requirements_dev.txt ]; then
498+
echo "No dev_deps/requirements_dev.txt. Migrate your dependencies to dev_deps/requirements_dev.txt"
499+
exit 1
500+
else
501+
echo "Found dev_deps/requirements_dev.txt. Installing dev dependencies in an isolated environment";
502+
fi
491503
git config --global --add url."https://${{ secrets.GH_TOKEN_ADMIN }}@github.com".insteadOf https://github.com
492504
git config --global --add url."https://${{ secrets.GH_TOKEN_ADMIN }}@github.com".insteadOf ssh://git@github.com
493-
poetry install --with dev
505+
python${{ env.PYTHON_VERSION }} -m venv ~/.dev_venv
506+
~/.dev_venv/bin/python${{ env.PYTHON_VERSION }} -m pip install -r dev_deps/requirements_dev.txt
507+
~/.dev_venv/bin/python${{ env.PYTHON_VERSION }} -m pip install -r package/lib/requirements.txt
494508
- name: Create directories
495509
run: |
496510
mkdir -p /opt/splunk/var/log/splunk
497511
chmod -R 777 /opt/splunk/var/log/splunk
498512
- name: Copy pytest ini
499513
run: cp tests/unit/pytest-ci.ini pytest.ini
500514
- name: Run Pytest with coverage
501-
run: poetry run pytest --cov=./ --cov-report=xml --junitxml=test-results/junit.xml tests/unit
515+
run: ~/.dev_venv/bin/python${{ env.PYTHON_VERSION }} -m pytest --cov=./ --cov-report=xml --junitxml=test-results/junit.xml tests/unit
502516
- name: Job summary
503517
continue-on-error: true
504518
run: |
@@ -568,48 +582,41 @@ jobs:
568582
echo "No prod dependencies were found"
569583
rm requirements.txt
570584
fi
571-
poetry export --without-hashes --with dev -o requirements_dev.txt
572-
cat requirements_dev.txt
573585
fi
574586
- name: Setup UCC
575587
run: |
576-
if [ -f "requirements_ucc.txt" ]; then
577-
python${{ env.PYTHON_VERSION }} -m venv .ucc_venv
588+
if [ -f "dev_deps/requirements_ucc.txt" ]; then
578589
echo "Found requirements_ucc.txt. Installing UCC dependencies in an isolated environment"
579-
./.ucc_venv/bin/python -m pip install -r requirements_ucc.txt
580-
export UCC_GEN="$PWD/.ucc_venv/bin/ucc-gen"
581-
590+
python${{ env.PYTHON_VERSION }} -m venv ~/.ucc_venv
591+
~/.ucc_venv/bin/python${{ env.PYTHON_VERSION }} -m pip install -r dev_deps/requirements_ucc.txt
592+
export UCC_GEN="$HOME/.ucc_venv/bin/ucc-gen"
593+
582594
if [ ! -f "$UCC_GEN" ]; then
583-
echo "ucc-gen not found after installing requirements from requirements_ucc.txt"
595+
echo "ucc-gen not found after installing requirements from dev_deps/requirements_ucc.txt"
584596
exit 1
585597
fi
586598
587599
echo "UCC_GEN=$UCC_GEN" >> "$GITHUB_ENV"
588600
else
589601
echo "No UCC requirements file found, skipping UCC setup"
590-
echo "Consider adding a requirements_ucc.txt file and place UCC requirement there, to avoid dependency conflicts"
602+
echo "Create a dev_deps/requirements_ucc.txt file and place UCC requirement there, to avoid dependency conflicts"
603+
exit 1
591604
fi
592605
- name: Get pip cache dir
593606
id: pip-cache
594607
run: |
595608
echo "dir=$(pip cache dir)" >> "$GITHUB_OUTPUT"
596609
- name: Run Check there are libraries to scan
597610
id: checklibs
598-
run: if [ -f requirements_dev.txt ]; then echo "ENABLED=true" >> "$GITHUB_OUTPUT"; fi
611+
run: if [ -f dev_deps/requirements_dev.txt ]; then echo "ENABLED=true" >> "$GITHUB_OUTPUT"; fi
599612
- name: pip cache
600613
if: ${{ steps.checklibs.outputs.ENABLED == 'true' }}
601614
uses: actions/cache@v4
602615
with:
603616
path: ${{ steps.pip-cache.outputs.dir }}
604-
key: ${{ runner.os }}-pip-${{ hashFiles('requirements_dev.txt') }}
617+
key: ${{ runner.os }}-pip-${{ hashFiles('dev_deps/requirements_dev.txt') }}
605618
restore-keys: |
606619
${{ runner.os }}-pip-
607-
- name: Install deps
608-
if: ${{ steps.checklibs.outputs.ENABLED == 'true' }}
609-
run: |
610-
git config --global --add url."https://${{ secrets.GH_TOKEN_ADMIN }}@github.com".insteadOf https://github.com
611-
git config --global --add url."https://${{ secrets.GH_TOKEN_ADMIN }}@github.com".insteadOf ssh://git@github.com
612-
pip install -r requirements_dev.txt
613620
- name: Semantic Release Get Next
614621
id: semantic
615622
if: github.event_name != 'pull_request'
@@ -812,6 +819,50 @@ jobs:
812819
name: appinspect-api-html-report-${{ matrix.tags }}
813820
path: AppInspect_response.html
814821

822+
run-gs-scorecard:
823+
name: quality-gs-scorecard
824+
needs: build
825+
if: ${{ !cancelled() && needs.build.result == 'success' && (github.ref_name == 'main' && github.event_name == 'push') }}
826+
runs-on: ubuntu-latest
827+
steps:
828+
- uses: actions/checkout@v4
829+
- name: Configure AWS credentials
830+
uses: aws-actions/configure-aws-credentials@v4
831+
with:
832+
aws-access-key-id: ${{ secrets.GSSA_AWS_ACCESS_KEY_ID }}
833+
aws-secret-access-key: ${{ secrets.GSSA_AWS_SECRET_ACCESS_KEY }}
834+
aws-region: us-west-2
835+
- name: Login to Amazon ECR
836+
uses: aws-actions/amazon-ecr-login@v2
837+
- name: Pull GS Scorecard image
838+
run:
839+
docker pull 956110764581.dkr.ecr.us-west-2.amazonaws.com/ta-automation/gs-scorecard:${{ env.GS_IMAGE_VERSION }}
840+
- name: Run GS Scorecard
841+
env:
842+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_ADMIN }}
843+
GITHUB_USERNAME: ${{ secrets.SA_GH_USER_NAME }}
844+
APPINSPECT_USER: ${{ secrets.SPL_COM_USER }}
845+
APPINSPECT_PASS: ${{ secrets.SPL_COM_PASSWORD }}
846+
run: |
847+
docker run --rm \
848+
-e GITHUB_TOKEN \
849+
-e GITHUB_USERNAME \
850+
-e AWS_ACCESS_KEY_ID="${{ secrets.GSSA_AWS_ACCESS_KEY_ID }}" \
851+
-e AWS_SECRET_ACCESS_KEY="${{ secrets.GSSA_AWS_SECRET_ACCESS_KEY }}" \
852+
-e AWS_DEFAULT_REGION="us-west-2" \
853+
-e APPINSPECT_USER \
854+
-e APPINSPECT_PASS \
855+
-e GS_VERSION="${{ env.GS_VERSION }}" \
856+
-v "$(pwd)":/addon \
857+
956110764581.dkr.ecr.us-west-2.amazonaws.com/ta-automation/gs-scorecard:"${{ env.GS_IMAGE_VERSION }}"
858+
859+
- name: Upload GS Scorecard report
860+
uses: actions/upload-artifact@v4
861+
if: always()
862+
with:
863+
name: gs-scorecard-report
864+
path: ./gs_scorecard.html
865+
815866
setup:
816867
needs:
817868
- setup-workflow
@@ -902,11 +953,12 @@ jobs:
902953
env:
903954
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
904955
run: |
905-
poetry install --only modinput
956+
python${{ env.PYTHON_VERSION }} -m venv ~/.dev_venv
957+
~/.dev_venv/bin/python${{ env.PYTHON_VERSION }} -m pip install -r dev_deps/requirements_dev.txt
906958
if [ -f "tests/ucc_modinput_functional/tmp/openapi.json" ]; then
907-
poetry run ucc-test-modinput gen -o tests/ucc_modinput_functional/tmp/openapi.json -t ${{ steps.download-openapi.outputs.download-path }}/tmp/
959+
~/.dev_venv/bin/ucc-test-modinput gen -o tests/ucc_modinput_functional/tmp/openapi.json -t ${{ steps.download-openapi.outputs.download-path }}/tmp/
908960
else
909-
poetry run ucc-test-modinput gen -o ${{ steps.download-openapi.outputs.download-path }}/openapi.json -t ${{ steps.download-openapi.outputs.download-path }}/tmp/
961+
~/.dev_venv/bin/ucc-test-modinput gen -o ${{ steps.download-openapi.outputs.download-path }}/openapi.json -t ${{ steps.download-openapi.outputs.download-path }}/tmp/
910962
fi
911963
- name: upload-libs-to-s3
912964
id: upload-libs-to-s3
@@ -915,9 +967,11 @@ jobs:
915967
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
916968
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
917969
run: |
918-
poetry install --with dev
970+
python${{ env.PYTHON_VERSION }} -m venv ~/.dev_venv
971+
echo "Found requirements_dev.txt. Installing dev dependencies in an isolated environment"
972+
~/.dev_venv/bin/python${{ env.PYTHON_VERSION }} -m pip install -r dev_deps/requirements_dev.txt
919973
libs_archive=libs_$(basename "$BUILD_NAME" .spl).tgz
920-
cp -r "$(find "$(poetry env info --path)" -maxdepth 3 -type d -name "site-packages")" libs/
974+
cp -r ~/.dev_venv/lib/python${{ env.PYTHON_VERSION }}/site-packages/ libs/
921975
tar -czf "$libs_archive" libs
922976
aws s3 cp "$libs_archive" "s3://${{ needs.setup-workflow.outputs.s3_bucket_k8s }}/ta-apps/$libs_archive" --only-show-errors
923977
- name: upload-swagger-artifacts-to-s3
@@ -1265,7 +1319,7 @@ jobs:
12651319
run: |
12661320
start_time=${{ steps.capture-start-time.outputs.start_time }}
12671321
current_time=$(date +%s)
1268-
remaining_time_minutes=$(( 350-((current_time-start_time)/60) ))
1322+
remaining_time_minutes=$(( 300-((current_time-start_time)/60) ))
12691323
echo "remaining_time_minutes=$remaining_time_minutes" >> "$GITHUB_OUTPUT"
12701324
- name: Check if pod was deleted
12711325
id: is-pod-deleted
@@ -1550,7 +1604,7 @@ jobs:
15501604
run: |
15511605
start_time=${{ steps.capture-start-time.outputs.start_time }}
15521606
current_time=$(date +%s)
1553-
remaining_time_minutes=$(( 350-((current_time-start_time)/60) ))
1607+
remaining_time_minutes=$(( 300-((current_time-start_time)/60) ))
15541608
echo "remaining_time_minutes=$remaining_time_minutes" >> "$GITHUB_OUTPUT"
15551609
- name: Check if pod was deleted
15561610
id: is-pod-deleted
@@ -1826,7 +1880,7 @@ jobs:
18261880
run: |
18271881
start_time=${{ steps.capture-start-time.outputs.start_time }}
18281882
current_time=$(date +%s)
1829-
remaining_time_minutes=$(( 350-((current_time-start_time)/60) ))
1883+
remaining_time_minutes=$(( 300-((current_time-start_time)/60) ))
18301884
echo "remaining_time_minutes=$remaining_time_minutes" >> "$GITHUB_OUTPUT"
18311885
- name: Check if pod was deleted
18321886
id: is-pod-deleted
@@ -2101,7 +2155,7 @@ jobs:
21012155
run: |
21022156
start_time=${{ steps.capture-start-time.outputs.start_time }}
21032157
current_time=$(date +%s)
2104-
remaining_time_minutes=$(( 350-((current_time-start_time)/60) ))
2158+
remaining_time_minutes=$(( 300-((current_time-start_time)/60) ))
21052159
echo "remaining_time_minutes=$remaining_time_minutes" >> "$GITHUB_OUTPUT"
21062160
- name: Check if pod was deleted
21072161
id: is-pod-deleted
@@ -2365,7 +2419,7 @@ jobs:
23652419
run: |
23662420
start_time=${{ steps.capture-start-time.outputs.start_time }}
23672421
current_time=$(date +%s)
2368-
remaining_time_minutes=$(( 350-((current_time-start_time)/60) ))
2422+
remaining_time_minutes=$(( 300-((current_time-start_time)/60) ))
23692423
echo "remaining_time_minutes=$remaining_time_minutes" >> "$GITHUB_OUTPUT"
23702424
- name: Check if pod was deleted
23712425
id: is-pod-deleted
@@ -2634,7 +2688,7 @@ jobs:
26342688
run: |
26352689
start_time=${{ steps.capture-start-time.outputs.start_time }}
26362690
current_time=$(date +%s)
2637-
remaining_time_minutes=$(( 350-((current_time-start_time)/60) ))
2691+
remaining_time_minutes=$(( 300-((current_time-start_time)/60) ))
26382692
echo "remaining_time_minutes=$remaining_time_minutes" >> "$GITHUB_OUTPUT"
26392693
- name: Check if pod was deleted
26402694
id: is-pod-deleted
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: publish-to-splunkbase
2+
on:
3+
workflow_call:
4+
inputs:
5+
addon_version:
6+
description: 'The version of the add-on to publish to Splunkbase'
7+
required: true
8+
type: string
9+
splunk_versions:
10+
description: 'Comma-separated list of supported Splunk versions'
11+
required: true
12+
type: string
13+
cim_versions:
14+
description: 'Comma-separated list of supported CIM versions'
15+
required: true
16+
type: string
17+
secrets:
18+
SPL_COM_USERNAME:
19+
description: 'Splunk Community username'
20+
required: true
21+
SPL_COM_PASSWORD:
22+
description: 'Splunk Community password'
23+
required: true
24+
25+
jobs:
26+
inputs-validator:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- id: matrix
30+
uses: splunk/addonfactory-test-matrix-action@v3.1
31+
with:
32+
features: PYTHON39
33+
publish:
34+
runs-on: ubuntu-latest
35+
needs:
36+
- inputs-validator
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: actions/setup-python@v5
40+
with:
41+
python-version: "3.12"
42+
- run: pip install splunk_add_on_ucc_framework-5.69.1-py3-none-any.whl
43+
- name: Fetch build
44+
env:
45+
GH_TOKEN: ${{ github.token }}
46+
run: |
47+
gh release download v${{ inputs.addon_version }} --pattern "*${{ inputs.addon_version }}.spl" --output release.spl
48+
- run: |
49+
APP_ID=$(cat .splunkbase)
50+
export APP_ID
51+
ucc-gen publish \
52+
--stage \
53+
--app-id "$APP_ID" \
54+
--package-path release.spl \
55+
--splunk-versions ${{ inputs.splunk_versions }} \
56+
--cim-versions ${{ inputs.cim_versions }} \
57+
--username ${{ secrets.SPL_COM_USERNAME }} \
58+
--password ${{ secrets.SPL_COM_PASSWORD }}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: validate-deploy-docs
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
validate-docs-change:
8+
runs-on: ubuntu-latest
9+
outputs:
10+
status: ${{ steps.validate.outputs.status }}
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: 3.12
16+
- name: Install mkdocs and plugins
17+
run: pip install mkdocs==1.6.0 mkdocs-material==9.5.32 mkdocs-print-site-plugin==2.6.0
18+
- name: Validate docs change
19+
id: validate
20+
shell: bash
21+
run: |
22+
RED='\033[0;31m'
23+
GREEN='\033[0;32m'
24+
NC='\033[0m'
25+
if mkdocs build --strict; then
26+
echo "status=success" >> "$GITHUB_OUTPUT"
27+
echo -e "${GREEN}Docs validation success${NC}"
28+
else
29+
echo "status=failure" >> "$GITHUB_OUTPUT"
30+
echo -e "${RED}Docs validation failure${NC}"
31+
exit 1
32+
fi
33+
34+
deploy-docs:
35+
needs:
36+
- validate-docs-change
37+
runs-on: ubuntu-latest
38+
permissions:
39+
contents: write
40+
pages: write
41+
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
42+
steps:
43+
- uses: actions/checkout@v4
44+
- uses: actions/setup-python@v5
45+
with:
46+
python-version: 3.12
47+
- name: Install mkdocs and plugins
48+
run: pip install mkdocs==1.6.0 mkdocs-material==9.5.32 mkdocs-print-site-plugin==2.6.0
49+
- name: Build and Deploy docs
50+
id: deploy
51+
shell: bash
52+
run: |
53+
RED='\033[0;31m'
54+
GREEN='\033[0;32m'
55+
NC='\033[0m'
56+
if [ "${{ needs.validate-docs-change.outputs.status }}" == "failure" ]; then
57+
echo -e "${RED}Docs validation failed, abort docs deployment... (for more details look at Validate docs change job)${NC}"
58+
exit 1
59+
fi
60+
mkdocs gh-deploy --force
61+
echo -e "${GREEN}Deployed docs on github!${NC}"

0 commit comments

Comments
 (0)