diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b9ac6d2..98e01c2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 }}] @@ -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 @@ -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 }}" @@ -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." @@ -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 diff --git a/README.md b/README.md index 42c95b9..5737541 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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/archiving-upload-artifact@v0.1.0 + with: + name: android-test-results + directory: android/libs + path: | + */build/test-results/** + */build/reports/** + */build/cucumber-reports/** +``` \ No newline at end of file diff --git a/action.yml b/action.yml index 17775ed..4f8d33d 100644 --- a/action.yml +++ b/action.yml @@ -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. @@ -44,11 +39,12 @@ runs: uses: TheDoctor0/zip-release@0.6.2 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