Skip to content

Commit

Permalink
Add option for e2e env vars in workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dkirov-dd committed Dec 17, 2024
1 parent e7d4f3c commit 860de51
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ jobs:
repo: "core"
standard: true
pytest-args: "-s -k test_fips_inactive_e2e"
fips-mode: false
traces-artifact-name: traces-tls-linux-no-fips
test-results-name: test-tls-linux-no-fips
agent-image: "datadog/agent-dev:main-fips"
Expand All @@ -59,10 +58,10 @@ jobs:
repo: "core"
standard: true
pytest-args: "-s -k test_fips_active_e2e"
fips-mode: true
traces-artifact-name: traces-tls-linux-fips
test-results-name: test-tls-linux-fips
agent-image: "datadog/agent-dev:main-fips"
e2e-env-vars: "{'GOFIPS':'1'}"
secrets: inherit

test-tls-windows:
Expand Down
35 changes: 22 additions & 13 deletions .github/workflows/test-target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ on:
required: false
type: string
default: ""
fips-mode:
description: "Should the agent be run in FIPS mode for e2e tests"
e2e-env-vars:
description: "Key-value pairs of environment variables for the Agent container."
required: false
type: boolean
default: false
type: string
default: "{}"

defaults:
run:
Expand Down Expand Up @@ -122,6 +122,7 @@ jobs:
# Capture traces for a separate job to do the submission
TRACE_CAPTURE_BASE_DIR: "trace-captures"
TRACE_CAPTURE_LOG: "trace-captures/output.log"
E2E_ENV_VARS: ""

steps:

