-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DAOS-14726 build: Handle corner case… (#13472)
Of not erroneously matching commit pragmas that are part of the patch description when they occur quoted at the start of a line. For example: 'Skip-checkpatch: true' should not be considered a commit pragma. Unfortunately Skip-checkpatch: true would be considered a commit pragma because the missing quotes around it (and it being at the beginning of the line) eliminate the only means we have of trying to determine that it's not really a commit pragma. Unfortunately we cannot use spaces in the value as an indicator that it's a pragma because we have pragmas that allow space separated values such as Test-tag. Also limit the characters that can be in a commit pragma to prevent command injection attempts such as: Hacking-attempt: true;evil_command Add a step to show the found commit pragmas. Add unit-testing for gha_functions.sh. Signed-off-by: Brian J. Murrell <[email protected]>
- Loading branch information
1 parent
266f84a
commit d53892d
Showing
3 changed files
with
45 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: bash Unit Testing | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
concurrency: | ||
group: bash-unit-test-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
defaults: | ||
run: | ||
shell: bash --noprofile --norc -ueo pipefail {0} | ||
|
||
jobs: | ||
Test-gha-functions: | ||
name: Tests in ci/gha_functions.sh | ||
runs-on: [self-hosted, light] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
- name: Checkout bash_unit project | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: 'pgrange/bash_unit' | ||
path: bash_unit | ||
- name: Unit testing with bash_unit | ||
run: FORCE_COLOR=true ./bash_unit/bash_unit ci/gha_functions.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,7 +77,7 @@ get_test_tags() { | |
|
||
|
||
get_commit_pragmas() { | ||
sed -ne '/^[^ ]*: */s/\([^:]*\): *\(.*\)/\1 \2/p' | while read -r a b; do | ||
sed -Ene 's/^([-[:alnum:]]+): *([-\._ [:alnum:]]+)$/\1 \2/p' | while read -r a b; do | ||
echo -n "${a//-/_}" | tr '[:lower:]' '[:upper:]' | ||
# escape special characters in the value | ||
echo "=$b" | sed -e 's/\([<> ]\)/\\\1/g' | ||
|
@@ -240,7 +240,7 @@ Stage Name: $stage_name\" > /root/job_info | |
|
||
|
||
# This is run under the unit test framework at https://github.com/pgrange/bash_unit/ | ||
# I.e. ../bash_unit/bash_unit ci/gha_functions.sh ci/gha_functions.sh | ||
# I.e. ../bash_unit/bash_unit ci/gha_functions.sh | ||
test_test_tag_and_features() { | ||
# Simple Test-tag: test | ||
assert_equals "$(CP_TEST_TAG="always_passes always_fails" get_test_tags "-hw")" "always_passes,-hw always_fails,-hw" | ||
|
@@ -257,7 +257,12 @@ test_test_tag_and_features() { | |
test_get_commit_pragmas() { | ||
local msg='Escape spaces also | ||
'"'"'Will-not-be-a-pragma: false'"'"' should not be considered a commit | ||
pragma, but: | ||
Should-not-be-a-pragma: bar will be because it was not quoted. | ||
Skip-func-test-leap15: false | ||
RPM-test-version: 2.5.100-13.10036.g65926e32 | ||
Skip-PR-comments: true | ||
Test-tag: always_passes always_fails | ||
EL8-VM9-label: all_vm9 | ||
|
@@ -270,21 +275,21 @@ Required-githooks: true | |
Signed-off-by: Brian J. Murrell <[email protected]> | ||
' | ||
assert_equals "$(echo "$msg" | get_commit_pragmas)" 'SKIP_FUNC_TEST_LEAP15=false | ||
assert_equals "$(echo "$msg" | get_commit_pragmas)" 'SHOULD_NOT_BE_A_PRAGMA=bar\ will\ be\ because\ it\ was\ not\ quoted. | ||
SKIP_FUNC_TEST_LEAP15=false | ||
RPM_TEST_VERSION=2.5.100-13.10036.g65926e32 | ||
SKIP_PR_COMMENTS=true | ||
TEST_TAG=always_passes\ always_fails | ||
EL8_VM9_LABEL=all_vm9 | ||
EL9_VM9_LABEL=all_vm9 | ||
LEAP15_VM9_LABEL=all_vm9 | ||
HW_MEDIUM_LABEL=new_icx5 | ||
HW_LARGE_LABEL=new_icx9 | ||
REQUIRED_GITHOOKS=true | ||
SIGNED_OFF_BY=Brian\ J.\ Murrell\ \<[email protected]\>' | ||
REQUIRED_GITHOOKS=true' | ||
|
||
} | ||
|
||
test_jenkins_curl() { | ||
JENKINS_URL="${JENKINS_URL:-https://build.hpdd.intel.com/}" | ||
assert_equals "$(QUIET=true VERBOSE=false jenkins_curl -X POST "${JENKINS_URL}api/xml" 3>&1 >/dev/null | grep '^X-Content-Type-Options:')" "X-Content-Type-Options: nosniff | ||
" | ||
assert_equals "$(QUIET=true VERBOSE=false jenkins_curl -X POST "${JENKINS_URL}api/xml" 3>&1 >/dev/null | tr -d '\r' | grep '^X-Content-Type-Options:')" "X-Content-Type-Options: nosniff" | ||
} |