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

chore(preview-envs): Add preview env workflows to camunda docs repo #3960

Merged
merged 27 commits into from
Jun 26, 2024

Conversation

andromaqui
Copy link
Contributor

@andromaqui andromaqui commented Jun 18, 2024

Description

This pr adds two workflows which aim to assist in deploying the camunda-docs preview environments as well as tearing the environments down:

preview-env-deploy.yml:

  • Deployment Trigger: Activates on labeled pull requests.
  • Build: Installs dependencies, builds the project
  • Deployment: Syncs the content of the path in the bucket to the local folder build. I did a test and using the gsutil command with the rsync -d -r option does the following:
    a. Files which don’t exist in the bucket but exist locally in the build folder will get uploaded
    b. Files which exist in the bucket but not in the local folder will get deleted from the bucket
    c. File which exist in both the local directory and the bucket but they have different content will be synced (the content of the local files will override the content of the files in the bucket)

  • Comment Handling: Updates or creates comments on the pull request about deployment status

    a. If no comments exist then a comment indicating the deployment url will be shown

    b. If a comment is found which indicates that the environment was previously teared down, it will be replaced by a comment indicating the preview env url.
    c. If there is subsequent deployments then the comment indicating that the preview env has been deployed will remain intact
  • Deployment status: The deployment status will start showing in the pr just before the build step. Once the deployment has been concluded the url will be shown at the status

preview-env-teardown.yml

  • Deployment Trigger: Runs on pull request unlabeled or closed events if the 'deploy' label is present or was present.
  • Deletes Bucket Files: Removes files from the Google Cloud Storage bucket associated with the pull request.
  • Updates Comment: Finds and updates a specific comment on the pull request to indicate the preview environment has been torn down.

Testing

Test1: Teardown workflow gets triggered when closing pr

PR #3961
Run triggered: https://github.com/camunda/camunda-docs/actions/runs/9576897550/job/26404161568

Test 2: When pushing multiple times in the same pr: the deploy comment won’t get posted multiple times and the preview environment will be build from scratch

An example of this can be found in this pr as the deploy label is active and there are multiple pushes which have happened. The latest run of the deploy-preview-env workflow wiped out all files from the bucket pr-3960 before pushing the built changes again
https://github.com/camunda/camunda-docs/actions/runs/9577037637/job/26404564930?pr=3960

Test 3: Adding and removing the deploy label multiple times results in only one comment in the pr indicating the current status of the preview env.

You can have a look at the history of this pr. The label has been removed and added multiple times and there is one comment which constantly get updated. The comment gets created/updated in the following ways:

  • When a deployment was successful a comment gets created.
  • The comment doesnt get updated when there are subsequent pushes to the pr even if there have been subsequent deployments.
  • The comment gets updated when the preview env gets teared down (on label removal for instance) indicating that action.
  • The comment which previously was indicating that the preview env has been teared down will have to be updated again to indicate that the preview env has been deployed in case the label was added again to the pr and the deployment was successful.

After env was torn down:
Screenshot 2024-06-20 at 10 50 46

Test 4: The url in the posted comment leads to a working preview environment

Following this comment on this pr
the url posted there should prompt us to a working preview environment. The link is https://preview.docs.camunda.cloud/pr-3960/index.html.

Test 5: Test concurency in deploy preview env workflow

PR: #3965

Initial run triggered: https://github.com/camunda/camunda-docs/actions/runs/9595842471/job/26461440032?pr=3965
Second run triggered: https://github.com/camunda/camunda-docs/actions/runs/9595856162/job/26461487867?pr=3965
The initial run got cancelled after the first run got triggered

Test 6: Preview env has been torn down

PR: #3972
I deployed the preview env and then removed the label to tear it down.

Since the deployment is only deactivated and not removed, this is how it is deployment after the environment has been torn down (notice the url not been apparent anymore):

Screenshot 2024-06-24 at 14 41 22

An explanation as to why the deployment has not been removed can be found in this comment #3960 (comment)

When should this change go live?

  • This is a bug fix, security concern, or something that needs urgent release support.
  • This is already available but undocumented and should be released within a week.
  • This on a specific schedule and the assignee will coordinate a release with the DevEx team. (apply hold label or convert to draft PR)
  • This is part of a scheduled alpha or minor. (apply alpha or minor label)
  • There is no urgency with this change and can be released at any time.

PR Checklist

  • My changes are for an already released minor and are in /versioned_docs directory.
  • My changes are for the next minor and are in /docs directory (aka /next/).

