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

feat: CD workflow cache & add CI workflow #68

Merged
merged 6 commits into from
May 24, 2023
Merged

Conversation

kylemocode
Copy link
Contributor

@kylemocode kylemocode commented May 24, 2023

Why need this change? / Root cause:

  • The original workflow would only be triggered when a feature is merged into the main branch. However, this means that when a feature branch initiates a pull request, it can't utilize CI to improve reliability. Therefore, I've added a new workflow (ci.yaml) that executes when a pull request is created, modified, or closed, and it will run tests and build during this process.
  • I've added a caching mechanism to the original deploy workflow, which caches node_modules and the Cypress binary. If cache got hit, the installation of dependencies step will not run. This can reduce the workflow execution time when dependencies remain unchanged.
  • For information about the caching mechanism of GitHub Actions, you can refer to this article. Since it maintains a cache for each branch, I have chosen to add the caching mechanism only to the merge workflow of the main branch, and not to the pipeline of the pull request for the time being, as the chances of cache-hit will be lower.
  • I found that the original way of using an if statement to determine whether to execute still initially triggers the workflow, then exits if conditions are not met.(like the image below) I've revised this to write the condition in the on statement instead, so the workflow will not trigger if the conditions aren't met.
截圖 2023-05-24 下午5 17 49 (some workflow just triggered and canceled in few seconds)

Changes made:

Test Scope / Change impact:

Without Cache (⏰ Time spent: 2:00) With Cache (⏰ Time spent: 1:15)
圖片 圖片

Issue

@kylemocode kylemocode temporarily deployed to development May 24, 2023 07:36 — with GitHub Actions Inactive
@kylemocode kylemocode temporarily deployed to development May 24, 2023 08:03 — with GitHub Actions Inactive
@kylemocode kylemocode temporarily deployed to development May 24, 2023 08:07 — with GitHub Actions Inactive
@kylemocode kylemocode deployed to development May 24, 2023 08:23 — with GitHub Actions Active
@kylemocode kylemocode changed the title [WIP] feat: CD workflow cache & add CI workflow feat: CD workflow cache & add CI workflow May 24, 2023
@Parkerhiphop Parkerhiphop merged commit 365ceb4 into main May 24, 2023
@Parkerhiphop Parkerhiphop deleted the feat/workflow-cache branch May 24, 2023 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants