Skip to content

Commit

Permalink
v1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Paebbels committed Dec 26, 2024
2 parents e24bbc2 + 154975d commit 8eae9e1
Show file tree
Hide file tree
Showing 7 changed files with 676 additions and 109 deletions.
70 changes: 70 additions & 0 deletions .github/actions/check-artifact-content/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# The MIT License (MIT)
#
# Copyright © 2024 The pyTooling Authors
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
# documentation files (the “Software”), to deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
name: Check-Artifact-Content
description: Check what was contained in artifact.
inputs:
must-exist:
description: True, if the tarball must exist, otherwise false.
type: boolean
default: false
tarball:
description: Name of the expected tarball.
type: string
default: '__pyTooling_upload_artifact__.tar'

runs:
using: composite
steps:
- name: 🔎 Inspect downloaded artifact content
shell: bash
run: |
# 🔎 Inspect downloaded artifact content
set +e
ANSI_CYAN=$'\x1b[36m'
ANSI_LIGHT_RED=$'\x1b[91m'
ANSI_LIGHT_GREEN=$'\x1b[92m'
ANSI_LIGHT_YELLOW=$'\x1b[93m'
ANSI_LIGHT_BLUE="\e[94m"
ANSI_NOCOLOR=$'\x1b[0m'
printf "::group::${ANSI_LIGHT_BLUE}List directory content ...${ANSI_NOCOLOR}\n"
if [[ "${{ runner.os }}" != "macOS" ]]; then
tree -pashC -I .git .
else
ls -lAh .
fi
printf "::endgroup::\n"
printf "%s" "Does tarball '${{ inputs.tarball }}' exist ... "
if [[ -f ${{ inputs.tarball }} ]]; then
if [[ "${{ inputs.must-exist }}" == "true" ]]; then
printf "%s\n" "${ANSI_LIGHT_GREEN}[YES]${ANSI_NOCOLOR}"
else
printf "%s\n" "${ANSI_LIGHT_RED}[YES]${ANSI_NOCOLOR}"
printf "::error title=%s::%s\n" "check-artifact-content" "Tarball '${{ inputs.tarball }}' wasn't removed."
exit 1
fi
else
if [[ "${{ inputs.must-exist }}" == "true" ]]; then
printf "%s\n" "${ANSI_LIGHT_RED}[NO]${ANSI_NOCOLOR}"
printf "::error title=%s::%s\n" "check-artifact-content" "Tarball '${{ inputs.tarball }}' is missing."
exit 1
else
printf "%s\n" "${ANSI_LIGHT_GREEN}[NO]${ANSI_NOCOLOR}"
fi
fi
49 changes: 43 additions & 6 deletions .github/actions/check-directory-content/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,22 @@
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
name: Check-Directory-Content
description: Check if directory contains the listed files.
description: Check if directory contains all expected and no unexpected files.
inputs:
files:
expected-files:
description: List of filenames.
type: string
unexpected-files:
description: List of filenames.
type: string

