generated from daos-stack/actions-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Brian J. Murrell <[email protected]>
- Loading branch information
1 parent
e938fe1
commit 26575d0
Showing
10 changed files
with
263 additions
and
0 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,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_* |
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,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/[email protected] | ||
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 |
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,36 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Test | ||
id: test | ||
uses: ./ | ||
with: | ||
commit-message: | | ||
Use external action | ||
Run-GHA: true | ||
Skip-PR-comments: true | ||
Test-tag: always_passes,vm | ||
Required-githooks: true | ||
Signed-off-by: Brian J. Murrell <[email protected]> | ||
- name: Test value | ||
run: | | ||
set -eux | ||
if [ '${{ env.CP_TEST_TAG }}' != 'always_passes,vm' ]; then | ||
echo "Value is not 'always_passes,vm'" | ||
exit 1 | ||
fi |
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,51 @@ | ||
Copyright 2021-2022 Intel Corporation. | ||
|
||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
Subject to the terms and conditions of this license, each copyright holder | ||
and contributor hereby grants to those receiving rights under this license | ||
a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable | ||
(except for failure to satisfy the conditions of this license) patent | ||
license to make, have made, use, offer to sell, sell, import, and otherwise | ||
transfer this software, where such license applies only to those patent | ||
claims, already acquired or hereafter acquired, licensable by such copyright | ||
holder or contributor that are necessarily infringed by: | ||
|
||
(a) their Contribution(s) (the licensed copyrights of copyright holders and | ||
non-copyrightable additions of contributors, in source or binary form) | ||
alone; or | ||
|
||
(b) combination of their Contribution(s) with the work of authorship to | ||
which such Contribution(s) was added by such copyright holder or | ||
contributor, if, at the time the Contribution is added, such addition | ||
causes such combination to be necessarily infringed. The patent license | ||
shall not apply to any other combinations which include the | ||
Contribution. | ||
|
||
Except as expressly stated above, no rights or licenses from any copyright | ||
holder or contributor is granted under this license, whether expressly, by | ||
implication, estoppel or otherwise. | ||
|
||
DISCLAIMER | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE | ||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. |
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 @@ | ||
A GitHub Action to get the pragmas from a commit and import them into the environment prefixed with `CP_`. |
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,5 @@ | ||
# Security Policy | ||
Intel is committed to rapidly addressing security vulnerabilities affecting our customers and providing clear guidance on the solution, impact, severity and mitigation. | ||
|
||
## Reporting a Vulnerability | ||
Please report any security vulnerabilities in this project utilizing the guidelines [here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html). |
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,25 @@ | ||
name: 'Import Commit Pragmas' | ||
description: 'Import Commit Pragmas' | ||
inputs: | ||
commit-message: | ||
description: 'Commit Message' | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
# checkout the common library | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: daos-stack/actions-lib | ||
ref: v1 | ||
path: actions-lib | ||
- name: Import pragmas | ||
id: import | ||
shell: bash | ||
run: | | ||
set -eu | ||
echo '${{ inputs.commit-message }}' | sed -e "s/'/'\"'\"'/g" | actions-lib/get_commit_pragmas | | ||
sed -e 's/^/CP_/' >> $GITHUB_ENV | ||
echo 'Identified pragmas:' | ||
cat $GITHUB_ENV |
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,16 @@ | ||
#!/bin/bash | ||
|
||
# NOTE: This is not actually used yet. | ||
# Consumers of this function are getting it from actions-lib/gha_functions.sh until we can DRY the consumers out | ||
# This will require one consumer to import a commit message and dequote it for all other users which is tricky | ||
# due to the potential presence of both ' and " in commit messages | ||
set -eu | ||
|
||
sed -Ene "s/'/'\"'\"'/g" \ | ||
-e '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 | | ||
sed -e 's/^/CP_/' |
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,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 | ||
} | ||
] | ||
} | ||
] | ||
} |
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,53 @@ | ||
#!/bin/bash | ||
|
||
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 <[email protected]> | ||
' | ||
assert_equals "$(echo "$msg" | ../get_commit_pragmas)" 'CP_RUN_GHA=true | ||
CP_SKIP_PR_COMMENTS=true | ||
CP_TEST_TAG=always_passes,vm | ||
CP_REQUIRED_GITHOOKS=true | ||
CP_SIGNED_OFF_BY=Brian\ J.\ Murrell\ \<[email protected]\>' | ||
|
||
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 <[email protected]> | ||
' | ||
assert_equals "$(echo "$msg" | ../get_commit_pragmas)" 'CP_SHOULD_NOT_BE_A_PRAGMA=bar\ will\ be\ because\ it\ was\ not\ quoted. | ||
CP_SKIP_FUNC_TEST_LEAP15=false | ||
CP_RPM_TEST_VERSION=2.5.100-13.10036.g65926e32 | ||
CP_SKIP_PR_COMMENTS=true | ||
CP_TEST_TAG=always_passes\ always_fails | ||
CP_EL8_VM9_LABEL=all_vm9 | ||
CP_EL9_VM9_LABEL=all_vm9 | ||
CP_LEAP15_VM9_LABEL=all_vm9 | ||
CP_HW_MEDIUM_LABEL=new_icx5 | ||
CP_HW_LARGE_LABEL=new_icx9 | ||
CP_REQUIRED_GITHOOKS=true | ||
CP_SIGNED_OFF_BY=Brian\ J.\ Murrell\ \<[email protected]\>' | ||
|
||
} |