Skip to content

Commit 291fce9

Browse files
feat: adding requirement tests back (#114)
1 parent 381b554 commit 291fce9

File tree

1 file changed

+185
-6
lines changed

1 file changed

+185
-6
lines changed

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

Lines changed: 185 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,30 @@ jobs:
402402
name: test-results-unit-python_${{ matrix.python-version }}
403403
path: test-results/*
404404

405+
run-requirements-unit-tests:
406+
if: ${{ needs.test-inventory.outputs.requirement_test == 'true' }}
407+
runs-on: ubuntu-latest
408+
needs:
409+
- build
410+
- test-inventory
411+
steps:
412+
- uses: actions/checkout@v3
413+
- name: Install Python 3
414+
uses: actions/setup-python@v4
415+
with:
416+
python-version: 3.7
417+
- name: run-tests
418+
uses: splunk/addonfactory-workflow-requirement-files-unit-tests@v1.4
419+
with:
420+
input-files: tests/requirement_test/logs
421+
- name: Archive production artifacts
422+
if: always()
423+
uses: actions/upload-artifact@v3
424+
with:
425+
name: test-results
426+
path: |
427+
test_*.txt
428+
405429
appinspect:
406430
name: quality-appinspect-${{ matrix.tags }}
407431
needs: build
@@ -750,6 +774,161 @@ jobs:
750774
path: "${{ needs.setup.outputs.directory-path }}/test-results/*.xml"
751775
reporter: java-junit
752776

777+
run-requirement-tests:
778+
if: ${{ needs.test-inventory.outputs.requirement_test == 'true' }}
779+
needs:
780+
- build
781+
- test-inventory
782+
- setup
783+
- meta
784+
runs-on: ubuntu-latest
785+
strategy:
786+
fail-fast: false
787+
matrix:
788+
splunk: ${{ fromJson(needs.meta.outputs.matrix_latestSplunk) }}
789+
sc4s: ${{ fromJson(needs.meta.outputs.matrix_supportedSC4S) }}
790+
container:
791+
image: ghcr.io/splunk/workflow-engine-base:2.0.3
792+
env:
793+
ARGO_SERVER: ${{ needs.setup.outputs.argo-server }}
794+
ARGO_HTTP1: ${{ needs.setup.outputs.argo-http1 }}
795+
ARGO_SECURE: ${{ needs.setup.outputs.argo-secure }}
796+
ARGO_BASE_HREF: ${{ needs.setup.outputs.argo-href }}
797+
ARGO_NAMESPACE: ${{ needs.setup.outputs.argo-namespace }}
798+
TEST_TYPE: "requirement_test"
799+
TEST_ARGS: ""
800+
steps:
801+
- uses: actions/checkout@v3
802+
with:
803+
submodules: recursive
804+
- name: Configure AWS credentials
805+
uses: aws-actions/configure-aws-credentials@v1
806+
with:
807+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
808+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
809+
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
810+
- name: Read secrets from AWS Secrets Manager into environment variables
811+
id: get-argo-token
812+
run: |
813+
ARGO_TOKEN=$(aws secretsmanager get-secret-value --secret-id ta-github-workflow-automation-token | jq -r '.SecretString')
814+
echo "::set-output name=argo-token::$ARGO_TOKEN"
815+
- name: create job name
816+
id: create-job-name
817+
shell: bash
818+
run: |
819+
RANDOM_STRING=$(head -3 /dev/urandom | tr -cd '[:lower:]' | cut -c -4)
820+
JOB_NAME=${{ needs.setup.outputs.job-name }}-${RANDOM_STRING}
821+
JOB_NAME=${JOB_NAME//TEST-TYPE/${{ env.TEST_TYPE }}}
822+
JOB_NAME=${JOB_NAME//[_.]/-}
823+
JOB_NAME=$(echo "$JOB_NAME" | tr '[:upper:]' '[:lower:]')
824+
echo "::set-output name=job-name::$JOB_NAME"
825+
- name: run-tests
826+
id: run-tests
827+
env:
828+
ARGO_TOKEN: ${{ steps.get-argo-token.outputs.argo-token }}
829+
uses: splunk/wfe-test-runner-action@v1.6
830+
with:
831+
splunk: ${{ matrix.splunk.version }}
832+
test-type: ${{ env.TEST_TYPE }}
833+
test-args: ""
834+
job-name: ${{ steps.create-job-name.outputs.job-name }}
835+
labels: ${{ needs.setup.outputs.labels }}
836+
workflow-tmpl-name: ${{ needs.setup.outputs.argo-workflow-tmpl-name }}
837+
workflow-template-ns: ${{ needs.setup.outputs.argo-namespace }}
838+
delay-destroy: "No"
839+
addon-url: ${{ needs.setup.outputs.addon-upload-path }}
840+
addon-name: ${{ needs.setup.outputs.addon-name }}
841+
sc4s-version: ${{ matrix.sc4s.version }}
842+
sc4s-docker-registry: ${{ matrix.sc4s.docker_registry }}
843+
- name: Check if pod was deleted
844+
id: is-pod-deleted
845+
if: always()
846+
shell: bash
847+
env:
848+
ARGO_TOKEN: ${{ steps.get-argo-token.outputs.argo-token }}
849+
run: |
850+
set -o xtrace
851+
if argo watch ${{ steps.run-tests.outputs.workflow-name }} -n workflows | grep "pod deleted"; then
852+
echo "::set-output name=retry-workflow::true"
853+
fi
854+
- name: Retrying workflow
855+
id: retry-wf
856+
shell: bash
857+
env:
858+
ARGO_TOKEN: ${{ steps.get-argo-token.outputs.argo-token }}
859+
if: always()
860+
run: |
861+
set -o xtrace
862+
set +e
863+
if [[ "${{ steps.is-pod-deleted.outputs.retry-workflow }}" == "true" ]]
864+
then
865+
WORKFLOW_NAME=$(argo resubmit -v -o json -n workflows "${{ steps.run-tests.outputs.workflow-name }}" | jq -r .metadata.name)
866+
echo "::set-output name=workflow-name::$$WORKFLOW_NAME"
867+
argo logs --follow "${WORKFLOW_NAME}" -n workflows || echo "... there was an error fetching logs, the workflow is still in progress. please wait for the workflow to complete ..."
868+
else
869+
echo "No retry required"
870+
argo wait "${{ steps.run-tests.outputs.workflow-name }}" -n workflows
871+
argo watch "${{ steps.run-tests.outputs.workflow-name }}" -n workflows | grep "test-addon"
872+
fi
873+
- name: check if workflow completed
874+
env:
875+
ARGO_TOKEN: ${{ steps.get-argo-token.outputs.argo-token }}
876+
shell: bash
877+
if: always()
878+
run: |
879+
set +e
880+
# shellcheck disable=SC2157
881+
if [ -z "${{ steps.retry-wf.outputs.workflow-name }}" ]; then
882+
WORKFLOW_NAME=${{ steps.run-tests.outputs.workflow-name }}
883+
else
884+
WORKFLOW_NAME="${{ steps.retry-wf.outputs.workflow-name }}"
885+
fi
886+
ARGO_STATUS=$(argo get "${WORKFLOW_NAME}" -n workflows -o json | jq -r '.status.phase')
887+
echo "Status of workflow:" "$ARGO_STATUS"
888+
while [ "$ARGO_STATUS" == "Running" ] || [ "$ARGO_STATUS" == "Pending" ]
889+
do
890+
echo "... argo Workflow ${WORKFLOW_NAME} is running, waiting for it to complete."
891+
argo wait "${WORKFLOW_NAME}" -n workflows || true
892+
ARGO_STATUS=$(argo get "${WORKFLOW_NAME}" -n workflows -o json | jq -r '.status.phase')
893+
done
894+
- name: pull artifacts from s3 bucket
895+
if: always()
896+
run: |
897+
echo "pulling artifacts"
898+
aws s3 cp s3://${{ needs.setup.outputs.s3-bucket }}/artifacts-${{ steps.create-job-name.outputs.job-name }}/${{ steps.create-job-name.outputs.job-name }}.tgz ${{ needs.setup.outputs.directory-path }}/
899+
tar -xf ${{ needs.setup.outputs.directory-path }}/${{ steps.create-job-name.outputs.job-name }}.tgz -C ${{ needs.setup.outputs.directory-path }}
900+
- name: pull logs from s3 bucket
901+
if: always()
902+
run: |
903+
# shellcheck disable=SC2157
904+
if [ -z "${{ steps.retry-wf.outputs.workflow-name }}" ]; then
905+
WORKFLOW_NAME=${{ steps.run-tests.outputs.workflow-name }}
906+
else
907+
WORKFLOW_NAME="${{ steps.retry-wf.outputs.workflow-name }}"
908+
fi
909+
echo "pulling logs"
910+
mkdir -p ${{ needs.setup.outputs.directory-path }}/argo-logs
911+
aws s3 cp s3://${{ needs.setup.outputs.s3-bucket }}/${WORKFLOW_NAME}/ ${{ needs.setup.outputs.directory-path }}/argo-logs/ --recursive
912+
- uses: actions/upload-artifact@v3
913+
if: always()
914+
with:
915+
name: archive splunk ${{ matrix.splunk.version }} ${{ env.TEST_TYPE }} tests artifacts
916+
path: |
917+
${{ needs.setup.outputs.directory-path }}/test-results
918+
- uses: actions/upload-artifact@v3
919+
if: always()
920+
with:
921+
name: archive splunk ${{ matrix.splunk.version }} ${{ env.TEST_TYPE }} tests logs
922+
path: |
923+
${{ needs.setup.outputs.directory-path }}/argo-logs
924+
- name: Test Report
925+
uses: dorny/test-reporter@v1
926+
if: always()
927+
with:
928+
name: splunk ${{ matrix.splunk.version }} ${{ env.TEST_TYPE }} test report
929+
path: "${{ needs.setup.outputs.directory-path }}/test-results/*.xml"
930+
reporter: java-junit
931+
753932
run-ui-tests:
754933
if: ${{ needs.test-inventory.outputs.ui == 'true' }}
755934
needs:
@@ -762,7 +941,7 @@ jobs:
762941
fail-fast: false
763942
matrix:
764943
splunk: ${{ fromJson(needs.meta.outputs.matrix_supportedSplunk) }}
765-
browser: ["chrome","firefox"]
944+
browser: [ "chrome","firefox" ]
766945
vendor-version: ${{ fromJson(needs.meta.outputs.matrix_supportedUIVendors) }}
767946
container:
768947
image: ghcr.io/splunk/workflow-engine-base:2.0.3
@@ -924,7 +1103,7 @@ jobs:
9241103
fail-fast: false
9251104
matrix:
9261105
splunk: ${{ fromJson(needs.meta.outputs.matrix_supportedSplunk) }}
927-
modinput-type: ["modinput_functional"]
1106+
modinput-type: [ "modinput_functional" ]
9281107
vendor-version: ${{ fromJson(needs.meta.outputs.matrix_supportedModinputFunctionalVendors) }}
9291108
marker: ${{ fromJson(inputs.marker) }}
9301109
container:
@@ -1099,7 +1278,7 @@ jobs:
10991278
fail-fast: false
11001279
matrix:
11011280
splunk: ${{ fromJson(needs.meta.outputs.matrix_supportedSplunk) }}
1102-
os: ["ubuntu:14.04", "ubuntu:16.04","ubuntu:18.04","ubuntu:22.04", "centos:7", "redhat:8.0", "redhat:8.2", "redhat:8.3", "redhat:8.4", "redhat:8.5"]
1281+
os: [ "ubuntu:14.04", "ubuntu:16.04","ubuntu:18.04","ubuntu:22.04", "centos:7", "redhat:8.0", "redhat:8.2", "redhat:8.3", "redhat:8.4", "redhat:8.5" ]
11031282
container:
11041283
image: ghcr.io/splunk/workflow-engine-base:2.0.3
11051284
env:
@@ -1267,7 +1446,7 @@ jobs:
12671446
fail-fast: false
12681447
matrix:
12691448
splunk: ${{ fromJson(needs.meta.outputs.matrix_supportedSplunk) }}
1270-
os: ["ubuntu:22.04", "centos:7","redhat:8.5"]
1449+
os: [ "ubuntu:22.04", "centos:7","redhat:8.5" ]
12711450
container:
12721451
image: ghcr.io/splunk/workflow-engine-base:2.0.3
12731452
env:
@@ -1729,10 +1908,10 @@ jobs:
17291908
overwrite: true
17301909
file_glob: true
17311910
tag: v${{ steps.semantic.outputs.new_release_version }}
1732-
1911+
17331912
get_workflow_conclusion:
17341913
if: always()
1735-
needs: [publish]
1914+
needs: [ publish ]
17361915
runs-on: ubuntu-latest
17371916
steps:
17381917
- name: Send logs to Skynet

0 commit comments

Comments
 (0)