Expand All @@ -133,6 +134,14 @@ jobs:
echo "TEST_RESULTS_DIR=$TEST_RESULTS_BASE_DIR/$JOB_NAME" >> $GITHUB_ENV
echo "TRACE_CAPTURE_FILE=$TRACE_CAPTURE_BASE_DIR/$JOB_NAME" >> $GITHUB_ENV
- name:
run: |
for key in $(echo '${{ toJSON(fromJSON(inputs.e2e-env-vars)) }}' | jq -r 'keys[]'); do
value=$(echo '${{ toJSON(fromJSON(inputs.e2e-env-vars)) }}' | jq -r --arg k "$key" '.[$k]')
E2E_ENV_VARS+="-e ${key}=${value} "
done
echo "E2E_ENV_VARS=$E2E_ENV_VARS" >> $GITHUB_ENV
- name: Set up Windows
if: runner.os == 'Windows'
run: |-
Expand Down Expand Up @@ -279,7 +288,7 @@ jobs:
# by default
if [ '${{ inputs.pytest-args }}' = '-m flaky' ]; then
set +e # Disable immediate exit
ddev env test -e GOFIPS=${{ inputs.fips-mode && '1' || '0' }} --base --new-env --junit ${{ inputs.target }} -- all ${{ inputs.pytest-args }}
ddev env test ${{ env.E2E_ENV_VARS }} --base --new-env --junit ${{ inputs.target }} -- all ${{ inputs.pytest-args }}
exit_code=$?
if [ $exit_code -eq 5 ]; then
# Flaky test count can be zero, this is done to avoid pipeline failure
Expand All @@ -290,7 +299,7 @@ jobs:
fi
elif [ '${{ inputs.pytest-args }}' = '-m "not flaky"' ]; then
set +e # Disable immediate exit
ddev env test -e GOFIPS=${{ inputs.fips-mode && '1' || '0' }} --base --new-env --junit ${{ inputs.target }} -- all ${{ inputs.pytest-args }}
ddev env test ${{ env.E2E_ENV_VARS }} --base --new-env --junit ${{ inputs.target }} -- all ${{ inputs.pytest-args }}
exit_code=$?
if [ $exit_code -eq 5 ]; then
# Flaky test count can be zero, this is done to avoid pipeline failure
Expand All @@ -300,7 +309,7 @@ jobs:
exit $exit_code
fi
else
ddev env test -e GOFIPS=${{ inputs.fips-mode && '1' || '0' }} --base --new-env --junit ${{ inputs.target }} ${{ inputs.pytest-args != '' && format('-- all {0}', inputs.pytest-args) || '' }}
ddev env test ${{ env.E2E_ENV_VARS }} --base --new-env --junit ${{ inputs.target }} ${{ inputs.pytest-args != '' && format('-- all {0}', inputs.pytest-args) || '' }}
fi
- name: Run E2E tests
Expand All @@ -317,7 +326,7 @@ jobs:
# by default
if [ '${{ inputs.pytest-args }}' = '-m flaky' ]; then
set +e # Disable immediate exit
ddev env test -e GOFIPS=${{ inputs.fips-mode && '1' || '0' }} --new-env --junit ${{ inputs.target }} -- all ${{ inputs.pytest-args }}
ddev env test ${{ env.E2E_ENV_VARS }} --new-env --junit ${{ inputs.target }} -- all ${{ inputs.pytest-args }}
exit_code=$?
if [ $exit_code -eq 5 ]; then
# Flaky test count can be zero, this is done to avoid pipeline failure
Expand All @@ -328,7 +337,7 @@ jobs:
fi
elif [ '${{ inputs.pytest-args }}' = '-m "not flaky"' ]; then
set +e # Disable immediate exit
ddev env test -e GOFIPS=${{ inputs.fips-mode && '1' || '0' }} --new-env --junit ${{ inputs.target }} -- all ${{ inputs.pytest-args }}
ddev env test ${{ env.E2E_ENV_VARS }} --new-env --junit ${{ inputs.target }} -- all ${{ inputs.pytest-args }}
exit_code=$?
if [ $exit_code -eq 5 ]; then
# Flaky test count can be zero, this is done to avoid pipeline failure
Expand All @@ -338,7 +347,7 @@ jobs:
exit $exit_code
fi
else
ddev env test -e GOFIPS=${{ inputs.fips-mode && '1' || '0' }} --new-env --junit ${{ inputs.target }} ${{ inputs.pytest-args != '' && format('-- all {0}', inputs.pytest-args) || '' }}
ddev env test ${{ env.E2E_ENV_VARS }} --new-env --junit ${{ inputs.target }} ${{ inputs.pytest-args != '' && format('-- all {0}', inputs.pytest-args) || '' }}
fi
- name: Run benchmarks
Expand All @@ -364,7 +373,7 @@ jobs:
# by default
if [ '${{ inputs.pytest-args }}' = '-m flaky' ]; then
set +e # Disable immediate exit
ddev env test -e GOFIPS=${{ inputs.fips-mode && '1' || '0' }} --base --new-env --junit ${{ inputs.target }}:latest -- all ${{ inputs.pytest-args }}
ddev env test ${{ env.E2E_ENV_VARS }} --base --new-env --junit ${{ inputs.target }}:latest -- all ${{ inputs.pytest-args }}
exit_code=$?
if [ $exit_code -eq 5 ]; then
# Flaky test count can be zero, this is done to avoid pipeline failure
Expand All @@ -375,7 +384,7 @@ jobs:
fi
elif [ '${{ inputs.pytest-args }}' = '-m "not flaky"' ]; then
set +e # Disable immediate exit
ddev env test -e GOFIPS=${{ inputs.fips-mode && '1' || '0' }} --base --new-env --junit ${{ inputs.target }}:latest -- all ${{ inputs.pytest-args }}
ddev env test ${{ env.E2E_ENV_VARS }} --base --new-env --junit ${{ inputs.target }}:latest -- all ${{ inputs.pytest-args }}
exit_code=$?
if [ $exit_code -eq 5 ]; then
# Flaky test count can be zero, this is done to avoid pipeline failure
Expand All @@ -385,7 +394,7 @@ jobs:
exit $exit_code
fi
else
ddev env test -e GOFIPS=${{ inputs.fips-mode && '1' || '0' }} --base --new-env --junit ${{ inputs.target }}:latest ${{ inputs.pytest-args != '' && format('-- all {0}', inputs.pytest-args) || '' }}
ddev env test ${{ env.E2E_ENV_VARS }} --base --new-env --junit ${{ inputs.target }}:latest ${{ inputs.pytest-args != '' && format('-- all {0}', inputs.pytest-args) || '' }}
fi
- name: View trace log
Expand Down

0 comments on commit 860de51

Please sign in to comment.