Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
Base directory (#2)
Browse files Browse the repository at this point in the history
* declaring a directory input parameter

* fixing working directory of checking phase

* updating README file
  • Loading branch information
RockLobster authored Dec 9, 2022
1 parent c0e1b46 commit eab14a9
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 28 deletions.
39 changes: 22 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,28 @@ jobs:
runs-on: [ubuntu-latest, macos-latest]
config:
- name: Single
path: __testFiles__/DirA/SubDirA/FileAA.md
expanded_paths: __testFiles__/DirA/SubDirA/FileAA.md
directory: __testFiles__/DirA/SubDirA
path: FileAA.md
expanded_paths: FileAA.md
- name: Multiple
path: __testFiles__/**
directory: __testFiles__
path: '**'
expanded_paths: |
__testFiles__/DirA/SubDirA/FileAA.md
__testFiles__/DirA/SubDirB/FileAB.md
__testFiles__/DirA/FileA.md
__testFiles__/DirB/FileB.md
__testFiles__/Foo
DirA/SubDirA/FileAA.md
DirA/SubDirB/FileAB.md
DirA/FileA.md
DirB/FileB.md
Foo
- name: Multiple2
directory: __testFiles__
path: |
__testFiles__/DirA
__testFiles__/DirB/**
DirA
DirB/**
expanded_paths: |
__testFiles__/DirA/SubDirA/FileAA.md
__testFiles__/DirA/SubDirB/FileAB.md
__testFiles__/DirA/FileA.md
__testFiles__/DirB/FileB.md
DirA/SubDirA/FileAA.md
DirA/SubDirB/FileAB.md
DirA/FileA.md
DirB/FileB.md
fail-fast: false
name: ${{ matrix.config.name }} File Upload Test [${{ matrix.runs-on }}]
Expand All @@ -43,6 +46,7 @@ jobs:
- name: Upload
uses: ./
with:
directory: ${{ matrix.config.directory }}
name: ${{ matrix.config.name }}-${{ matrix.runs-on }}
path: ${{ matrix.config.path }}
retention-days: 1
Expand All @@ -61,7 +65,7 @@ jobs:
working-directory: check
- name: Check Archive contents
run: |
unzip *.rTmpArchive.zip -d check/tmp
unzip *.rTmpArchive.zip -d unpacked
EXPANDED_PATHS="${{ matrix.config.expanded_paths }}"
Expand All @@ -73,7 +77,7 @@ jobs:
continue
fi
FULL_PATH=check/tmp/$EXPANDED_PATH
FULL_PATH=unpacked/$EXPANDED_PATH
echo "Checking if file exists: $FULL_PATH"
if [ -f "$FULL_PATH" ]; then
echo "File exists."
Expand All @@ -86,11 +90,12 @@ jobs:
echo "Done checking files."
unzipped_file_count=$(find check/tmp -type f | wc -l)
unzipped_file_count=$(find unpacked -type f | wc -l)
if [ ! "$unzipped_file_count" -eq "$PATH_COUNT" ]; then
echo "Encountered more files than expected; expected: [$PATH_COUNT], actual: [$unzipped_file_count]";
exit 1
fi
working-directory: check

test-multiple-uploads-same-name:
name: Multiple Uploads With The Same Name
Expand Down
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# archiving-upload-artifact

In our builds we noticed that [actions/upload-artifact](https://github.com/actions/upload-artifact) becomes really slow when trying to upload large numbers of files.
In our builds we noticed that [actions/upload-artifact](https://github.com/marketplace/actions/upload-a-build-artifact) becomes really slow when trying to upload large numbers of files.

For comaprison:

Expand All @@ -10,3 +10,30 @@ For comaprison:
| Android Unit Test Results | 1192 | ~13MB | 2m 25s |

This action attempts to reduce the upload time by putting all matched files into an archive before uploading.

## Inputs
The inputs of the action mirror [actions/upload-artifact](https://github.com/marketplace/actions/upload-a-build-artifact) except for path stripping:

`upload-artifact` strips away the directory hierarchy that is common between all `path` inputs. (See [Upload using Multiple Paths and Exclusions]([actions/upload-artifact](https://github.com/marketplace/actions/upload-a-build-artifact)))

To replicate the same behavior with this action, make sure to set the `directory` parameter.

| Parameter | Description |
|------------------|--------------|
| `name` | The name under which the artifact will be uploaded |
| `directory` | The base directory for all `path` values. Defaults to '`.`' |
| `path` | 'A file, directory or wildcard pattern that describes what to upload. These must be relative to the `directory` input parameter.' |
| `retention-days` | Duration after which artifact will expire in days. 0 means using default retention. Minimum 1 day. Maximum 90 days unless changed from the repository settings page. |

## Example
```yaml
- name: Archive and upload Build Artifacts
uses: RockLobster/[email protected]
with:
name: android-test-results
directory: android/libs
path: |
*/build/test-results/**
*/build/reports/**
*/build/cucumber-reports/**
```
16 changes: 6 additions & 10 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,12 @@ inputs:
name:
description: 'Artifact name'
default: 'artifact'
directory:
description: 'The base directory '
default: '.'
path:
description: 'A file, directory or wildcard pattern that describes what to upload'
description: 'A file, directory or wildcard pattern that describes what to upload. These must be relative to the `directory` input parameter.'
required: true
if-no-files-found:
description: >
The desired behavior if no files are found using the provided path.
Available Options:
warn: Output a warning but do not fail the action
error: Fail the action with an error message
ignore: Do not output any warnings or errors, the action does not fail
default: 'warn'
retention-days:
description: >
Duration after which artifact will expire in days. 0 means using default retention.
Expand All @@ -44,11 +39,12 @@ runs:
uses: TheDoctor0/[email protected]
with:
filename: ${{ steps.generate-name.outputs.zip_name }}
directory: ${{ inputs.directory }}
path: ${{ inputs.path }}
- name: Upload Archive
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.name }}
retention-days: ${{ inputs.retention-days }}
path: ${{ steps.generate-name.outputs.zip_name }}
path: ${{ inputs.directory }}/${{ steps.generate-name.outputs.zip_name }}
if-no-files-found: error

0 comments on commit eab14a9

Please sign in to comment.