Skip to content

Commit 737b96e

Browse files
feat: handle separate deps (#440)
### Description This PR introduces mechanism for splitting dev dependencies from pyproject.toml and putting them to into dev_deps/requirements_dev.txt file. This is breaking change and needs to be performed before relevant repository template rollout. ### 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 splunk/splunk-add-on-for-cisco-asa#465 splunk/splunk-add-on-for-amazon-web-services#1532 splunk/splunk-add-on-for-google-workspace#651 splunk/splunk-add-on-for-microsoft-office-365#895 splunk/splunk-add-on-for-microsoft-cloud-services#1363
2 parents e9f1bc8 + 87a0220 commit 737b96e

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

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

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -485,20 +485,22 @@ jobs:
485485
python${{ env.PYTHON_VERSION }} -m pip install poetry==${{ env.POETRY_VERSION }} poetry-plugin-export==${{ env.POETRY_EXPORT_PLUGIN_VERSION }}
486486
poetry check
487487
poetry export --without-hashes -o package/lib/requirements.txt
488-
poetry export --without-hashes --with dev -o requirements_dev.txt
489488
fi
490-
if [ ! -f requirements_dev.txt ]; then echo no requirements;exit 0 ;fi
489+
if [ ! -f dev_deps/requirements_dev.txt ]; then echo no dev_deps/requirements;exit 1 ;fi
491490
git config --global --add url."https://${{ secrets.GH_TOKEN_ADMIN }}@github.com".insteadOf https://github.com
492491
git config --global --add url."https://${{ secrets.GH_TOKEN_ADMIN }}@github.com".insteadOf ssh://git@github.com
493-
poetry install --with dev
492+
python${{ env.PYTHON_VERSION }} -m venv .dev_venv
493+
echo "Found requirements_dev.txt. Installing dev dependencies in an isolated environment"
494+
./.dev_venv/bin/python${{ env.PYTHON_VERSION }} -m pip install -r dev_deps/requirements_dev.txt
495+
./.dev_venv/bin/python${{ env.PYTHON_VERSION }} -m pip install -r package/lib/requirements.txt
494496
- name: Create directories
495497
run: |
496498
mkdir -p /opt/splunk/var/log/splunk
497499
chmod -R 777 /opt/splunk/var/log/splunk
498500
- name: Copy pytest ini
499501
run: cp tests/unit/pytest-ci.ini pytest.ini
500502
- name: Run Pytest with coverage
501-
run: poetry run pytest --cov=./ --cov-report=xml --junitxml=test-results/junit.xml tests/unit
503+
run: ./.dev_venv/bin/python${{ env.PYTHON_VERSION }} -m pytest --cov=./ --cov-report=xml --junitxml=test-results/junit.xml tests/unit
502504
- name: Job summary
503505
continue-on-error: true
504506
run: |
@@ -568,48 +570,46 @@ jobs:
568570
echo "No prod dependencies were found"
569571
rm requirements.txt
570572
fi
571-
poetry export --without-hashes --with dev -o requirements_dev.txt
572-
cat requirements_dev.txt
573573
fi
574574
- name: Setup UCC
575575
run: |
576-
if [ -f "requirements_ucc.txt" ]; then
576+
if [ -f "dev_deps/requirements_ucc.txt" ]; then
577577
python${{ env.PYTHON_VERSION }} -m venv .ucc_venv
578578
echo "Found requirements_ucc.txt. Installing UCC dependencies in an isolated environment"
579-
./.ucc_venv/bin/python -m pip install -r requirements_ucc.txt
579+
./.ucc_venv/bin/python${{ env.PYTHON_VERSION }} -m pip install -r dev_deps/requirements_ucc.txt
580580
export UCC_GEN="$PWD/.ucc_venv/bin/ucc-gen"
581581
582582
if [ ! -f "$UCC_GEN" ]; then
583-
echo "ucc-gen not found after installing requirements from requirements_ucc.txt"
583+
echo "ucc-gen not found after installing requirements from dev_deps/requirements_ucc.txt"
584584
exit 1
585585
fi
586586
587587
echo "UCC_GEN=$UCC_GEN" >> "$GITHUB_ENV"
588588
else
589589
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"
590+
echo "Consider adding a dev_deps/requirements_ucc.txt file and place UCC requirement there, to avoid dependency conflicts"
591591
fi
592592
- name: Get pip cache dir
593593
id: pip-cache
594594
run: |
595595
echo "dir=$(pip cache dir)" >> "$GITHUB_OUTPUT"
596596
- name: Run Check there are libraries to scan
597597
id: checklibs
598-
run: if [ -f requirements_dev.txt ]; then echo "ENABLED=true" >> "$GITHUB_OUTPUT"; fi
598+
run: if [ -f dev_deps/requirements_dev.txt ]; then echo "ENABLED=true" >> "$GITHUB_OUTPUT"; fi
599599
- name: pip cache
600600
if: ${{ steps.checklibs.outputs.ENABLED == 'true' }}
601601
uses: actions/cache@v4
602602
with:
603603
path: ${{ steps.pip-cache.outputs.dir }}
604-
key: ${{ runner.os }}-pip-${{ hashFiles('requirements_dev.txt') }}
604+
key: ${{ runner.os }}-pip-${{ hashFiles('dev_deps/requirements_dev.txt') }}
605605
restore-keys: |
606606
${{ runner.os }}-pip-
607607
- name: Install deps
608608
if: ${{ steps.checklibs.outputs.ENABLED == 'true' }}
609609
run: |
610610
git config --global --add url."https://${{ secrets.GH_TOKEN_ADMIN }}@github.com".insteadOf https://github.com
611611
git config --global --add url."https://${{ secrets.GH_TOKEN_ADMIN }}@github.com".insteadOf ssh://git@github.com
612-
pip install -r requirements_dev.txt
612+
python${{ env.PYTHON_VERSION }} -m pip install -r dev_deps/requirements_dev.txt
613613
- name: Semantic Release Get Next
614614
id: semantic
615615
if: github.event_name != 'pull_request'
@@ -902,11 +902,11 @@ jobs:
902902
env:
903903
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
904904
run: |
905-
poetry install --only modinput
905+
python${{ env.PYTHON_VERSION }} -m pip install -r dev_deps/requirements_dev.txt
906906
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/
907+
ucc-test-modinput gen -o tests/ucc_modinput_functional/tmp/openapi.json -t ${{ steps.download-openapi.outputs.download-path }}/tmp/
908908
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/
909+
ucc-test-modinput gen -o ${{ steps.download-openapi.outputs.download-path }}/openapi.json -t ${{ steps.download-openapi.outputs.download-path }}/tmp/
910910
fi
911911
- name: upload-libs-to-s3
912912
id: upload-libs-to-s3
@@ -915,9 +915,11 @@ jobs:
915915
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
916916
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
917917
run: |
918-
poetry install --with dev
918+
python${{ env.PYTHON_VERSION }} -m venv .dev_venv
919+
echo "Found requirements_dev.txt. Installing dev dependencies in an isolated environment"
920+
./.dev_venv/bin/python${{ env.PYTHON_VERSION }} -m pip install -r dev_deps/requirements_dev.txt
919921
libs_archive=libs_$(basename "$BUILD_NAME" .spl).tgz
920-
cp -r "$(find "$(poetry env info --path)" -maxdepth 3 -type d -name "site-packages")" libs/
922+
cp -r ./.dev_venv/lib/python${{ env.PYTHON_VERSION }}/site-packages/ libs/
921923
tar -czf "$libs_archive" libs
922924
aws s3 cp "$libs_archive" "s3://${{ needs.setup-workflow.outputs.s3_bucket_k8s }}/ta-apps/$libs_archive" --only-show-errors
923925
- name: upload-swagger-artifacts-to-s3

0 commit comments

Comments
 (0)