Skip to content

Commit

Permalink
Comparing actions and pyTooling variant behavior.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paebbels committed Dec 5, 2024
1 parent 046b12c commit 71b5325
Show file tree
Hide file tree
Showing 2 changed files with 259 additions and 10 deletions.
239 changes: 233 additions & 6 deletions .github/workflows/ArtifactsUpload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on:
workflow_dispatch:

jobs:
Build:
name: Upload artifact
Build-1:
name: Build 1 - Upload artifact
runs-on: ubuntu-24.04

steps:
Expand Down Expand Up @@ -37,14 +37,113 @@ jobs:
*.log
bin/
lib/*.py
# if-no-files-found: error
# retention-days: 1
Verify:
Build-2:
name: Build 2 - Upload artifact
runs-on: ubuntu-24.04

steps:
- name: 🖉 Build 2
run: |
echo "Document 1 $(date --utc '+%d.%m.%Y - %H:%M:%S')" > document1.txt
echo "Analysis log $(date --utc '+%d.%m.%Y - %H:%M:%S')" > analysis.log
echo "Build log $(date --utc '+%d.%m.%Y - %H:%M:%S')" > build.log
mkdir -p bin
echo "Program $(date --utc '+%d.%m.%Y - %H:%M:%S')" > bin/program.py
chmod u+x bin/program.py
mkdir -p lib
echo "Library $(date --utc '+%d.%m.%Y - %H:%M:%S')" > lib/common.py
chmod +x lib/common.py
- name: 🔎 Inspect directory structure
run: |
tree .
- name: 📤 Upload artifact
uses: actions/upload-artifact@v4
with:
name: github-release
path: |
document1.txt
*.log
bin/
lib/*.py
- name: 📤 Upload artifact
uses: pyTooling/upload-artifact@dev
with:
name: pyTooling-release
path: |
document1.txt
*.log
bin/
lib/*.py
- name: 📤 Upload artifact
uses: actions/upload-artifact@v4
with:
name: github-single-file
path: |
document1.txt
- name: 📤 Upload artifact
uses: pyTooling/upload-artifact@dev
with:
name: pyTooling-single-file
path: |
document1.txt
- name: 📤 Upload artifact
uses: actions/upload-artifact@v4
with:
name: github-single-file-in-directory
path: |
bin/program.py
- name: 📤 Upload artifact
uses: pyTooling/upload-artifact@dev
with:
name: pyTooling-single-file-in-directory
path: |
bin/program.py
- name: 📤 Upload artifact
uses: actions/upload-artifact@v4
with:
name: github-single-directory
path: |
bin
- name: 📤 Upload artifact
uses: pyTooling/upload-artifact@dev
with:
name: pyTooling-single-directory
path: |
bin
- name: 📤 Upload artifact
uses: actions/upload-artifact@v4
with:
name: github-double-directory
path: |
bin
lib
- name: 📤 Upload artifact
uses: pyTooling/upload-artifact@dev
with:
name: pyTooling-double-directory
path: |
bin
lib
Verify-1:
name: Verify artifact content
runs-on: ubuntu-24.04
needs:
- Build
- Build-1

steps:
- name: 📥 Download artifact
Expand Down Expand Up @@ -161,3 +260,131 @@ jobs:
else
echo -e "${ANSI_LIGHT_GREEN}No errors found.${ANSI_NOCOLOR}"
fi
Inspect-2-1:
name: Inspect single file
runs-on: ubuntu-24.04
needs:
- Build-2

steps:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: github-single-file

- name: 🔎 Inspect extracted tarball
run: |
tree .
Inspect-2-2:
name: Inspect single file in directory
runs-on: ubuntu-24.04
needs:
- Build-2

steps:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: github-single-file-in-directory

- name: 🔎 Inspect extracted tarball
run: |
tree .
Inspect-2-3:
name: Inspect single directory
runs-on: ubuntu-24.04
needs:
- Build-2

steps:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: github-single-directory

- name: 🔎 Inspect extracted tarball
run: |
tree .
Inspect-2-4:
name: Inspect double directory
runs-on: ubuntu-24.04
needs:
- Build-2

steps:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: github-double-directory

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

steps:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: pyTooling-single-file

- name: 🔎 Inspect extracted tarball
run: |
tree .
Verify-2-2:
name: Verify single file in directory
runs-on: ubuntu-24.04
needs:
- Build-2

steps:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: pyTooling-single-file-in-directory

- name: 🔎 Inspect extracted tarball
run: |
tree .
Verify-2-3:
name: Verify single directory
runs-on: ubuntu-24.04
needs:
- Build-2

steps:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: pyTooling-single-directory

- name: 🔎 Inspect extracted tarball
run: |
tree .
Verify-2-4:
name: Verify double directory
runs-on: ubuntu-24.04
needs:
- Build-2

steps:
- name: 📥 Download artifact
uses: actions/download-artifact@v4
with:
name: pyTooling-double-directory

- name: 🔎 Inspect extracted tarball
run: |
tree .
30 changes: 26 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ inputs:
type: string
required: false
default: 'artifact'
root-directory:
# description:
type: string
required: false
path:
description: |
A file, directory or wildcard pattern that describes what to upload
Required.
type: string
required: true
if-no-files-found:
description: |
The desired behavior if no files are found using the provided path.
Expand Down Expand Up @@ -61,7 +66,7 @@ inputs:
type: boolean
required: false
default: false
temp_tarball:
tarball-name:
type: string
required: false
default: '__upload_artifact__.tar'
Expand Down Expand Up @@ -100,22 +105,39 @@ runs:
done <<<'${{ inputs.path }}'
# echo "PATTERNS: ${PATTERNS[@]}"
if [[ "${{ inputs.root-directory }}" != "" ]]; then
echo -n "Changing to artifact root directory '${{ inputs.root-directory }}' ... "
if [[ -d "${{ inputs.root-directory }}" ]]; then
pushd "${artifactDirectory}" > /dev/null
if [[ $? -ne 0 ]]; then
echo -e "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}"
else
echo -e "${ANSI_LIGHT_GREEN}[OK]${ANSI_NOCOLOR}"
fi
else
echo -e "echo -e ${ANSI_LIGHT_RED}[NO DIRECTORY]${ANSI_NOCOLOR}"
exit 1
fi
pushd "${artifactDirectory}" > /dev/null
fi
echo -n "Creating temporary tarball ... "
tar -cf "${{ inputs.temp_tarball }}" "${PATTERNS[@]}"
tar -cf "${{ inputs.tarball-name }}" "${PATTERNS[@]}"
if [[ $? -ne 0 ]]; then
echo -e "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}"
else
echo -e "${ANSI_LIGHT_GREEN}[OK]${ANSI_NOCOLOR}"
fi
echo "Files collected: $(tar -tf '${{ inputs.tarball-name }}' | wc -l)"
# https://github.com/actions/upload-artifact
- name: Upload artifact
id: upload
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.name }}
path: ${{ inputs.temp_tarball }}
path: ${{ inputs.tarball-name }}
overwrite: ${{ inputs.overwrite }}

- name: Remove temporary tarball
Expand All @@ -129,7 +151,7 @@ runs:
ANSI_NOCOLOR="\e[0m"
echo -n "Removing temporary tarball ... "
rm -f "${{ inputs.temp_tarball }}"
rm -f "${{ inputs.tarball-name }}"
if [[ $? -ne 0 ]]; then
echo -e "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}"
else
Expand Down

0 comments on commit 71b5325

Please sign in to comment.