@andromaqui andromaqui added the deploy Stand up a temporary docs site with this PR label Jun 18, 2024
@andromaqui andromaqui added deploy Stand up a temporary docs site with this PR and removed deploy Stand up a temporary docs site with this PR labels Jun 18, 2024
@camunda camunda deleted a comment from github-actions bot Jun 18, 2024
@andromaqui andromaqui added deploy Stand up a temporary docs site with this PR and removed deploy Stand up a temporary docs site with this PR labels Jun 18, 2024
@andromaqui andromaqui removed the deploy Stand up a temporary docs site with this PR label Jun 19, 2024
@andromaqui andromaqui added the deploy Stand up a temporary docs site with this PR label Jun 19, 2024
@camunda camunda deleted a comment from github-actions bot Jun 20, 2024
@andromaqui andromaqui added deploy Stand up a temporary docs site with this PR and removed deploy Stand up a temporary docs site with this PR labels Jun 20, 2024
@camunda camunda deleted a comment from github-actions bot Jun 20, 2024
@andromaqui andromaqui added deploy Stand up a temporary docs site with this PR and removed deploy Stand up a temporary docs site with this PR labels Jun 20, 2024
@github-actions github-actions bot temporarily deployed to camunda-docs June 24, 2024 10:35 Destroyed
@andromaqui andromaqui added deploy Stand up a temporary docs site with this PR and removed deploy Stand up a temporary docs site with this PR labels Jun 24, 2024
@github-actions github-actions bot temporarily deployed to camunda-docs June 24, 2024 10:59 Destroyed
@github-actions github-actions bot temporarily deployed to camunda-docs June 24, 2024 13:06 Destroyed
@github-actions github-actions bot temporarily deployed to camunda-docs June 24, 2024 13:30 Destroyed
@clementnero clementnero added deploy Stand up a temporary docs site with this PR and removed deploy Stand up a temporary docs site with this PR labels Jun 24, 2024
Copy link
Contributor

@clementnero clementnero left a comment

Choose a reason for hiding this comment

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

A last minor comment regarding two duplicated steps.
The rest is awesome, very good job 🎉

.github/workflows/preview-env-deploy.yml Outdated Show resolved Hide resolved
@github-actions github-actions bot temporarily deployed to camunda-docs June 24, 2024 16:12 Destroyed
@camunda camunda deleted a comment from github-actions bot Jun 25, 2024
@github-actions github-actions bot temporarily deployed to camunda-docs June 25, 2024 09:13 Destroyed
@github-actions github-actions bot temporarily deployed to camunda-docs June 25, 2024 09:48 Destroyed
Copy link
Contributor

github-actions bot commented Jun 25, 2024

Your preview env has been torn down.

@camunda camunda deleted a comment from github-actions bot Jun 25, 2024
@github-actions github-actions bot temporarily deployed to camunda-docs June 25, 2024 10:10 Destroyed
@andromaqui andromaqui requested a review from clementnero June 25, 2024 10:17
@andromaqui
Copy link
Contributor Author

@akeller This pr is now ready for devex review as well :)

@akeller
Copy link
Member

akeller commented Jun 25, 2024

@andromaqui this is super cool! I know our PMs will be very excited to have previews available for docs PR reviews 🚀

The implementation looks clean and is easy to follow. No concerns with that.

I'm looking into each of the open PRs associated with this work and noticed I occasionally see a NoSuchKey error:
image

Initially, I thought this happened on the first load, but it happened again. It happens if I am on any page and hit the refresh button in my browser. The error continues until I navigate to the docs homepage and refresh. Given that this is better than our current state, I will accept this as a bug if this is a complex issue (either to debug or fix).

Screen.Recording.2024-06-25.at.2.45.37.PM.mov

@andromaqui
Copy link
Contributor Author

@akeller Thank you for catching this error, I didnt think of refreshing tbh. I had al look into the issue and that seems to be a common problem with bucket hosted javascript applications (example thread on stack overflow). I am not yet 100% certain but I think the change will involve modifying some settings on the bucket side so this pr here probably doesnt have influence in this topic.

If the current solution is acceptable to you, could we consider merging this? Today I am working on another urgent task but I will priorise fixing this issue with the preview environments right after

Copy link
Member

@akeller akeller left a comment

Choose a reason for hiding this comment

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

Based on the conversation in the PR, I'm good to merge this 👍

@andromaqui andromaqui merged commit e5561a7 into main Jun 26, 2024
8 checks passed
@andromaqui andromaqui deleted the infra-539-main branch June 26, 2024 20:32
@pepopowitz pepopowitz mentioned this pull request Jul 22, 2024
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy Stand up a temporary docs site with this PR
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

5 participants