Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: separate the CDN upload process and add a retry script #563

Merged
merged 9 commits into from
Jun 19, 2024

Conversation

daine
Copy link
Collaborator

@daine daine commented Jun 18, 2024

Summary | Résumé

Refactor: separate the CDN upload process and add a retry to wait for npm publishing to complete
Fix for:

This adds a retry functionality to the part where the files get uploaded to the CDN. The script usually fails if the package is not yet available on NPM, especially if it's a new package.

New Github workflow file upload-cdn.yml

This separates the CDN upload part in a script called upload_to_cdn.sh, which runs on new the GitHub workflow file upload-cdn.yml.

  • The workflow action runs after the compile-and-publish.yml workflow is completed.
  • We can run it manually if we need to -- you can run it multiple times because it just updates the files based on the NPM version of the specified package.

Tested with my scratch account at the moment

I ran our terraform files on my scratch account and linked our CDN to my custom domain.

Here are the links for quick testing, to make sure they do upload correctly:

Testing @latest and @0.22.1 are exactly the same:

$ wget https://cdn.ds.daine.app/@cdssnc/gcds-components@0.22.1/dist/gcds/gcds.css
$ wget https://cdn.ds.daine.app/@cdssnc/gcds-components@latest/dist/gcds/gcds.css
$ ls -alh
    38K 18 Jun 09:26 gcds.css
    38K 18 Jun 09:26 gcds.css.1
$ diff gcds.css gcds.css.1
// nothing; exactly the same

S3 Bucket

gc-design-system-daine-scratch-cdn
@cds-snc/gcds-components@latest/

Confirmed: Contents are the same, file size is the same.

@daine daine marked this pull request as ready for review June 18, 2024 22:33
@daine daine changed the title refactor: separate the CDN upload process and add a retry refactor: separate the CDN upload process and add a retry script Jun 18, 2024
}

# Retry 3 times with a 5-second delay in between
retry 3 5
Copy link
Member

Choose a reason for hiding this comment

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

I like this pattern - it's a nice way to work around the problem of the package not being instantly available.

@daine daine requested a review from patheard June 19, 2024 15:46
@daine
Copy link
Collaborator Author

daine commented Jun 19, 2024

I've made a few changes and ran them on my forked repo.

@ethanWallace I added sleep timer (60 seconds) to allow time for npm to publish the web package before proceeding to publish the rest of the packages. Here's the log to see the publish package workflow run w/sleep timer

^ Above action also forces a failure so I can test the unable-to-deploy job.
@patheard Here's the log for running a failed publishing workflow run

Co-authored-by: Pat Heard <patrick.heard@cds-snc.ca>
Copy link
Collaborator

@ethanWallace ethanWallace left a comment

Choose a reason for hiding this comment

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

LGTM!

@daine daine merged commit 498edf3 into main Jun 19, 2024
3 checks passed
@daine daine deleted the refactor/publishing-cdn-upload-workflow branch June 19, 2024 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants