Skip to content

Commit

Permalink
Use local actions to verify directory contents and file permissions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paebbels committed Dec 12, 2024
1 parent 36c966a commit bfb7f31
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 100 deletions.
38 changes: 38 additions & 0 deletions .github/actions/check-directory-content/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Check-Directory-Content
description: Check if directory contains the listed files.
inputs:
files:
description: List of filenames.
type: string

runs:
using: composite
steps:
- name: 📋 Verify extracted tarball content
shell: bash
run: |
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
echo -n "Checking '${file}' ... "
if [[ -f "$file" ]]; then
echo "${ANSI_LIGHT_GREEN}[PASSED]${ANSI_NOCOLOR}"
else
echo "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}"
echo "${ANSI_LIGHT_RED}Extracted artifact doesn't contain file '${file}'.${ANSI_NOCOLOR}"
errors=$((errors + 1))
fi
done <<<'${{ inputs.files }}'
echo ""
if [[ $errors -ne 0 ]]; then
echo "${ANSI_LIGHT_RED}Counted ${errors} errors.${ANSI_NOCOLOR}"
exit 1
else
echo "${ANSI_LIGHT_GREEN}No errors found.${ANSI_NOCOLOR}"
fi
38 changes: 38 additions & 0 deletions .github/actions/file-is-executable/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: File-Is-Executable
description: Check if listed files are executable.
inputs:
files:
description: List of filenames.
type: string

runs:
using: composite
steps:
- name: 📋 Verify file permissions
shell: bash
run: |
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
echo -n "Checking '${file}' ... "
if [[ -x "$file" ]]; then
echo "${ANSI_LIGHT_GREEN}[PASSED]${ANSI_NOCOLOR}"
else
echo "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}"
echo "${ANSI_LIGHT_RED}File '${file}' isn't executable.${ANSI_NOCOLOR}"
errors=$((errors + 1))
fi
done <<<'${{ inputs.files }}'
echo ""
if [[ $errors -ne 0 ]]; then
echo "${ANSI_LIGHT_RED}Counted ${errors} errors.${ANSI_NOCOLOR}"
exit 1
else
echo "${ANSI_LIGHT_GREEN}No errors found.${ANSI_NOCOLOR}"
fi
155 changes: 55 additions & 100 deletions .github/workflows/ArtifactsUpload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
chmod +x lib/gui/dialog.py
- name: 🔎 Inspect directory structure
if: runner.os != 'macOS'
run: |
tree .
Expand Down Expand Up @@ -251,7 +252,7 @@ jobs:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: github-release
name: ${{ matrix.os.name }}-github-release

