Skip to content

feat: refactor uploading and ignore processing#255

Merged
sethvargo merged 3 commits intomainfrom
sethvargo/refactor
Apr 26, 2022
Merged

feat: refactor uploading and ignore processing#255
sethvargo merged 3 commits intomainfrom
sethvargo/refactor

Conversation

@sethvargo
Copy link
Copy Markdown
Contributor

@sethvargo sethvargo commented Apr 20, 2022

This refactors the implementation for listing, ignoring, and uploading files.

The previous implementation relied on the UploadHelper to process files and globs, and it led to a lot of translation between relative and absolute paths. It also added a lot of layers of indirection and a really tight coupling between the filesystem and the uploader.

The new implementation pre-processes all files and ignores first, then delegates uploading on the complete list of files. This means the uploader does not need to behave differently when given a file versus a directory. This makes it easier to stub only the calls to storage.bucket.upload and truly exercise the entire pipeline in unit tests.

As part of this refactor, I dropped the pMap dependency. We've been pinned at an old version of this dependency because the new version is incompatible. There's a new function, inParallel that executes Promises in parallel. I'll move it to actions-utils after more battle testing.

@sethvargo sethvargo requested a review from a team as a code owner April 20, 2022 02:35
@sethvargo sethvargo force-pushed the sethvargo/refactor branch 10 times, most recently from c1f7dd1 to b74dd82 Compare April 20, 2022 20:02
This refactors the implementation for listing, ignoring, and uploading files.

The previous implementation relied on the UploadHelper to process files and globs, and it led to a lot of translation between relative and absolute paths. It also added a lot of layers of indirection and a really tight coupling between the filesystem and the uploader.

The new implementation pre-processes all files and ignores first, then delegates uploading on the complete list of files. This means the uploader does not need to behave differently when given a file versus a directory. This makes it easier to stub only the calls to storage.bucket.upload and truly exercise the entire pipeline in unit tests.

As part of this refactor, I dropped the pMap dependency. We've been pinned at an old version of this dependency because the new version is incompatible. There's a new function, inParallel that executes Promises in parallel. I'll move it to actions-utils after more battle testing.
@sethvargo sethvargo force-pushed the sethvargo/refactor branch from b74dd82 to 5f9eb66 Compare April 21, 2022 22:24
@sethvargo
Copy link
Copy Markdown
Contributor Author

@verbanicm @bharathkkb I pulled in the latest actions-utils bits so this is smaller.

Copy link
Copy Markdown
Contributor

@bharathkkb bharathkkb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay! LGTM with some minor comments

Comment thread src/client.ts Outdated
Comment thread tests/upload.int.test.ts
Comment thread tests/upload.int.test.ts Outdated
Comment thread src/util.ts Outdated
Comment thread src/main.ts
Comment thread src/main.ts Outdated
Comment thread tests/upload.int.test.ts
@sethvargo sethvargo merged commit 6c467dd into main Apr 26, 2022
@sethvargo sethvargo deleted the sethvargo/refactor branch April 26, 2022 22:47
@swarmiakimmo
Copy link
Copy Markdown

swarmiakimmo commented Apr 27, 2022

@sethvargo Just a heads-up. We noticed that our frontend deployment broke today, making our files being served with an incorrect mime-type. It looks like the issue could be linked to this change. For us, the issue was that at least JS, and CSS files were served with content-type: image/svg+xml. Our upload step for reference:

      - name: Upload Files
        uses: google-github-actions/upload-cloud-storage@v0
        with:
          path: build-for-deploy
          destination: our-frontend-bucket
          parent: false
          headers: |-
            cache-control: private, max-age=0, no-transform

@jump24-luke
Copy link
Copy Markdown

This broke everything.
#258

@sethvargo
Copy link
Copy Markdown
Contributor Author

Thanks for letting us know. Let's keep the conversation centralized in #258.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Suddenly began to fail with the error: path should be a path.relative()d string Error: failed with error code [object Object]

4 participants