runs:
using: composite
steps:
- name: 📋 Verify extracted tarball content
- name: 📋 Verify extracted tarball content for expected files
shell: bash
run: |
# 📋 Verify extracted tarball content for expected files
set +e
ANSI_LIGHT_RED=$'\x1b[91m'
Expand All @@ -42,11 +46,44 @@ runs:
if [[ -f "$file" ]]; then
printf "%s\n" "${ANSI_LIGHT_GREEN}[PASSED]${ANSI_NOCOLOR}"
else
printf "%s\n" "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}"
printf "%s\n" "${ANSI_LIGHT_RED}Extracted artifact doesn't contain file '${file}'.${ANSI_NOCOLOR}"
printf "%s\n" "${ANSI_LIGHT_RED}[MISSING]${ANSI_NOCOLOR}"
printf "::error title=%s::%s\n" "check-directory-content" "File '${file}' is missing."
errors=$((errors + 1))
fi
done <<<'${{ inputs.expected-files }}'
printf "%s\n" ""
if [[ $errors -ne 0 ]]; then
printf "%s\n" "${ANSI_LIGHT_RED}Counted ${errors} errors.${ANSI_NOCOLOR}"
exit 1
else
printf "%s\n" "${ANSI_LIGHT_GREEN}No errors found.${ANSI_NOCOLOR}"
fi
- name: 📋 Verify extracted tarball content for unexpected files
shell: bash
run: |
# 📋 Verify extracted tarball content for unexpected files
set +e
ANSI_LIGHT_RED=$'\x1b[91m'
ANSI_LIGHT_GREEN=$'\x1b[92m'
ANSI_NOCOLOR=$'\x1b[0m'
errors=0
while IFS=$'\r\n' read -r file; do
# skip empty or comment lines
[[ "${file}" == "" || "${file:0:1}" == "#" ]] && continue
printf "%s" "Checking '${file}' ... "
if [[ -f "$file" ]]; then
printf "%s\n" "${ANSI_LIGHT_RED}[UNEXPECTED]${ANSI_NOCOLOR}"
printf "::error title=%s::%s\n" "check-directory-content" "File '${file}' is unexpected."
errors=$((errors + 1))
else
printf "%s\n" "${ANSI_LIGHT_GREEN}[PASSED]${ANSI_NOCOLOR}"
fi
done <<<'${{ inputs.files }}'
done <<<'${{ inputs.unexpected-files }}'
printf "%s\n" ""
if [[ $errors -ne 0 ]]; then
Expand Down
13 changes: 9 additions & 4 deletions .github/actions/create-files/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,25 @@ runs:
- name: 🖉 Create some artificial file and directory structures
shell: bash
run: |
# 🖉 Create some artificial file and directory structures
printf "%s\n" "Root"
printf "%s\n" "Document 1 $(date --utc '+%d.%m.%Y - %H:%M:%S')" > document1.txt
printf "%s\n" "Analysis log $(date --utc '+%d.%m.%Y - %H:%M:%S')" > analysis.log
printf "%s\n" "Build log $(date --utc '+%d.%m.%Y - %H:%M:%S')" > build.log
printf "%s\n" "Document 1 $(date --utc '+%d.%m.%Y - %H:%M:%S')" > document1.txt
printf "%s\n" "Analysis log $(date --utc '+%d.%m.%Y - %H:%M:%S')" > analysis.log
printf "%s\n" "Build log $(date --utc '+%d.%m.%Y - %H:%M:%S')" > build.log
printf "%s\n" "Configuration $(date --utc '+%d.%m.%Y - %H:%M:%S')" > .config
printf "%s\n" "bin/"
mkdir -p bin
printf "%s\n" "Settings $(date --utc '+%d.%m.%Y - %H:%M:%S')" > bin/.settings
printf "%s\n" "Program $(date --utc '+%d.%m.%Y - %H:%M:%S')" > bin/program.py
chmod u+x bin/program.py
printf "%s\n" "Tool $(date --utc '+%d.%m.%Y - %H:%M:%S')" > bin/tool.py
chmod g+x bin/tool.py
printf "%s\n" "lib/"
mkdir -p lib
printf "%s\n" "Library $(date --utc '+%d.%m.%Y - %H:%M:%S')" > lib/.library
printf "%s\n" "Library 1 $(date --utc '+%d.%m.%Y - %H:%M:%S')" > lib/common.py
chmod +x lib/common.py
printf "%s\n" "Library 2 $(date --utc '+%d.%m.%Y - %H:%M:%S')" > lib/shared.py
Expand All @@ -53,4 +58,4 @@ runs:
if: runner.os != 'macOS' && runner.os != 'Windows'
shell: bash
run: |
tree .
tree -pash .
5 changes: 3 additions & 2 deletions .github/actions/file-is-executable/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ runs:
- name: 📋 Verify file permissions
shell: bash
run: |
# 📋 Verify file permissions
set +e
ANSI_LIGHT_RED=$'\x1b[91m'
Expand All @@ -42,8 +43,8 @@ runs:
if [[ -x "$file" ]]; then
printf "%s\n" "${ANSI_LIGHT_GREEN}[PASSED]${ANSI_NOCOLOR}"
else
printf "%s\n" "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}"
printf "%s\n" "${ANSI_LIGHT_RED}File '${file}' isn't executable.${ANSI_NOCOLOR}"
printf "%s\n" "${ANSI_LIGHT_RED}[NOT EXECUTABLE]${ANSI_NOCOLOR}"
printf "::error title=%s::%s\n" "file-is-executable" "File '${file}' isn't executable."
errors=$((errors + 1))
fi
done <<<'${{ inputs.files }}'
Expand Down
Loading

0 comments on commit 8eae9e1

Please sign in to comment.