From 48aa88c0cabd587c1d1fa90501cac5009342d513 Mon Sep 17 00:00:00 2001 From: Soren Ptak Date: Thu, 19 Oct 2023 10:13:34 -0700 Subject: [PATCH] Action File Formatting Updates (#85) * Update the actions to use 2 spaces for tabs instead of 4. Small tweaks to clang-formatting action file to make it identical to the uncrustify one * Update one of the manifest-verifier debug print statements to make more sense * Update the memory statistics action to use echo groups, change the check for if it runs to be a github workflow step check * Update the spell check to run silently so it doesn't flood the log with the line of each file. Relevant for use in large repos where this could run against thousands of files * Use echo groups for doxygen action --- clang-formatting/action.yml | 269 +++++++++++++-------------- complexity/action.yml | 70 +++---- coverage-cop/action.yml | 179 +++++++++--------- doxygen/action.yml | 29 ++- executable-monitor/action.yml | 138 +++++++------- formatting-bot/action.yml | 4 +- formatting/action.yml | 263 +++++++++++++------------- link-verifier/action.yml | 160 ++++++++-------- localhost-echo-server/action.yml | 11 +- localhost-http-1.1-server/action.yml | 13 +- localhost-mqtt-broker/action.yml | 12 +- manifest-verifier/action.yml | 86 ++++----- memory_statistics/action.yml | 68 +++++-- rust-spell-check/action.yml | 242 ++++++++++++------------ sbom-generator/action.yml | 17 +- spellings/action.yml | 202 ++++++++++---------- ssl-credential-creator/action.yml | 66 +++---- 17 files changed, 941 insertions(+), 888 deletions(-) diff --git a/clang-formatting/action.yml b/clang-formatting/action.yml index 2df59784..78b72c2d 100644 --- a/clang-formatting/action.yml +++ b/clang-formatting/action.yml @@ -18,140 +18,135 @@ inputs: runs: using: "composite" steps: - - env: - # At time of writing, you can't add a global environment - # to an action file so stuck with this. If this gets changed - # Please move this - bashPass: \033[32;1mPASSED - - bashInfo: \033[33;1mINFO - - bashFail: \033[31;1mFAILED - - bashEnd: \033[0m - stepName: Install Clang Format - name: ${{ env.stepName }} - shell: bash - run: | - # ${{ env.stepName }} - echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" - sudo apt-get install clang-format fd-find dos2unix - echo "$GITHUB_ACTION_PATH" >> $GITHUB_PATH - export PATH="$PATH:$GITHUB_ACTION_PATH" - - fdfind --version - fdInstalled=$? - - clang-format --version - clangFormatInstalled=$? - - echo -e "::endgroup::" - echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" - - - env: - bashPass: \033[32;1mPASSED - - bashInfo: \033[33;1mINFO - - bashFail: \033[31;1mFAILED - - bashEnd: \033[0m - stepName: Formatting Check - name: ${{ env.stepName }} - id: action-formatting-check - working-directory: ${{ inputs.path }} - shell: bash - run: | - # ${{ env.stepName }} - echo -e "${{ env.bashInfo }} Using clang-format Version "$(clang-format --version)" ${{ env.bashEnd }}" - - exitCode=0 - export PATH="$PATH:$GITHUB_ACTION_PATH" - - # TODO: These checks should really only run against modified files on PRS - # Where when the commit to the actual repo happens, then we should trigger the job - # Against all of the files in the repo. That way we can keep checks fast for PRs, - # and maintain that we don't have a change in the Repo. - # Think this can be done with git clang-format: - # https://ortogonal.github.io/cpp/git-clang-format/ - - # Parse the optional inputs - args="" - - # fd-find uses -E to exclude a file or directory - if [ -n "${{ inputs.exclude-dirs }}" ]; then - dirs=" -E " - dirs+="${{ inputs.exclude-dirs }}" - dirs="${dirs//,/ -E }" - args+=" ${dirs}" - fi - - # fd-find uses -E to exclude a file or directory - if [ -n "${{ inputs.exclude-files }}" ]; then - files=" -E " - files+="${{ inputs.exclude-files }}" - files="${files//,/ -E }" - args+=" ${files}" - fi - - # fd-find uses -e to include a file extension - if [ -n "${{ inputs.include-file-types }}" ]; then - file_types=" -e " - file_types+="${{ inputs.include-file-types }}" - file_types="${file_types//,/ -e }" - args+=" ${file_types}" - fi - - # Get all .c and .h files, as well as any other requested file types. - # Then run clang-format with the common config file. - echo -e "::group::${{ env.bashInfo }} Check Formatting ${{ env.bashEnd }}" - echo -e "${{ env.bashInfo }} fdfind -e c -e h ${args} --exec clang-format -i ${{ env.bashEnd }}" - fdfind -e c -e h ${args} --exec clang-format --verbose -i - - # Replace all trailing whitespace, exclude photo and binary files - echo -e "${{ env.bashInfo }} Check for Trailing Whitespace ${{ env.bashEnd }}" - echo -e "${{ env.bashInfo }} fdfind --type=file -E '*.png' -E '*.jpg' -E '*.svg' -E '*.a' -E '*.lib' -E '*.patch' ${args} . --exec sed -Ei 's/[[:blank:]]+$//' ${{ env.bashEnd }}" - fdfind --type=file -E '*.png' -E '*.jpg' -E '*.svg' -E '*.a' -E '*.lib' -E '*.patch' ${args} . --exec sed -Ei 's/[[:blank:]]+$//' - - # Replace all line endings with LF ones instead of CRLF - echo -e "${{ env.bashInfo }} Check for CRLF Line Endings ${{ env.bashEnd }}" - echo -e "${{ env.bashInfo }} fdfind --type=file ${args} . --exec dos2unix ${{ env.bashEnd }}" - fdfind --type=file ${args} . --exec dos2unix -q - - # Determine if there was a formatting diff. - # If there was, create a patch of it. - set +e - git diff --exit-code >> formattingChanges.patch - exitCode=$? - set -e - - if [ $exitCode -eq 0 ]; then - echo -e "::endgroup::" - echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" - else - # Run a git diff to print the formatting differences - echo -e "::group::${{ env.bashInfo }} Format Difference ${{ env.bashEnd }}" - git diff --color=always - echo -e "::endgroup::${{ env.bashFail }} List of files with formatting errors: ${{ env.bashEnd }}" - echo -e "${{ env.bashFail }} "$(git diff --name-only)" ${{ env.bashEnd }} " - echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}" - fi - exit $exitCode - - - name: Upload Formatting Git Patch - if: failure() && ( steps.action-formatting-check.outcome == 'failure' ) - id: upload-formatting-patch - uses: actions/upload-artifact@v3 - with: - name: formattingChanges - path: ${{ inputs.path }}/formattingChanges.patch - retention-days: 7 - - - env: - stepName: Formatting Git Patch Info - bashPass: \033[32;1m - bashInfo: \033[33;1m - bashFail: \033[31;1m - bashEnd: \033[0 - if: failure() && ( steps.upload-formatting-patch.outcome == 'success' ) - shell: bash - run: | - # ${{ env.stepName }} - echo -e "${{ env.bashInfo }} A git patch of the formatting issues has been attached to this workflow ${{ env.bashEnd }}" - echo -e "${{ env.bashInfo }} This can be accessed by returning to the bottom of the summary page of the workflow run ${{ env.bashEnd }}" - echo -e "${{ env.bashInfo }} At the bottom of the page will be a formattingChanges.patch file that you can download ${{ env.bashEnd }}" - echo -e "${{ env.bashInfo }} Copy this patch to your repository and apply it using 'git apply formattingChanges.patch' ${{ env.bashEnd }}" + - env: + # At time of writing, you can't add a global environment + # to an action file so stuck with this. If this gets changed + # Please move this + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + stepName: Install Clang Format + name: ${{ env.stepName }} + shell: bash + run: | + # ${{ env.stepName }} + echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" + + sudo apt-get install clang-format fd-find dos2unix + echo "$GITHUB_ACTION_PATH" >> $GITHUB_PATH + export PATH="$PATH:$GITHUB_ACTION_PATH" + + # Check that the commands installed correctly + fdfind --version + echo -e "::endgroup::" + + echo -e "${{ env.bashInfo }} Using clang-format Version "$(clang-format --version)" ${{ env.bashEnd }}" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + + - env: + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + stepName: Formatting Check + name: ${{ env.stepName }} + id: action-formatting-check + working-directory: ${{ inputs.path }} + shell: bash + run: | + # ${{ env.stepName }} + echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" + + exitCode=0 + export PATH="$PATH:$GITHUB_ACTION_PATH" + + # Parse the optional inputs + args="" + + # fd-find uses -E to exclude a file or directory + if [ -n "${{ inputs.exclude-dirs }}" ]; then + dirs=" -E " + dirs+="${{ inputs.exclude-dirs }}" + dirs="${dirs//,/ -E }" + args+=" ${dirs}" + fi + + # fd-find uses -E to exclude a file or directory + if [ -n "${{ inputs.exclude-files }}" ]; then + files=" -E " + files+="${{ inputs.exclude-files }}" + files="${files//,/ -E }" + args+=" ${files}" + fi + + # fd-find uses -e to include a file extension + if [ -n "${{ inputs.include-file-types }}" ]; then + file_types=" -e " + file_types+="${{ inputs.include-file-types }}" + file_types="${file_types//,/ -e }" + args+=" ${file_types}" + fi + + # Get all .c and .h files, as well as any other requested file types. + # Then run clang-format with the common config file. + + echo -e "${{ env.bashInfo }} fdfind -e c -e h ${args} --exec clang-format -i ${{ env.bashEnd }}" + fdfind -e c -e h ${args} --exec clang-format --verbose -i + + # Replace all trailing whitespace, exclude photo and binary files + echo -e "${{ env.bashInfo }} Check for Trailing Whitespace ${{ env.bashEnd }}" + echo -e "${{ env.bashInfo }} fdfind --type=file -E '*.png' -E '*.jpg' -E '*.svg' -E '*.a' -E '*.lib' -E '*.patch' ${args} . --exec sed -Ei 's/[[:blank:]]+$//' ${{ env.bashEnd }}" + fdfind --type=file -E '*.png' -E '*.jpg' -E '*.svg' -E '*.a' -E '*.lib' -E '*.patch' ${args} . --exec sed -Ei 's/[[:blank:]]+$//' + + # Replace all line endings with LF ones instead of CRLF + echo -e "${{ env.bashInfo }} Check for CRLF Line Endings ${{ env.bashEnd }}" + echo -e "${{ env.bashInfo }} fdfind --type=file ${args} . --exec dos2unix ${{ env.bashEnd }}" + fdfind --type=file ${args} . --exec dos2unix -q + + # Determine if there was a formatting diff. + # If there was, create a patch of it. + set +e + git diff --exit-code >> formattingChanges.patch + exitCode=$? + set -e + + if [ $exitCode -eq 0 ]; then + echo -e "::endgroup::" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + else + # Run a git diff to print the formatting differences + echo -e "::group::${{ env.bashInfo }} Format Difference ${{ env.bashEnd }}" + git diff --color=always + echo -e "::endgroup::" + echo -e "${{ env.bashFail }} List of files with formatting errors: ${{ env.bashEnd }}" + echo -e "${{ env.bashFail }} "$(git diff --name-only)" ${{ env.bashEnd }} " + echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}" + fi + exit $exitCode + + - name: Upload Formatting Git Patch + if: failure() && ( steps.action-formatting-check.outcome == 'failure' ) + id: upload-formatting-patch + uses: actions/upload-artifact@v3 + with: + name: formattingChanges + path: ${{ inputs.path }}/formattingChanges.patch + retention-days: 7 + + - env: + bashPass: \033[32;1m + bashInfo: \033[33;1m + bashFail: \033[31;1m + bashEnd: \033[0 + stepName: Formatting Git Patch Info + name: ${{ env.stepName }} + if: failure() && ( steps.upload-formatting-patch.outcome == 'success' ) + shell: bash + run: | + # ${{ env.stepName }} + echo -e "${{ env.bashInfo }} A git patch of the formatting issues has been attached to this workflow ${{ env.bashEnd }}" + echo -e "${{ env.bashInfo }} This can be accessed by returning to the bottom of the summary page of the workflow run ${{ env.bashEnd }}" + echo -e "${{ env.bashInfo }} At the bottom of the page will be a formattingChanges.zip file that you can download. ${{ env.bashEnd }}" + echo -e "${{ env.bashInfo }} Extract the 'formattingChanges.patch' file inside of it, and copy it to your repository. ${{ env.bashEnd }}" + echo -e "${{ env.bashInfo }} From here you can apply it using 'git apply formattingChanges.patch', fixing your formatting issues. ${{ env.bashEnd }}" diff --git a/complexity/action.yml b/complexity/action.yml index c0a3c277..50b2a3d9 100644 --- a/complexity/action.yml +++ b/complexity/action.yml @@ -17,41 +17,41 @@ inputs: runs: using: "composite" steps: + - env: + stepName: Install Dependencies + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0 + name: ${{ env.stepName }} + shell: bash + run: | + # ${{ env.stepName }} + echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" + sudo apt-get install complexity -y + echo -e "::endgroup::" + echo -e "${{ env.bashPass }} ${{env.stepName }} ${{ env.bashEnd }}" - - env: - stepName: Install Dependencies - bashPass: \033[32;1mPASSED - - bashInfo: \033[33;1mINFO - - bashFail: \033[31;1mFAILED - - bashEnd: \033[0 - name: ${{ env.stepName }} - shell: bash - run: | - # ${{ env.stepName }} - echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" - sudo apt-get install complexity -y - echo -e "::endgroup::" - echo -e "${{ env.bashPass }} ${{env.stepName }} ${{ env.bashEnd }}" + - env: + stepName: Complexity + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + name: ${{ env.stepName }} + working-directory: ${{ inputs.path }} + shell: bash + run: | + # ${{ env.stepName }} + echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" + echo -e "${{ env.bashInfo }} Have complexity limit of ${{ inputs.horrid_threshold }} ${{ env.bashEnd }}" + exitStatus=0 - - env: - stepName: Complexity - bashPass: \033[32;1mPASSED - - bashInfo: \033[33;1mINFO - - bashFail: \033[31;1mFAILED - - bashEnd: \033[0m - working-directory: ${{ inputs.path }} - shell: bash - run: | - # ${{ env.stepName }} - echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" - echo -e "${{ env.bashInfo }} Have complexity limit of ${{ inputs.horrid_threshold }} ${{ env.bashEnd }}" - exitStatus=0 + # Use find to find all files ending with a .c inside of the input directory + # From there run the complexity check against them + find ${{ inputs.source_path }}/ -iname '*.c' |\ + xargs complexity --scores --threshold=0 --horrid-threshold=${{ inputs.horrid_threshold }} - # Use find to find all files ending with a .c inside of the input directory - # From there run the complexity check against them - find ${{ inputs.source_path }}/ -iname '*.c' |\ - xargs complexity --scores --threshold=0 --horrid-threshold=${{ inputs.horrid_threshold }} - - echo -e "::endgroup::" - echo -e "${{ env.bashPass }} ${{env.stepName }} ${{ env.bashEnd }}" - exit 0 + echo -e "::endgroup::" + echo -e "${{ env.bashPass }} ${{env.stepName }} ${{ env.bashEnd }}" + exit 0 diff --git a/coverage-cop/action.yml b/coverage-cop/action.yml index 98b21552..3bb61798 100644 --- a/coverage-cop/action.yml +++ b/coverage-cop/action.yml @@ -15,92 +15,93 @@ inputs: runs: using: "composite" steps: - - env: - stepName: Install Dependencies - bashPass: \033[32;1mPASSED - - bashInfo: \033[33;1mINFO - - bashFail: \033[31;1mFAILED - - bashEnd: \033[0 - shell: bash - name: ${{ env.stepName }} - run: | - # ${{ env.stepName }} - echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" - sudo apt-get install lcov fd-find - echo -e "::endgroup::" - echo -e "${{ env.bashPass }} ${{env.stepName }} ${{ env.bashEnd }}" + - env: + stepName: Install Dependencies + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0 + name: ${{ env.stepName }} + shell: bash + run: | + # ${{ env.stepName }} + echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" + sudo apt-get install lcov fd-find + echo -e "::endgroup::" + echo -e "${{ env.bashPass }} ${{env.stepName }} ${{ env.bashEnd }}" - - env: - stepName: Check Line and Branch Coverage - bashPass: \033[32;1mPASSED - - bashInfo: \033[33;1mINFO - - bashFail: \033[31;1mFAILED - - bashEnd: \033[0 - name: ${{ env.stepName }} - id: action-check-line-and-branch-coverage - shell: bash - run: | - # ${{ env.stepName }} + - env: + stepName: Check Line and Branch Coverage + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0 + name: ${{ env.stepName }} + id: action-check-line-and-branch-coverage + shell: bash + run: | + # ${{ env.stepName }} - # Print the received code cov report. - # TODO: The way it grabs the line/branch coverage is a little complicated - # I'd like to see if this can be done simpler. - echo -e " ${{ env.bashInfo }} Received LCov Report: ${{ inputs.line-coverage-min }} ${{ env.bashEnd}}" - lcov --list --rc lcov_branch_coverage=1 ${{ inputs.coverage-file }} - LINE_COVERAGE=$(lcov --list ${{ inputs.coverage-file }} | tail -n 1 | cut -d '|' -f 2 | sed -n "s/\([^%]*\)%.*/\1/p") - BRANCH_COVERAGE=$(lcov --rc lcov_branch_coverage=1 --list ${{ inputs.coverage-file }} | tail -n 1 | cut -d '|' -f 4 | sed -n "s/\([^%]*\)%.*/\1/p") - RESULT=0 + # Print the received code cov report. + # TODO: The way it grabs the line/branch coverage is a little complicated + # I'd like to see if this can be done simpler. + echo -e " ${{ env.bashInfo }} Received LCov Report: ${{ inputs.coverage-file }} ${{ env.bashEnd}}" + lcov --list --rc lcov_branch_coverage=1 ${{ inputs.coverage-file }} + LINE_COVERAGE=$(lcov --list ${{ inputs.coverage-file }} | tail -n 1 | cut -d '|' -f 2 | sed -n "s/\([^%]*\)%.*/\1/p") + BRANCH_COVERAGE=$(lcov --rc lcov_branch_coverage=1 --list ${{ inputs.coverage-file }} | tail -n 1 | cut -d '|' -f 4 | sed -n "s/\([^%]*\)%.*/\1/p") + RESULT=0 - # Check Line Coverage - echo -e " ${{ env.bashInfo }} Required Line Coverage: ${{ inputs.line-coverage-min }} ${{ env.bashEnd}}" - echo -e " ${{ env.bashInfo }} Received Line Coverage: $LINE_COVERAGE ${{ env.bashEnd}}" - if [[ $(echo "$LINE_COVERAGE < ${{ inputs.line-coverage-min }}" | bc) -ne 0 ]]; then - echo -e "${{ env.bashFail }} Line Coverage is too low. ${{ env.bashEnd }}" - RESULT=1 - fi + # Check Line Coverage + echo -e " ${{ env.bashInfo }} Required Line Coverage: ${{ inputs.line-coverage-min }} ${{ env.bashEnd}}" + echo -e " ${{ env.bashInfo }} Line Coverage of PR: $LINE_COVERAGE ${{ env.bashEnd}}\n" + if [[ $(echo "$LINE_COVERAGE < ${{ inputs.line-coverage-min }}" | bc) -ne 0 ]]; then + echo -e "${{ env.bashFail }} Line Coverage is too low. ${{ env.bashEnd }}" + RESULT=1 + fi - echo -e " ${{ env.bashInfo }} Required Branch Coverage: ${{ inputs.branch-coverage-min }} ${{ env.bashEnd}}" - echo -e " ${{ env.bashInfo }} Received Branch Coverage: $BRANCH_COVERAGE ${{ env.bashEnd}}" - if [[ $(echo "$BRANCH_COVERAGE < ${{ inputs.branch-coverage-min }}" | bc) -ne 0 ]]; then - echo -e "${{ env.bashFail }} Branch Coverage is too low. ${{ env.bashEnd }}" - RESULT=1 - fi + echo -e " ${{ env.bashInfo }} Required Branch Coverage: ${{ inputs.branch-coverage-min }} ${{ env.bashEnd}}" + echo -e " ${{ env.bashInfo }} Line Coverage of PR: $BRANCH_COVERAGE ${{ env.bashEnd}}" + if [[ $(echo "$BRANCH_COVERAGE < ${{ inputs.branch-coverage-min }}" | bc) -ne 0 ]]; then + echo -e "${{ env.bashFail }} Branch Coverage is too low. ${{ env.bashEnd }}" + RESULT=1 + fi - if [ $RESULT -eq 0 ]; then - echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" - else - echo -e "::group::Create Failed Codecov HTML Report" - genhtml --rc lcov_branch_coverage=1 --ignore-errors source ${{ inputs.coverage-file }} --legend --title "$(basename `git rev-parse --show-toplevel`) $(git rev-parse HEAD)" --output-directory=CodecovHTMLReport - zip -r CodecovHTMLReport.zip CodecovHTMLReport - echo -e "::endgroup::" - echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}" - fi - exit $RESULT + if [ $RESULT -eq 0 ]; then + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + else + echo -e "::group::Create Failed Codecov HTML Report" + genhtml --rc lcov_branch_coverage=1 --ignore-errors source ${{ inputs.coverage-file }} --legend --title "$(basename `git rev-parse --show-toplevel`) $(git rev-parse HEAD)" --output-directory=CodecovHTMLReport + zip -r CodecovHTMLReport.zip CodecovHTMLReport + echo -e "::endgroup::" + echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}" + fi + exit $RESULT - - name: Upload Failed Codecov HTML Report - if: failure() && ( steps.action-check-line-and-branch-coverage.outcome == 'failure' ) - id: upload-codecov-report - uses: actions/upload-artifact@v3 - with: - name: CodecovHTMLReport - path: CodecovHTMLReport.zip - retention-days: 5 + - name: Upload Failed Codecov HTML Report + if: failure() && ( steps.action-check-line-and-branch-coverage.outcome == 'failure' ) + id: upload-codecov-report + uses: actions/upload-artifact@v3 + with: + name: CodecovHTMLReport + path: CodecovHTMLReport.zip + retention-days: 5 - - env: - stepName: Codecov Report Info - bashPass: \033[32;1m - bashInfo: \033[33;1m - bashFail: \033[31;1m - bashEnd: \033[0 - if: failure() && ( steps.upload-codecov-report.outcome == 'success' ) - shell: bash - run: | - # ${{ env.stepName }} - echo -e "${{ env.bashInfo }} A zip file of the failed Codecov report has been attached to this workflow ${{ env.bashEnd }}" - echo -e "${{ env.bashInfo }} This can be accessed by returning to the bottom of the summary page of the workflow run ${{ env.bashEnd }}" - echo -e "${{ env.bashInfo }} At the bottom of the page will be a CodecovHTMLReport.zip file that you can download ${{ env.bashEnd }}" - echo -e "${{ env.bashInfo }} Unzip the file and then open the index.html file in your browser for more info missing branch and line coverage ${{ env.bashEnd }}" - exit 1 + - env: + stepName: Codecov Report Info + bashPass: \033[32;1m + bashInfo: \033[33;1m + bashFail: \033[31;1m + bashEnd: \033[0 + name: ${{ env.stepName }} + if: failure() && ( steps.upload-codecov-report.outcome == 'success' ) + shell: bash + run: | + # ${{ env.stepName }} + echo -e "${{ env.bashInfo }} A zip file of the failed Codecov report has been attached to this workflow ${{ env.bashEnd }}" + echo -e "${{ env.bashInfo }} This can be accessed by returning to the bottom of the summary page of the workflow run ${{ env.bashEnd }}" + echo -e "${{ env.bashInfo }} At the bottom of the page will be a CodecovHTMLReport.zip file that you can download ${{ env.bashEnd }}" + echo -e "${{ env.bashInfo }} Unzip the file and then open the index.html file in your browser for more info missing branch and line coverage ${{ env.bashEnd }}" + exit 1 @@ -111,13 +112,13 @@ runs: # CorePKCS11 evidently has this, but I don't know who set that up or what approvals it took # So For now I'm going to create the html report and add it to the run. # More info here: https://about.Codecov.io/blog/how-to-set-up-Codecov-with-c-and-github-actions/ -# - env: -# stepName: Upload Line and Branch Report -# name: ${{ env.stepName }} -# if: failure() -# uses: Codecov/Codecov-action@v3 -# with: -# files: ${{ inputs.coverage-file }} -# flags: unit_tests -# fail_ci_if_error: false -# verbose: false +# - env: +# stepName: Upload Line and Branch Report +# name: ${{ env.stepName }} +# if: failure() +# uses: Codecov/Codecov-action@v3 +# with: +# files: ${{ inputs.coverage-file }} +# flags: unit_tests +# fail_ci_if_error: false +# verbose: false diff --git a/doxygen/action.yml b/doxygen/action.yml index d29ce214..73e7d310 100644 --- a/doxygen/action.yml +++ b/doxygen/action.yml @@ -25,18 +25,39 @@ inputs: runs: using: "composite" steps: - - name: Install Doxygen + - env: + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + stepName: Install Doxygen + name: ${{ env.stepName }} + shell: bash run: | + # ${{ env.stepName }} + echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" wget -qO- "${{ inputs.doxygen_link }}" | sudo tar --strip-components=1 -xz -C /usr/local sudo apt-get install -y ${{ inputs.doxygen_dependencies }} - shell: bash - - name: Verify Doxygen build and Generate ZIP (if specified) + echo -e "::endgroup::" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + + - env: + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + stepName: Verify Doxygen build and Generate ZIP (if specified) + name: ${{ env.stepName }} working-directory: ${{ inputs.path }} + shell: bash run: | + # ${{ env.stepName }} + echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" if [[ ${{ inputs.generate_zip }} == "true" ]]; then python3 $GITHUB_ACTION_PATH/generate_doxygen.py --root ./ --library-directories ${{ inputs.libs_parent_dir_path }} --zip else doxygen docs/doxygen/config.doxyfile 2>&1 | tee doxyoutput.txt if [[ "$(wc -c < doxyoutput.txt | bc)" = "0" ]]; then exit 0; else exit 1; fi fi - shell: bash + echo -e "::endgroup::" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" diff --git a/executable-monitor/action.yml b/executable-monitor/action.yml index 467fb8ea..9cd10c91 100644 --- a/executable-monitor/action.yml +++ b/executable-monitor/action.yml @@ -25,83 +25,83 @@ inputs: runs: using: "composite" steps: - - env: - # The bash escape character is \033 - # At time of writing, you can't add a global environment to an - # action so stuck with this. If this gets changed please move this - bashPass: \033[32;1mPASSED - - bashInfo: \033[33;1mINFO - - bashFail: \033[31;1mFAILED - - bashEnd: \033[0m - stepName: Install Dependencies - name: ${{ env.stepName }} - shell: bash - run: | - # ${{ env.stepName }} - echo -e "::group::Install Dependencies" - pip install -r $GITHUB_ACTION_PATH/requirements.txt - exitStatus=$? - echo -e "::endgroup::" - echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + - env: + # The bash escape character is \033 + # At time of writing, you can't add a global environment to an + # action so stuck with this. If this gets changed please move this + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + stepName: Install Dependencies + name: ${{ env.stepName }} + shell: bash + run: | + # ${{ env.stepName }} + echo -e "::group::Install Dependencies" + pip install -r $GITHUB_ACTION_PATH/requirements.txt + exitStatus=$? + echo -e "::endgroup::" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" - - env: - bashPass: \033[32;1mPASSED - - bashInfo: \033[33;1mINFO - - bashFail: \033[31;1mFAILED - - bashEnd: \033[0m - stepName: Run Executable with Monitoring - name: ${{ env.stepName }} - shell: bash - run: | - # Run Executable with Monitoring - echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" + - env: + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + stepName: Run Executable with Monitoring + name: ${{ env.stepName }} + shell: bash + run: | + # Run Executable with Monitoring + echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" - # Make sure we have an exit condition to look for - if [ "${{ inputs.success-exit-code }}" = "" ] && [ "${{ inputs.success-line }}" = "" ]; then - echo -e "::endgroup::\n${{ env.bashFail}} Did not supply an input of success-line or success-exit-code to search for ${{ env.bashEnd }}" - exit 1 - fi + # Make sure we have an exit condition to look for + if [ "${{ inputs.success-exit-code }}" = "" ] && [ "${{ inputs.success-line }}" = "" ]; then + echo -e "::endgroup::\n${{ env.bashFail}} Did not supply an input of success-line or success-exit-code to search for ${{ env.bashEnd }}" + exit 1 + fi - # Initial Arguments - args="$GITHUB_ACTION_PATH/executable-monitor.py --exe-path=${{ inputs.exe-path }}" - args+=" --timeout-seconds=${{ inputs.timeout-seconds }}" + # Initial Arguments + args="$GITHUB_ACTION_PATH/executable-monitor.py --exe-path=${{ inputs.exe-path }}" + args+=" --timeout-seconds=${{ inputs.timeout-seconds }}" - # Check if an exit code was provided - if [ -n "${{ inputs.success-exit-code }}" ]; then - args+=" --success-exit-code=${{ inputs.success-exit-code }}" - fi + # Check if an exit code was provided + if [ -n "${{ inputs.success-exit-code }}" ]; then + args+=" --success-exit-code=${{ inputs.success-exit-code }}" + fi - # Check for log directory/if a log file should be created - if [ -n "${{ inputs.log-dir }}" ]; then - args+=" --log-dir=${{ inputs.log-dir}}" - fi + # Check for log directory/if a log file should be created + if [ -n "${{ inputs.log-dir }}" ]; then + args+=" --log-dir=${{ inputs.log-dir}}" + fi - # Check for retry attempts - if [ -n "${{ inputs.retry-attempts }}" ]; then - args+=" --retry-attempts=${{ inputs.retry-attempts }}" - fi + # Check for retry attempts + if [ -n "${{ inputs.retry-attempts }}" ]; then + args+=" --retry-attempts=${{ inputs.retry-attempts }}" + fi - # set +e so if the run fails we can capture that and print custom error message - set +e + # set +e so if the run fails we can capture that and print custom error message + set +e - # Check for success line to search for - if [ -n "${{ inputs.success-line }}" ]; then - echo -e "${{ env.bashInfo }} Running: python3 ${args} --success-line=${{ inputs.success-line}} ${{ env.bashEnd }}" - python3 ${args} --success-line="${{ inputs.success-line}}" - else - echo -e "${{ env.bashInfo }} Running: python3 ${args} ${{ env.bashEnd }}" - python3 ${args} - fi + # Check for success line to search for + if [ -n "${{ inputs.success-line }}" ]; then + echo -e "${{ env.bashInfo }} Running: python3 ${args} --success-line=${{ inputs.success-line}} ${{ env.bashEnd }}" + python3 ${args} --success-line="${{ inputs.success-line}}" + else + echo -e "${{ env.bashInfo }} Running: python3 ${args} ${{ env.bashEnd }}" + python3 ${args} + fi - # Store status as the echo group will overwrite it - exitStatus=$? - set -e - echo -e "::endgroup::" + # Store status as the echo group will overwrite it + exitStatus=$? + set -e + echo -e "::endgroup::" - if [ $exitStatus -eq 0 ]; then - echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" - else - echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}" - fi - exit $exitStatus + if [ $exitStatus -eq 0 ]; then + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + else + echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}" + fi + exit $exitStatus diff --git a/formatting-bot/action.yml b/formatting-bot/action.yml index 10fa7a8e..49338c8f 100644 --- a/formatting-bot/action.yml +++ b/formatting-bot/action.yml @@ -46,8 +46,8 @@ runs: - name: Checkout upstream repo uses: actions/checkout@v3 with: - repository: ${{ steps.pr-info.outputs.RemoteRepo }} - ref: ${{ steps.pr-info.outputs.branchName }} + repository: ${{ steps.pr-info.outputs.RemoteRepo }} + ref: ${{ steps.pr-info.outputs.branchName }} - name: Check Formatting uses: FreeRTOS/CI-CD-Github-Actions/formatting@main diff --git a/formatting/action.yml b/formatting/action.yml index a92c0fc8..e6371547 100644 --- a/formatting/action.yml +++ b/formatting/action.yml @@ -18,133 +18,136 @@ inputs: runs: using: "composite" steps: - - env: - # At time of writing, you can't add a global environment - # to an action file so stuck with this. If this gets changed - # Please move this - bashPass: \033[32;1mPASSED - - bashInfo: \033[33;1mINFO - - bashFail: \033[31;1mFAILED - - bashEnd: \033[0m - stepName: Install Uncrustify - name: ${{ env.stepName }} - shell: bash - run: | - # ${{ env.stepName }} - echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" - - sudo apt-get install uncrustify fd-find dos2unix - echo "$GITHUB_ACTION_PATH" >> $GITHUB_PATH - export PATH="$PATH:$GITHUB_ACTION_PATH" - - # Check that the commands installed correctly - fdfind --version - echo -e "::endgroup::" - echo -e "${{ env.bashInfo }} Using Uncrustify Version: "$(uncrustify --version)" ${{ env.bashEnd }}" - echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" - - - env: - bashPass: \033[32;1mPASSED - - bashInfo: \033[33;1mINFO - - bashFail: \033[31;1mFAILED - - bashEnd: \033[0m - stepName: Formatting Check - name: ${{ env.stepName }} - id: action-formatting-check - working-directory: ${{ inputs.path }} - shell: bash - run: | - # ${{ env.stepName }} - echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" - - exitCode=0 - export PATH="$PATH:$GITHUB_ACTION_PATH" - - # Parse the optional inputs - args="" - - # fd-find uses -E to exclude a file or directory - if [ -n "${{ inputs.exclude-dirs }}" ]; then - dirs=" -E " - dirs+="${{ inputs.exclude-dirs }}" - dirs="${dirs//,/ -E }" - args+=" ${dirs}" - fi - - # fd-find uses -E to exclude a file or directory - if [ -n "${{ inputs.exclude-files }}" ]; then - files=" -E " - files+="${{ inputs.exclude-files }}" - files="${files//,/ -E }" - args+=" ${files}" - fi - - # fd-find uses -e to include a file extension - if [ -n "${{ inputs.include-file-types }}" ]; then - file_types=" -e " - file_types+="${{ inputs.include-file-types }}" - file_types="${file_types//,/ -e }" - args+=" ${file_types}" - fi - - # Get all .c and .h files, as well as any other requested file types. - # Then run uncrustify with the common config file. - - echo -e "${{ env.bashInfo }} fdfind -e c -e h ${args} --exec uncrustify --no-backup --replace --if-changed -c https://github.com/FreeRTOS/CI-CD-Github-Actions/blob/main/formatting/uncrustify.cfg -l C ${{ env.bashEnd }}" - fdfind -e c -e h ${args} --exec uncrustify -q --no-backup --replace --if-changed -c $GITHUB_ACTION_PATH/uncrustify.cfg -l C - - # Replace all trailing whitespace, exclude photo and binary files - echo -e "${{ env.bashInfo }} Check for Trailing Whitespace ${{ env.bashEnd }}" - echo -e "${{ env.bashInfo }} fdfind --type=file -E '*.png' -E '*.jpg' -E '*.svg' -E '*.a' -E '*.lib' -E '*.patch' ${args} . --exec sed -Ei 's/[[:blank:]]+$//' ${{ env.bashEnd }}" - fdfind --type=file -E '*.png' -E '*.jpg' -E '*.svg' -E '*.a' -E '*.lib' -E '*.patch' ${args} . --exec sed -Ei 's/[[:blank:]]+$//' - - # Replace all line endings with LF ones instead of CRLF - echo -e "${{ env.bashInfo }} Check for CRLF Line Endings ${{ env.bashEnd }}" - echo -e "${{ env.bashInfo }} fdfind --type=file ${args} . --exec dos2unix ${{ env.bashEnd }}" - fdfind --type=file ${args} . --exec dos2unix -q - - # Determine if there was a formatting diff. - # If there was, create a patch of it. - set +e - git diff --exit-code >> formattingChanges.patch - exitCode=$? - set -e - - if [ $exitCode -eq 0 ]; then - echo -e "::endgroup::" - echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" - else - # Run a git diff to print the formatting differences - echo -e "::group::${{ env.bashInfo }} Format Difference ${{ env.bashEnd }}" - git diff --color=always - echo -e "::endgroup::${{ env.bashFail }} List of files with formatting errors: ${{ env.bashEnd }}" - echo -e "${{ env.bashFail }} "$(git diff --name-only)" ${{ env.bashEnd }} " - echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}" - fi - exit $exitCode - - - name: Upload Formatting Git Patch - if: failure() && ( steps.action-formatting-check.outcome == 'failure' ) - id: upload-formatting-patch - uses: actions/upload-artifact@v3 - with: - name: formattingChanges - path: ${{ inputs.path }}/formattingChanges.patch - retention-days: 7 - - - env: - stepName: Formatting Git Patch Info - bashPass: \033[32;1m - bashInfo: \033[33;1m - bashFail: \033[31;1m - bashEnd: \033[0 - if: failure() && ( steps.upload-formatting-patch.outcome == 'success' ) - shell: bash - run: | - # ${{ env.stepName }} - echo -e "${{ env.bashInfo }} A git patch of the formatting issues has been attached to this workflow ${{ env.bashEnd }}" - echo -e "${{ env.bashInfo }} This can be accessed by returning to the bottom of the summary page of the workflow run ${{ env.bashEnd }}" - echo -e "${{ env.bashInfo }} At the bottom of the page will be a formattingChanges.zip file that you can download. ${{ env.bashEnd }}" - echo -e "${{ env.bashInfo }} Extract the 'formattingChanges.patch' file inside of it, and copy it to your repository. ${{ env.bashEnd }}" - echo -e "${{ env.bashInfo }} From here you can apply it using 'git apply formattingChanges.patch', fixing your formatting issues. ${{ env.bashEnd }}" - echo -e "${{ env.bashInfo }} Or you can add the comment '/bot run formatting' on your Pull Request to have formatting changes automatically applied to your PR! ${{ env.bashEnd }}" + - env: + # At time of writing, you can't add a global environment + # to an action file so stuck with this. If this gets changed + # Please move this + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + stepName: Install Uncrustify + name: ${{ env.stepName }} + shell: bash + run: | + # ${{ env.stepName }} + echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" + + sudo apt-get install uncrustify fd-find dos2unix + echo "$GITHUB_ACTION_PATH" >> $GITHUB_PATH + export PATH="$PATH:$GITHUB_ACTION_PATH" + + # Check that the commands installed correctly + fdfind --version + echo -e "::endgroup::" + + echo -e "${{ env.bashInfo }} Using Uncrustify Version: "$(uncrustify --version)" ${{ env.bashEnd }}" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + + - env: + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + stepName: Formatting Check + name: ${{ env.stepName }} + id: action-formatting-check + working-directory: ${{ inputs.path }} + shell: bash + run: | + # ${{ env.stepName }} + echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" + + exitCode=0 + export PATH="$PATH:$GITHUB_ACTION_PATH" + + # Parse the optional inputs + args="" + + # fd-find uses -E to exclude a file or directory + if [ -n "${{ inputs.exclude-dirs }}" ]; then + dirs=" -E " + dirs+="${{ inputs.exclude-dirs }}" + dirs="${dirs//,/ -E }" + args+=" ${dirs}" + fi + + # fd-find uses -E to exclude a file or directory + if [ -n "${{ inputs.exclude-files }}" ]; then + files=" -E " + files+="${{ inputs.exclude-files }}" + files="${files//,/ -E }" + args+=" ${files}" + fi + + # fd-find uses -e to include a file extension + if [ -n "${{ inputs.include-file-types }}" ]; then + file_types=" -e " + file_types+="${{ inputs.include-file-types }}" + file_types="${file_types//,/ -e }" + args+=" ${file_types}" + fi + + # Get all .c and .h files, as well as any other requested file types. + # Then run uncrustify with the common config file. + + echo -e "${{ env.bashInfo }} fdfind -e c -e h ${args} --exec uncrustify --no-backup --replace --if-changed -c https://github.com/FreeRTOS/CI-CD-Github-Actions/blob/main/formatting/uncrustify.cfg -l C ${{ env.bashEnd }}" + fdfind -e c -e h ${args} --exec uncrustify -q --no-backup --replace --if-changed -c $GITHUB_ACTION_PATH/uncrustify.cfg -l C + + # Replace all trailing whitespace, exclude photo and binary files + echo -e "${{ env.bashInfo }} Check for Trailing Whitespace ${{ env.bashEnd }}" + echo -e "${{ env.bashInfo }} fdfind --type=file -E '*.png' -E '*.jpg' -E '*.svg' -E '*.a' -E '*.lib' -E '*.patch' ${args} . --exec sed -Ei 's/[[:blank:]]+$//' ${{ env.bashEnd }}" + fdfind --type=file -E '*.png' -E '*.jpg' -E '*.svg' -E '*.a' -E '*.lib' -E '*.patch' ${args} . --exec sed -Ei 's/[[:blank:]]+$//' + + # Replace all line endings with LF ones instead of CRLF + echo -e "${{ env.bashInfo }} Check for CRLF Line Endings ${{ env.bashEnd }}" + echo -e "${{ env.bashInfo }} fdfind --type=file ${args} . --exec dos2unix ${{ env.bashEnd }}" + fdfind --type=file ${args} . --exec dos2unix -q + + # Determine if there was a formatting diff. + # If there was, create a patch of it. + set +e + git diff --exit-code >> formattingChanges.patch + exitCode=$? + set -e + + if [ $exitCode -eq 0 ]; then + echo -e "::endgroup::" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + else + # Run a git diff to print the formatting differences + echo -e "::group::${{ env.bashInfo }} Format Difference ${{ env.bashEnd }}" + git diff --color=always + echo -e "::endgroup::" + echo -e "${{ env.bashFail }} List of files with formatting errors: ${{ env.bashEnd }}" + echo -e "${{ env.bashFail }} "$(git diff --name-only)" ${{ env.bashEnd }} " + echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}" + fi + exit $exitCode + + - name: Upload Formatting Git Patch + if: failure() && ( steps.action-formatting-check.outcome == 'failure' ) + id: upload-formatting-patch + uses: actions/upload-artifact@v3 + with: + name: formattingChanges + path: ${{ inputs.path }}/formattingChanges.patch + retention-days: 7 + + - env: + bashPass: \033[32;1m + bashInfo: \033[33;1m + bashFail: \033[31;1m + bashEnd: \033[0 + stepName: Formatting Git Patch Info + name: ${{ env.stepName }} + if: failure() && ( steps.upload-formatting-patch.outcome == 'success' ) + shell: bash + run: | + # ${{ env.stepName }} + echo -e "${{ env.bashInfo }} A git patch of the formatting issues has been attached to this workflow ${{ env.bashEnd }}" + echo -e "${{ env.bashInfo }} This can be accessed by returning to the bottom of the summary page of the workflow run ${{ env.bashEnd }}" + echo -e "${{ env.bashInfo }} At the bottom of the page will be a formattingChanges.zip file that you can download. ${{ env.bashEnd }}" + echo -e "${{ env.bashInfo }} Extract the 'formattingChanges.patch' file inside of it, and copy it to your repository. ${{ env.bashEnd }}" + echo -e "${{ env.bashInfo }} From here you can apply it using 'git apply formattingChanges.patch', fixing your formatting issues. ${{ env.bashEnd }}" + echo -e "${{ env.bashInfo }} Or you can add the comment '/bot run formatting' on your Pull Request to have formatting changes automatically applied to your PR! ${{ env.bashEnd }}" diff --git a/link-verifier/action.yml b/link-verifier/action.yml index b7b236ec..8136da6f 100644 --- a/link-verifier/action.yml +++ b/link-verifier/action.yml @@ -27,97 +27,97 @@ inputs: runs: using: "composite" steps: - - name: Setup Python for link verifier action - uses: actions/setup-python@v3 + - name: Setup Python for link verifier action + uses: actions/setup-python@v3 - - env: - # The bash escape character is \033 - # At time of writing, you can't add a global environment - # to an action file. If this gets changed please move this - bashPass: \033[32;1mPASSED - - bashInfo: \033[33;1mINFO - - bashFail: \033[31;1mFAILED - - bashEnd: \033[0m - stepName: Install Dependencies - name: ${{ env.stepName }} - shell: bash - run: | - # ${{ env.stepName }} - echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" + - env: + # The bash escape character is \033 + # At time of writing, you can't add a global environment + # to an action file. If this gets changed please move this + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + stepName: Install Dependencies + name: ${{ env.stepName }} + shell: bash + run: | + # ${{ env.stepName }} + echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" - wget https://github.com/jgm/pandoc/releases/download/2.11/pandoc-2.11-1-amd64.deb -O pandoc.deb - sudo dpkg -i pandoc.deb + wget https://github.com/jgm/pandoc/releases/download/2.11/pandoc-2.11-1-amd64.deb -O pandoc.deb + sudo dpkg -i pandoc.deb - rm pandoc.deb - sudo apt install debsums + rm pandoc.deb + sudo apt install debsums - sudo debsums pandoc - sudo type -p curl >/dev/null || sudo apt install curl -y - curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg - sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null + sudo debsums pandoc + sudo type -p curl >/dev/null || sudo apt install curl -y + curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg + sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null - sudo apt update - sudo apt install -y gh - sudo apt install pandoc -y - sudo apt-get install -y python3-setuptools python3-pip + sudo apt update + sudo apt install -y gh + sudo apt install pandoc -y + sudo apt-get install -y python3-setuptools python3-pip - python3 -m pip install -r $GITHUB_ACTION_PATH/requirements.txt + python3 -m pip install -r $GITHUB_ACTION_PATH/requirements.txt - echo -e "::endgroup::" - echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd}}" + echo -e "::endgroup::" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd}}" - - env: - bashPass: \033[32;1mPASSED - - bashInfo: \033[33;1mINFO - - bashFail: \033[31;1mFAILED - - bashEnd: \033[0m - stepName: Check Links in Files - name: ${{ env.stepName }} - working-directory: ${{ inputs.path }} - shell: bash - run: | - # ${{ env.stepName }} - echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" - args="--test-markdown" - if [ -n "${{ inputs.exclude-dirs }}" ]; then - dirs="${{ inputs.exclude-dirs }}" - dirs="${dirs//,/ }" - args+=" --exclude-dirs ${dirs}" - fi + - env: + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + stepName: Check Links in Files + name: ${{ env.stepName }} + working-directory: ${{ inputs.path }} + shell: bash + run: | + # ${{ env.stepName }} + echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" + args="--test-markdown" + if [ -n "${{ inputs.exclude-dirs }}" ]; then + dirs="${{ inputs.exclude-dirs }}" + dirs="${dirs//,/ }" + args+=" --exclude-dirs ${dirs}" + fi - if [ -n "${{ inputs.include-file-types }}" ]; then - file_types="${{ inputs.include-file-types }}" - file_types="${file_types//,/ }" - args+=" --include-file-types ${file_types}" - fi + if [ -n "${{ inputs.include-file-types }}" ]; then + file_types="${{ inputs.include-file-types }}" + file_types="${file_types//,/ }" + args+=" --include-file-types ${file_types}" + fi - if [ -n "${{ inputs.allowlist-file }}" ]; then - touch allowList.txt - cat ${{ inputs.allowlist-file }} >> allowList.txt - fi + if [ -n "${{ inputs.allowlist-file }}" ]; then + touch allowList.txt + cat ${{ inputs.allowlist-file }} >> allowList.txt + fi - if [[ "${{ inputs.exclude-urls }}" != "" ]]; then - touch allowList.txt - exclude_urls="${{ inputs.exclude-urls }}" - exclude_urls="${exclude_urls//,/ }" - for url in ${exclude_urls[@]}; do echo -e "$url" >> allowList.txt; done - fi + if [[ "${{ inputs.exclude-urls }}" != "" ]]; then + touch allowList.txt + exclude_urls="${{ inputs.exclude-urls }}" + exclude_urls="${exclude_urls//,/ }" + for url in ${exclude_urls[@]}; do echo -e "$url" >> allowList.txt; done + fi - if [ -n "${{ inputs.allowlist-file }}" ] || [ -n "${{ inputs.exclude-urls }}" ]; then - args+=" --allowlist-file allowList.txt" - fi + if [ -n "${{ inputs.allowlist-file }}" ] || [ -n "${{ inputs.exclude-urls }}" ]; then + args+=" --allowlist-file allowList.txt" + fi - echo -e "${{ env.bashInfo }} Running: verify-links.py ${args} --user-agent \"${{ inputs.user-agent }}\" ${{ env.bashEnd }}" - set +e - python3 ${GITHUB_ACTION_PATH}/verify-links.py ${args} --user-agent "${{ inputs.user-agent }}"; - exitStatus=$? - set -e + echo -e "${{ env.bashInfo }} Running: verify-links.py ${args} --user-agent \"${{ inputs.user-agent }}\" ${{ env.bashEnd }}" + set +e + python3 ${GITHUB_ACTION_PATH}/verify-links.py ${args} --user-agent "${{ inputs.user-agent }}"; + exitStatus=$? + set -e - echo -e "::endgroup::" - if [ $exitStatus -eq 1 ]; then - echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}" - else - echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" - fi - exit $exitStatus + echo -e "::endgroup::" + if [ $exitStatus -eq 1 ]; then + echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}" + else + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + fi + exit $exitStatus diff --git a/localhost-echo-server/action.yml b/localhost-echo-server/action.yml index 5ed733bf..da284cb6 100644 --- a/localhost-echo-server/action.yml +++ b/localhost-echo-server/action.yml @@ -9,8 +9,9 @@ inputs: runs: using: "composite" steps: - - name: Run localhost Echo server - run: | - python3 --version - python3 $GITHUB_ACTION_PATH/local_echo_server.py --port_number=${{ inputs.port_number }} & - shell: bash + - name: Run localhost Echo server + shell: bash + run: | + python3 --version + python3 $GITHUB_ACTION_PATH/local_echo_server.py --port_number=${{ inputs.port_number }} & + diff --git a/localhost-http-1.1-server/action.yml b/localhost-http-1.1-server/action.yml index 8b40e667..4f678468 100644 --- a/localhost-http-1.1-server/action.yml +++ b/localhost-http-1.1-server/action.yml @@ -15,9 +15,10 @@ inputs: runs: using: "composite" steps: - - name: Install dependencies - run: pip install -r $GITHUB_ACTION_PATH/requirements.txt - shell: bash - - name: Run localhost HTTP broker - run: python3 $GITHUB_ACTION_PATH/localhost_http_1.1_server.py --root-ca-cert-path=${{ inputs.root-ca-cert-path }} --server-priv-key-path=${{ inputs.server-priv-key-path }} --server-cert-path=${{ inputs.server-cert-path }} & - shell: bash + - name: Install dependencies + run: pip install -r $GITHUB_ACTION_PATH/requirements.txt + shell: bash + + - name: Run localhost HTTP broker + run: python3 $GITHUB_ACTION_PATH/localhost_http_1.1_server.py --root-ca-cert-path=${{ inputs.root-ca-cert-path }} --server-priv-key-path=${{ inputs.server-priv-key-path }} --server-cert-path=${{ inputs.server-cert-path }} & + shell: bash diff --git a/localhost-mqtt-broker/action.yml b/localhost-mqtt-broker/action.yml index f3579255..0ccd88de 100644 --- a/localhost-mqtt-broker/action.yml +++ b/localhost-mqtt-broker/action.yml @@ -15,9 +15,9 @@ inputs: runs: using: "composite" steps: - - name: Install dependencies - run: pip install -r $GITHUB_ACTION_PATH/requirements.txt - shell: bash - - name: Run localhost MQTT broker - run: python3 $GITHUB_ACTION_PATH/localhost_mqtt_broker.py --root-ca-cert-path=${{ inputs.root-ca-cert-path }} --server-priv-key-path=${{ inputs.server-priv-key-path }} --server-cert-path=${{ inputs.server-cert-path }} & - shell: bash + - name: Install dependencies + run: pip install -r $GITHUB_ACTION_PATH/requirements.txt + shell: bash + - name: Run localhost MQTT broker + run: python3 $GITHUB_ACTION_PATH/localhost_mqtt_broker.py --root-ca-cert-path=${{ inputs.root-ca-cert-path }} --server-priv-key-path=${{ inputs.server-priv-key-path }} --server-cert-path=${{ inputs.server-cert-path }} & + shell: bash diff --git a/manifest-verifier/action.yml b/manifest-verifier/action.yml index b52ea406..8d38eeb5 100644 --- a/manifest-verifier/action.yml +++ b/manifest-verifier/action.yml @@ -16,49 +16,49 @@ inputs: runs: using: "composite" steps: - - env: - bashPass: \033[32;1mPASSED - - bashInfo: \033[33;1mINFO - - bashFail: \033[31;1mFAILED - - bashEnd: \033[0m - stepName: Install Manifest Verification Dependencies - name: ${{ env.stepName }} - shell: bash - run: | - # ${{ env.stepName }} - echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" - pip install -r $GITHUB_ACTION_PATH/requirements.txt - exitStatus=$? - echo -e "::endgroup::" - echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + - env: + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + stepName: Install Manifest Verification Dependencies + name: ${{ env.stepName }} + shell: bash + run: | + # ${{ env.stepName }} + echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" + pip install -r $GITHUB_ACTION_PATH/requirements.txt + exitStatus=$? + echo -e "::endgroup::" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" - - env: - bashPass: \033[32;1mPASSED - - bashInfo: \033[33;1mINFO - - bashFail: \033[31;1mFAILED - - bashEnd: \033[0m - stepName: Run Manifest Verification Script - name: ${{ env.stepName }} - working-directory: ${{ inputs.path }} - shell: bash - run: | - # ${{ env.stepName }} - echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" + - env: + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + stepName: Run Manifest Verification Script + name: ${{ env.stepName }} + working-directory: ${{ inputs.path }} + shell: bash + run: | + # ${{ env.stepName }} + echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" - if [[ "${{ inputs.fail-on-incorrect-version }}" == "true" ]]; then - echo -e "${{ env.bashInfo}} Value of flag is ${{ inputs.fail-on-incorrect-version }} ${{ env.bashEnd }}" - echo -e "${{ env.bashInfo}} Running: python3 manifest-verifier.py --ignore-submodule-path=${{ inputs.exclude-submodules }} --fail-on-incorrect-version ${{ inputs.fail-on-incorrect-version }} ${{ env.bashEnd }}" - python3 $GITHUB_ACTION_PATH/manifest-verifier.py --ignore-submodule-path=${{ inputs.exclude-submodules }} --fail-on-incorrect-version - else - echo -e "${{ env.bashInfo}} Running: python3 manifest-verifier.py --ignore-submodule-path=${{ inputs.exclude-submodules }} ${{ env.bashEnd }}" - python3 $GITHUB_ACTION_PATH/manifest-verifier.py --ignore-submodule-path=${{ inputs.exclude-submodules }} - fi - exitStatus=$? + if [[ "${{ inputs.fail-on-incorrect-version }}" == "true" ]]; then + echo -e "${{ env.bashInfo}} This action will cause a PR Failure if a submodule is not equal to the manifest.yml version ${{ inputs.fail-on-incorrect-version }} ${{ env.bashEnd }}" + echo -e "${{ env.bashInfo}} Running: python3 manifest-verifier.py --ignore-submodule-path=${{ inputs.exclude-submodules }} --fail-on-incorrect-version ${{ inputs.fail-on-incorrect-version }} ${{ env.bashEnd }}" + python3 $GITHUB_ACTION_PATH/manifest-verifier.py --ignore-submodule-path=${{ inputs.exclude-submodules }} --fail-on-incorrect-version + else + echo -e "${{ env.bashInfo}} Running: python3 manifest-verifier.py --ignore-submodule-path=${{ inputs.exclude-submodules }} ${{ env.bashEnd }}" + python3 $GITHUB_ACTION_PATH/manifest-verifier.py --ignore-submodule-path=${{ inputs.exclude-submodules }} + fi + exitStatus=$? - echo -e "::endgroup::" - if [ "$exitStatus" = "0" ]; then - echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" - else - echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}" - exit 1 - fi + echo -e "::endgroup::" + if [ "$exitStatus" = "0" ]; then + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + else + echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}" + exit 1 + fi diff --git a/memory_statistics/action.yml b/memory_statistics/action.yml index 8787bcae..6fd01e24 100644 --- a/memory_statistics/action.yml +++ b/memory_statistics/action.yml @@ -22,30 +22,60 @@ inputs: description: 'Link to ARM GCC tar.bz2 to use for compiling files (default version 9-2020-q2).' required: false default: "https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/9-2020q2/gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2?revision=05382cca-1721-44e1-ae19-1e7c3dc96118&la=en&hash=D7C9D18FCA2DD9F894FD9F3C3DC9228498FA281A" + runs: using: "composite" steps: - - name: Install ARM GCC - run: | - wget -qO- "${{ inputs.toolchain_link }}" | sudo tar --strip-components=1 -xj -C /usr/local + - env: + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + stepName: Install ARM GCC + name: ${{ env.stepName }} shell: bash - - name: Compute sizes + run: | + # ${{ env.stepName }} + echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" + wget -qO- "${{ inputs.toolchain_link }}" | sudo tar --strip-components=1 -xj -C /usr/local + echo -e "::endgroup::" + echo -e "::group::${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + + - env: + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + stepName: Compute File Sizes + name: ${{ env.stepName }} working-directory: ${{ inputs.path }} - run: >- - ${{ github.action_path }}/memory_statistics.py - --config "${{ inputs.config }}" - --output "${{ inputs.output }}" shell: bash - - name: Compare table - working-directory: ${{ inputs.path }} run: | - if [ -n "${{ inputs.check_against }}" ] ; then - if cmp "${{ inputs.check_against }}" "${{ inputs.output }}" ; then - exit 0 - else - echo "Size table does not match!" - diff -U 2 "${{ inputs.check_against }}" "${{ inputs.output }}" - exit 1 - fi - fi + # ${{ env.stepName }} + echo -e "${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" + ${{ github.action_path }}/memory_statistics.py --config "${{ inputs.config }}" --output "${{ inputs.output }}" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + + - env: + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + stepName: Check File Size + name: ${{ env.stepName }} + working-directory: ${{ inputs.path }} shell: bash + if: inputs.check_against + run: | + # ${{ env.stepName }} + echo -e "${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" + if cmp "${{ inputs.check_against }}" "${{ inputs.output }}" ; then + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + exit 0 + else + echo -e "::endgroup::" + echo -e "::group::${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}" + echo -e "${{ env.bashFail }} Sizes of files from provided ${{ inputs.check_against }} are not equal to current file size! ${{ env.bashEnd }}" + diff -U 2 "${{ inputs.check_against }}" "${{ inputs.output }}" + exit 1 + fi diff --git a/rust-spell-check/action.yml b/rust-spell-check/action.yml index a490358b..e6580582 100644 --- a/rust-spell-check/action.yml +++ b/rust-spell-check/action.yml @@ -19,126 +19,126 @@ inputs: runs: using: "composite" steps: - - env: - bashPass: \033[32;1mPASSED - - bashInfo: \033[33;1mINFO - - bashFail: \033[31;1mFAILED - - bashEnd: \033[0m - stepName: Set-Up The Spell Checker - name: ${{ env.stepName }} - id: spell-checker-setup - shell: bash - run: | - # ${{ env.stepName }} - echo -e "::group::Install Dependencies" - - # Install the Dependencies we need to run the spell-checker - sudo apt-get install util-linux -y - sudo apt-get install fd-find -y - sudo apt-get install aspell -y - sudo apt-get install spell -y - echo -e "::endgroup::" - - # Add the current directory to PATH - export PATH="$GITHUB_ACTION_PATH:$PATH" - - # Due to feedback from @archigup we will not be storing the binary - # So will build it from scratch each time. A future improvement is to use - # GitHub Caches or a public S3 bucket to store a pre-built one and download it. - # When this is done this logic below needs to be changed to perform the download - # And then try to use the spell-checker. Leaving this here for future reference - # When this work is being done. - # echo -e " ${{ env.bashInfo }} Try Using the pre-built spell checker ${{ env.bashEnd }}" - # Wrap the check to use if in a set +e so we don't error out if it fails - # Save the exit code to check later, as "set -e" will overwrite it - # set +e - # spell-checker - # exitCode=$? - # set -e - - echo -e "::group::Compile Spell Checker" - exitCode=1 - - if ! [ $exitCode -eq 0 ]; then - #echo -e " ${{ env.bashFail }} Don't have the ability to use the current spell checker, building it ${{ env.bashEnd }}" - - # If we can't run the current one, install the tools we need to build it - # Run one a time for error checking - sudo apt-get install libaspell-dev -y - sudo apt-get install build-essential -y - sudo apt install rustc -y - - echo -e "${{ env.bashInfo }} cargo --version = $(cargo --version) ${{ env.bashEnd }}" - echo -e "${{ env.bashInfo }} rustc --version = $(rustc --version) ${{ env.bashEnd }}" - - pushd "$GITHUB_ACTION_PATH" - cargo build --release - echo -e "find = $(find . -name 'spell-checker') " - # It's possible that we have one in the directory, but just can't suse it - # set +e so we don't error when overriding it - set +e - mv $(find . -name "spell-checker") . - set -e - popd - spell-checker --help - echo -e "::endgroup::Compile Spell Checker" - - # Only make it to here if nothing above fails - echo -e "${{ env.bashPass }} Compiled the Spell Checker ${{ env.bashEnd }}" - fi - echo -e "::endgroup::" - - # Only get to here if nothing above fails - echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" - - - env: - bashPass: \033[32;1mPASSED - - bashInfo: \033[33;1mINFO - - bashFail: \033[31;1mFAILED - - bashEnd: \033[0m - stepName: Spell Checker - name: ${{ env.stepName }} - id: run-spell-checker - working-directory: ${{ inputs.path }} - shell: bash - run: | - # ${{ env.stepName }} - #echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" - export PATH="$GITHUB_ACTION_PATH:$PATH" - - # So here's the deal. At time of writing this spell checker can check - # every word in every folder in FreeRTOS/FreeRTOS in like 10 seconds. - # So I just let it do that. If this changes in the future, feel free to use - # The various exclude dir/file options - # files=$(getFiles --exclude-dirs="${{ inputs.exclude-dirs}}" --exclude-files="${{ inputs.exclude-files }}" --include-extensions="${{ inputs.include-extensions }}") - - # The use of exec will return the exit code from the grep command - # Grep returns an exit code if a file isn't found - # So wrap the search in a set +/- e so github doesn't stop the run on first failure + - env: + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + stepName: Set-Up The Spell Checker + name: ${{ env.stepName }} + id: spell-checker-setup + shell: bash + run: | + # ${{ env.stepName }} + echo -e "::group::Install Dependencies" + + # Install the Dependencies we need to run the spell-checker + sudo apt-get install util-linux -y + sudo apt-get install fd-find -y + sudo apt-get install aspell -y + sudo apt-get install spell -y + echo -e "::endgroup::" + + # Add the current directory to PATH + export PATH="$GITHUB_ACTION_PATH:$PATH" + + # Due to feedback from @archigup we will not be storing the binary + # So will build it from scratch each time. A future improvement is to use + # GitHub Caches or a public S3 bucket to store a pre-built one and download it. + # When this is done this logic below needs to be changed to perform the download + # And then try to use the spell-checker. Leaving this here for future reference + # When this work is being done. + # echo -e " ${{ env.bashInfo }} Try Using the pre-built spell checker ${{ env.bashEnd }}" + # Wrap the check to use if in a set +e so we don't error out if it fails + # Save the exit code to check later, as "set -e" will overwrite it + # set +e + # spell-checker + # exitCode=$? + # set -e + + echo -e "::group::Compile Spell Checker" + exitCode=1 + + if ! [ $exitCode -eq 0 ]; then + #echo -e " ${{ env.bashFail }} Don't have the ability to use the current spell checker, building it ${{ env.bashEnd }}" + + # If we can't run the current one, install the tools we need to build it + # Run one a time for error checking + sudo apt-get install libaspell-dev -y + sudo apt-get install build-essential -y + sudo apt install rustc -y + + echo -e "${{ env.bashInfo }} cargo --version = $(cargo --version) ${{ env.bashEnd }}" + echo -e "${{ env.bashInfo }} rustc --version = $(rustc --version) ${{ env.bashEnd }}" + + pushd "$GITHUB_ACTION_PATH" + cargo build --release + echo -e "find = $(find . -name 'spell-checker') " + # It's possible that we have one in the directory, but just can't suse it + # set +e so we don't error when overriding it set +e - files=$(fdfind -e c -e h --exec grep -liE "copyright (.*) [0-9]{4} amazon.com") + mv $(find . -name "spell-checker") . set -e - - # If you're onboarding a repo or need better debugging, uncomment this instead - # Of the one-line check - # for file in ${files[@]}; do - # echo -e "${{ env.bashInfo }} Checking spelling of "$file" ${{ env.bashEnd }}" - # set +e - # spell-checker -c -w .cSpellWords.txt $file - # exitStatus=$? - # set -e - # done - - # Wrap in set +e so the first mis-spelled word doesn't end the run - set +e - spell-checker -c -w .github/.cSpellWords.txt $files - exitStatus=$? - set -e - - echo -e "::endgroup::" - if [ $exitStatus -eq 0 ]; then - echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" - else - echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}" - exit 1 - fi + popd + spell-checker --help + echo -e "::endgroup::Compile Spell Checker" + + # Only make it to here if nothing above fails + echo -e "${{ env.bashPass }} Compiled the Spell Checker ${{ env.bashEnd }}" + fi + echo -e "::endgroup::" + + # Only get to here if nothing above fails + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + + - env: + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + stepName: Spell Checker + name: ${{ env.stepName }} + id: run-spell-checker + working-directory: ${{ inputs.path }} + shell: bash + run: | + # ${{ env.stepName }} + #echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" + export PATH="$GITHUB_ACTION_PATH:$PATH" + + # So here's the deal. At time of writing this spell checker can check + # every word in every folder in FreeRTOS/FreeRTOS in like 10 seconds. + # So I just let it do that. If this changes in the future, feel free to use + # The various exclude dir/file options + # files=$(getFiles --exclude-dirs="${{ inputs.exclude-dirs}}" --exclude-files="${{ inputs.exclude-files }}" --include-extensions="${{ inputs.include-extensions }}") + + # The use of exec will return the exit code from the grep command + # Grep returns an exit code if a file isn't found + # So wrap the search in a set +/- e so github doesn't stop the run on first failure + set +e + files=$(fdfind -e c -e h --exec grep -liE "copyright (.*) [0-9]{4} amazon.com") + set -e + + # If you're onboarding a repo or need better debugging, uncomment this instead + # Of the one-line check + # for file in ${files[@]}; do + # echo -e "${{ env.bashInfo }} Checking spelling of "$file" ${{ env.bashEnd }}" + # set +e + # spell-checker -c -w .cSpellWords.txt $file + # exitStatus=$? + # set -e + # done + + # Wrap in set +e so the first mis-spelled word doesn't end the run + set +e + spell-checker -c -w .github/.cSpellWords.txt $files + exitStatus=$? + set -e + + echo -e "::endgroup::" + if [ $exitStatus -eq 0 ]; then + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + else + echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}" + exit 1 + fi diff --git a/sbom-generator/action.yml b/sbom-generator/action.yml index bcd4b343..54c3382d 100644 --- a/sbom-generator/action.yml +++ b/sbom-generator/action.yml @@ -12,11 +12,12 @@ inputs: runs: using: "composite" steps: - - name: Install dependencies - run: pip install -r $GITHUB_ACTION_PATH/requirements.txt - shell: bash - - name: Run generator script - working-directory: ${{ inputs.repo_path }} - run: | - python3 $GITHUB_ACTION_PATH/scan_dir.py --source-path ${{ inputs.source_path }} - shell: bash + - name: Install dependencies + shell: bash + run: pip install -r $GITHUB_ACTION_PATH/requirements.txt + + - name: Run generator script + working-directory: ${{ inputs.repo_path }} + shell: bash + run: | + python3 $GITHUB_ACTION_PATH/scan_dir.py --source-path ${{ inputs.source_path }} diff --git a/spellings/action.yml b/spellings/action.yml index 230bdc75..3128b847 100644 --- a/spellings/action.yml +++ b/spellings/action.yml @@ -19,105 +19,105 @@ inputs: runs: using: "composite" steps: - - env: - bashPass: \033[32;1mPASSED - - bashInfo: \033[33;1mINFO - - bashFail: \033[31;1mFAILED - - bashEnd: \033[0m - stepName: Set-Up The Spell Checker - name: ${{ env.stepName }} - id: spell-checker-setup - shell: bash - run: | - # ${{ env.stepName }} - echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" - - # Install the Dependencies we need to run the spell-checker - sudo apt-get install util-linux -y - sudo apt-get install fd-find -y - sudo apt-get install npm -y - sudo npm install -g cspell - - # Add the Github Action Path to PATH - export PATH="$GITHUB_ACTION_PATH:$PATH" - - # Account for starting with an alternate path in a repository - # Do this by copying the cspell config and wordlist to the desired path - # Wrap in a set +e so Github doesn't throw an error if the file or - # directory already exists. - set +e - cp cspell.config.yaml ${{ inputs.path }} - mkdir ${{ inputs.path }}/.github - cp .github/.cSpellWords.txt ${{ inputs.path }}/.github - cd ${{ inputs.path }} - set -e - - echo -e "::endgroup::" - # Make sure we have all the commands we need. - echo -e "${{ env.bashInfo }} fdfind --version $(fdfind --version) ${{ env.bashEnd }}" - echo -e "${{ env.bashInfo }} cspell --version $(cspell --version) ${{ env.bashEnd }}" - - # Only reach this line if no errors were hit above + - env: + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + stepName: Set-Up The Spell Checker + name: ${{ env.stepName }} + id: spell-checker-setup + shell: bash + run: | + # ${{ env.stepName }} + echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" + + # Install the Dependencies we need to run the spell-checker + sudo apt-get install util-linux -y + sudo apt-get install fd-find -y + sudo apt-get install npm -y + sudo npm install -g cspell + + # Add the Github Action Path to PATH + export PATH="$GITHUB_ACTION_PATH:$PATH" + + # Account for starting with an alternate path in a repository + # Do this by copying the cspell config and wordlist to the desired path + # Wrap in a set +e so Github doesn't throw an error if the file or + # directory already exists. + set +e + cp cspell.config.yaml ${{ inputs.path }} + mkdir ${{ inputs.path }}/.github + cp .github/.cSpellWords.txt ${{ inputs.path }}/.github + cd ${{ inputs.path }} + set -e + + echo -e "::endgroup::" + # Make sure we have all the commands we need. + echo -e "${{ env.bashInfo }} fdfind --version $(fdfind --version) ${{ env.bashEnd }}" + echo -e "${{ env.bashInfo }} cspell --version $(cspell --version) ${{ env.bashEnd }}" + + # Only reach this line if no errors were hit above + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + + - env: + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + stepName: Spell Checker + name: ${{ env.stepName }} + id: run-spell-checker + working-directory: ${{ inputs.path }} + shell: bash + run: | + # ${{ env.stepName }} + echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" + export PATH="$GITHUB_ACTION_PATH:$PATH" + exitStatus=0 + + # Parse the optional inputs + args="" + + # fd-find uses -E to exclude a file or directory + if [ -n "${{ inputs.exclude-dirs }}" ]; then + dirs=" -E " + dirs+="${{ inputs.exclude-dirs }}" + dirs="${dirs//,/ -E }" + args+=" ${dirs}" + fi + + # fd-find uses -E to exclude a file or directory + if [ -n "${{ inputs.exclude-files }}" ]; then + files=" -E " + files+="${{ inputs.exclude-files }}" + files="${files//,/ -E }" + args+=" ${files}" + fi + + # fd-find uses -e to exclude a file extension + if [ -n "${{ inputs.include-file-types }}" ]; then + file_types=" -e " + file_types+="${{ inputs.include-file-types }}" + file_types="${file_types//,/ -e }" + args+=" ${file_types}" + fi + + echo -e "${{ env.bashInfo }} Running: fdfind -e c -e h -e md -e txt -e readme ${args} --exec-batch cspell lint --no-progress --language-id C --color --show-context --show-suggestions --no-must-find-files -c cspell.config.yaml ${{ env.bashEnd }}" + + # Wrap in a set +e so Github doesn't stop the spell check from running + set +e + + # Find all relevant files, then check them for spelling mistakes + fdfind -e c -e h -e md -e txt -e readme ${args} --exec-batch \ + cspell lint --no-progress --language-id C --color --show-context --show-suggestions --no-must-find-files -c cspell.config.yaml + exitStatus=$? + set -e + + echo -e "::endgroup::" + if [ $exitStatus -eq 0 ]; then echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" - - - env: - bashPass: \033[32;1mPASSED - - bashInfo: \033[33;1mINFO - - bashFail: \033[31;1mFAILED - - bashEnd: \033[0m - stepName: Spell Checker - name: ${{ env.stepName }} - id: run-spell-checker - working-directory: ${{ inputs.path }} - shell: bash - run: | - # ${{ env.stepName }} - echo -e "::group:${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" - export PATH="$GITHUB_ACTION_PATH:$PATH" - exitStatus=0 - - # Parse the optional inputs - args="" - - # fd-find uses -E to exclude a file or directory - if [ -n "${{ inputs.exclude-dirs }}" ]; then - dirs=" -E " - dirs+="${{ inputs.exclude-dirs }}" - dirs="${dirs//,/ -E }" - args+=" ${dirs}" - fi - - # fd-find uses -E to exclude a file or directory - if [ -n "${{ inputs.exclude-files }}" ]; then - files=" -E " - files+="${{ inputs.exclude-files }}" - files="${files//,/ -E }" - args+=" ${files}" - fi - - # fd-find uses -e to exclude a file extension - if [ -n "${{ inputs.include-file-types }}" ]; then - file_types=" -e " - file_types+="${{ inputs.include-file-types }}" - file_types="${file_types//,/ -e }" - args+=" ${file_types}" - fi - - echo -e "${{ env.bashInfo }} Running: fdfind -e c -e h -e md -e txt -e readme ${args} --exec cspell lint --language-id C --color --show-context --show-suggestions --no-must-find-files -c cspell.config.yaml ${{ env.bashEnd }}" - - # Wrap in a set +e so Github doesn't stop the spell check from running - set +e - - # Find all relevant files, then check them for spelling mistakes - fdfind -e c -e h -e md -e txt -e readme ${args} --exec-batch \ - cspell lint --language-id C --color --show-context --show-suggestions --no-must-find-files -c cspell.config.yaml - exitStatus=$? - set -e - - echo -e "::endgroup::" - if [ $exitStatus -eq 0 ]; then - echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" - else - echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}" - fi - exit $exitStatus + else + echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}" + fi + exit $exitStatus diff --git a/ssl-credential-creator/action.yml b/ssl-credential-creator/action.yml index 5bdc29dd..c57793bd 100644 --- a/ssl-credential-creator/action.yml +++ b/ssl-credential-creator/action.yml @@ -24,38 +24,38 @@ outputs: runs: using: "composite" steps: - - env: - bashPass: \033[32;1mPASSED - - bashInfo: \033[33;1mINFO - - bashFail: \033[31;1mFAILED - - bashEnd: \033[0m - stepName: Install Dependencies - shell: bash - run: | - # ${{ env.stepName }} - echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" - pip install -r $GITHUB_ACTION_PATH/requirements.txt - echo -e "::endgroup::" - echo -e "${{ env.bashPass }} ${{env.stepName}} ${{ env.bashEnd }}" + - env: + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + stepName: Install Dependencies + shell: bash + run: | + # ${{ env.stepName }} + echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" + pip install -r $GITHUB_ACTION_PATH/requirements.txt + echo -e "::endgroup::" + echo -e "${{ env.bashPass }} ${{env.stepName}} ${{ env.bashEnd }}" - - env: - bashPass: \033[32;1mPASSED - - bashInfo: \033[33;1mINFO - - bashFail: \033[31;1mFAILED - - bashEnd: \033[0m - stepName: Generate credentials - id: generate-credentials - shell: bash - run: | - # ${{ env.stepName }} - echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" - python3 $GITHUB_ACTION_PATH/ssl_credential_creator.py - echo "root-ca-priv-key-path=$(pwd)/root_ca_priv_key.key" >> $GITHUB_OUTPUT - echo "root-ca-cert-path=$(pwd)/root_ca_cert.crt" >> $GITHUB_OUTPUT - echo "server-priv-key-path=$(pwd)/server_priv_key.key" >> $GITHUB_OUTPUT - echo "server-cert-path=$(pwd)/server_cert.crt" >> $GITHUB_OUTPUT - echo "device-priv-key-path=$(pwd)/device_priv_key.key" >> $GITHUB_OUTPUT - echo "device-cert-path=$(pwd)/device_cert.crt" >> $GITHUB_OUTPUT - echo -e "::endgroup::" - echo -e "${{ env.bashPass }} ${{env.stepName}} ${{ env.bashEnd }}" + - env: + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + stepName: Generate credentials + id: generate-credentials + shell: bash + run: | + # ${{ env.stepName }} + echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" + python3 $GITHUB_ACTION_PATH/ssl_credential_creator.py + echo "root-ca-priv-key-path=$(pwd)/root_ca_priv_key.key" >> $GITHUB_OUTPUT + echo "root-ca-cert-path=$(pwd)/root_ca_cert.crt" >> $GITHUB_OUTPUT + echo "server-priv-key-path=$(pwd)/server_priv_key.key" >> $GITHUB_OUTPUT + echo "server-cert-path=$(pwd)/server_cert.crt" >> $GITHUB_OUTPUT + echo "device-priv-key-path=$(pwd)/device_priv_key.key" >> $GITHUB_OUTPUT + echo "device-cert-path=$(pwd)/device_cert.crt" >> $GITHUB_OUTPUT + echo -e "::endgroup::" + echo -e "${{ env.bashPass }} ${{env.stepName}} ${{ env.bashEnd }}"