Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
Signed-off-by: Brian J. Murrell <brian.murrell@intel.com>
  • Loading branch information
brianjmurrell committed Jul 9, 2024
1 parent a1aa731 commit 82c24f5
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Have Release Engineering added as a reviewer to any GitHub Actions
* @daos-stack/actions-watchers
18 changes: 18 additions & 0 deletions .github/workflows/bash_unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: bash_unit Tests
on:
push:
branches:
- master
pull_request:

jobs:
bash-unit-testing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Unit testing with bash_unit
run: |
curl -s https://raw.githubusercontent.com/pgrange/bash_unit/master/install.sh | bash
FORCE_COLOR=true ./bash_unit tests/test_*
41 changes: 41 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Linting

# Always run on Pull Requests as then these checks can be marked as required.
on:
push:
branches:
- master
pull_request:

permissions: {}

jobs:
shell-check:
name: ShellCheck
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Add error parser
run: echo -n "::add-matcher::shellcheck-matcher.json"
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@2.0.0
with:
format: gcc

linting-summary:
name: Linting Summary
runs-on: ubuntu-22.04
needs: [shell-check]
if: (!cancelled())
steps:
- name: Check if any job failed
run: |
if [[ -z "$(echo "${{ join(needs.*.result, '') }}" | sed -e 's/success//g')" ]]; then
echo "All jobs succeeded"
else
echo "One or more jobs did not succeed"
exit 1
fi
7 changes: 7 additions & 0 deletions get_commit_pragmas
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

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'
done
17 changes: 17 additions & 0 deletions shellcheck-matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"problemMatcher": [
{
"owner": "shellcheck-problem-matcher",
"severity": "error",
"pattern": [
{
"regexp": "^(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error|note):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"message": 5
}
]
}
]
}
55 changes: 55 additions & 0 deletions tests/test_get_commit_pragmas
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

set -eu

test_get_commit_pragmas() {
local msg='Use external action
Run-GHA: true
Skip-PR-comments: true
Test-tag: always_passes,vm
Required-githooks: true
Signed-off-by: Brian J. Murrell <brian.murrell@intel.com>
'
assert_equals "$(echo "$msg" | ../get_commit_pragmas)" 'RUN_GHA=true
SKIP_PR_COMMENTS=true
TEST_TAG=always_passes,vm
REQUIRED_GITHOOKS=true
SIGNED_OFF_BY=Brian\ J.\ Murrell\ \<brian.murrell@intel.com\>'

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
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 <brian.murrell@intel.com>
'
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\ \<brian.murrell@intel.com\>'

}

0 comments on commit 82c24f5

Please sign in to comment.