- name: 🔎 Inspect downloaded artifact content
run: |
Expand Down Expand Up @@ -291,92 +292,64 @@ jobs:
fi
- name: 🔎 Inspect extracted tarball
if: runner.os != 'macOS'
run: |
tree .
- name: 📋 Verify extracted tarball content
run: |
set +e
ANSI_LIGHT_RED="\x1b[91m"
ANSI_LIGHT_GREEN="\x1b[92m"
ANSI_NOCOLOR="\x1b[0m"
expected=(
"document1.txt"
"analysis.log"
"build.log"
"bin/program.py"
"lib/common.py"
)
errors=0
for file in "${expected[@]}"; do
echo -n "Checking '${file}' ... "
if [[ -f "$file" ]]; then
echo "${ANSI_LIGHT_GREEN}[PASSED]${ANSI_NOCOLOR}"
else
echo "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}"
echo "${ANSI_LIGHT_RED}Extracted artifact doesn't contain file '${file}'.${ANSI_NOCOLOR}"
errors=$((errors + 1))
fi
done
echo ""
if [[ $errors -ne 0 ]]; then
echo "${ANSI_LIGHT_RED}Counted ${errors} errors.${ANSI_NOCOLOR}"
exit 1
else
echo "${ANSI_LIGHT_GREEN}No errors found.${ANSI_NOCOLOR}"
fi
uses: ./.github/actions/check-directory-content
with:
files: |
document1.txt
analysis.log
build.log
bin/program.py
lib/common.py
- name: 📋 Verify file permissions
run: |
set +e
ANSI_LIGHT_RED="\x1b[91m"
ANSI_LIGHT_GREEN="\x1b[92m"
ANSI_NOCOLOR="\x1b[0m"
expected=(
"bin/program.py"
"lib/common.py"
)
errors=0
for file in "${expected[@]}"; do
echo -n "Checking '${file}' ... "
if [[ -x "$file" ]]; then
echo "${ANSI_LIGHT_GREEN}[PASSED]${ANSI_NOCOLOR}"
else
echo "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}"
echo "${ANSI_LIGHT_RED}File '${file}' isn't executable.${ANSI_NOCOLOR}"
errors=$((errors + 1))
fi
done
echo ""
if [[ $errors -ne 0 ]]; then
echo "${ANSI_LIGHT_RED}Counted ${errors} errors.${ANSI_NOCOLOR}"
exit 1
else
echo "${ANSI_LIGHT_GREEN}No errors found.${ANSI_NOCOLOR}"
fi
uses: ./.github/actions/file-is-executable
with:
files: |
bin/program.py
lib/common.py
Inspect-1:
name: Inspect single file
runs-on: ubuntu-24.04
needs:
- Build-1
strategy:
fail-fast: false
matrix:
os:
- {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04'}
task:
- {'name': 'inspect'}
- {'name': 'verify' }

steps:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
if: matrix.task.name == 'inspect'
with:
name: ${{ matrix.os.name }}-github-single-file

- name: 🔎 Inspect extracted tarball
if: matrix.task.name == 'inspect'
run: |
tree .
- name: 📥 Download artifact
uses: actions/download-artifact@v4
if: matrix.task.name == 'verify'
with:
name: github-single-file
name: ${{ matrix.os.name }}-pyTooling-single-file

- name: 🔎 Inspect extracted tarball
if: matrix.task.name == 'verify'
run: |
tar -xf "__pyTooling_upload_artifact__.tar"
rm __pyTooling_upload_artifact__.tar
tree .
Inspect-2:
Expand All @@ -389,7 +362,7 @@ jobs:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: github-single-file-in-directory
name: ${{ matrix.os.name }}-github-single-file-in-directory

- name: 🔎 Inspect extracted tarball
run: |
Expand All @@ -405,7 +378,7 @@ jobs:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: github-double-file-in-directory
name: ${{ matrix.os.name }}-github-double-file-in-directory

- name: 🔎 Inspect extracted tarball
run: |
Expand All @@ -421,7 +394,7 @@ jobs:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: github-triple-file-in-directory
name: ${{ matrix.os.name }}-github-triple-file-in-directory

- name: 🔎 Inspect extracted tarball
run: |
Expand All @@ -437,7 +410,7 @@ jobs:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: github-double-file-in-deep-directory
name: ${{ matrix.os.name }}-github-double-file-in-deep-directory

- name: 🔎 Inspect extracted tarball
run: |
Expand All @@ -453,7 +426,7 @@ jobs:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: github-single-directory
name: ${{ matrix.os.name }}-github-single-directory

- name: 🔎 Inspect extracted tarball
run: |
Expand All @@ -469,7 +442,7 @@ jobs:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: github-double-directory
name: ${{ matrix.os.name }}-github-double-directory

- name: 🔎 Inspect extracted tarball
run: |
Expand All @@ -485,28 +458,10 @@ jobs:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: github-unpredictable-wildcard

- name: 🔎 Inspect extracted tarball
run: |
tree .
Verify-1:
name: Verify single file
runs-on: ubuntu-24.04
needs:
- Inspect-1

steps:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: pyTooling-single-file
name: ${{ matrix.os.name }}-github-unpredictable-wildcard

- name: 🔎 Inspect extracted tarball
run: |
tar -xf "__pyTooling_upload_artifact__.tar"
rm __pyTooling_upload_artifact__.tar
tree .
Verify-2:
Expand All @@ -519,7 +474,7 @@ jobs:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: pyTooling-single-file-in-directory
name: ${{ matrix.os.name }}-pyTooling-single-file-in-directory

- name: 🔎 Inspect extracted tarball
run: |
Expand All @@ -537,7 +492,7 @@ jobs:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: pyTooling-double-file-in-directory
name: ${{ matrix.os.name }}-pyTooling-double-file-in-directory

- name: 🔎 Inspect extracted tarball
run: |
Expand All @@ -555,7 +510,7 @@ jobs:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: pyTooling-triple-file-in-directory
name: ${{ matrix.os.name }}-pyTooling-triple-file-in-directory

- name: 🔎 Inspect extracted tarball
run: |
Expand All @@ -573,7 +528,7 @@ jobs:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: pyTooling-double-file-in-deep-directory
name: ${{ matrix.os.name }}-pyTooling-double-file-in-deep-directory

- name: 🔎 Inspect extracted tarball
run: |
Expand All @@ -591,7 +546,7 @@ jobs:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: pyTooling-single-directory
name: ${{ matrix.os.name }}-pyTooling-single-directory

- name: 🔎 Inspect extracted tarball
run: |
Expand All @@ -609,7 +564,7 @@ jobs:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: pyTooling-double-directory
name: ${{ matrix.os.name }}-pyTooling-double-directory

- name: 🔎 Inspect extracted tarball
run: |
Expand All @@ -627,7 +582,7 @@ jobs:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: pyTooling-unpredictable-wildcard
name: ${{ matrix.os.name }}-pyTooling-unpredictable-wildcard

- name: 🔎 Inspect extracted tarball
run: |
Expand All @@ -645,7 +600,7 @@ jobs:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: pyTooling-lib
name: ${{ matrix.os.name }}-pyTooling-lib

- name: 🔎 Inspect extracted tarball
run: |
Expand Down

0 comments on commit bfb7f31

Please sign in to comment.