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

update sst #373

Closed
wants to merge 21 commits into from
Closed

update sst #373

wants to merge 21 commits into from

Conversation

ayinloya
Copy link
Collaborator

Fix preview urls not posted on pr

Fix preview urls not posted on pr
@ayinloya ayinloya self-assigned this Dec 16, 2024
@ayinloya ayinloya closed this Dec 16, 2024
@ayinloya ayinloya reopened this Dec 16, 2024
@smileidentity smileidentity deleted a comment from github-actions bot Dec 16, 2024
@ayinloya ayinloya closed this Dec 16, 2024
@ayinloya ayinloya reopened this Dec 16, 2024
@ayinloya ayinloya marked this pull request as ready for review December 16, 2024 17:05
@prfectionist
Copy link

prfectionist bot commented Dec 16, 2024

PR Reviewer Guide 🔍

(Review updated until commit 8ca6a23)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Workflow Change
Major changes to the preview URL sharing workflow including new trigger conditions and error handling. Verify the workflow runs correctly after PR merge.

Configuration Change
Modified SST secrets configuration and deployment commands. Ensure secrets are properly set and deployment works as expected.

@prfectionist
Copy link

prfectionist bot commented Dec 16, 2024

PR Code Suggestions ✨

Latest suggestions up to 8ca6a23

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Score
Security
Enhance security by verifying the integrity of downloaded installation scripts

Consider using a pinned hash for the curl installation script to ensure supply chain
security. This prevents potential tampering with the installation script.

.github/workflows/destroy-preview.yml [26]

-curl -fsSL https://ion.sst.dev/install | VERSION=3.4.5 bash
+curl -fsSL https://ion.sst.dev/install | sha256sum --check <(echo "expected-hash  -") && VERSION=3.4.5 bash
Suggestion importance[1-10]: 8

Why: Adding hash verification for downloaded scripts is a critical security practice that helps prevent supply chain attacks and ensures the integrity of external dependencies.

8
Best practice
Add explicit error handling to prevent silent failures in CI/CD pipeline commands

Add error handling to ensure the sst remove command executes successfully,
preventing silent failures in the workflow.

.github/workflows/destroy-preview.yml [37]

-npm run sst remove -- --stage ${{ steps.get_branch_name.outputs.SS_STAGE }}
+npm run sst remove -- --stage ${{ steps.get_branch_name.outputs.SS_STAGE }} || exit 1
Suggestion importance[1-10]: 7

Why: Explicit error handling with exit codes is important for CI/CD reliability, ensuring pipeline failures are properly caught and reported rather than silently continuing.

7
Add error handling and logging for failed operations in workflow steps that have continue-on-error enabled

Add error handling and logging for the case when retrieving the app URL fails, since
the step has continue-on-error enabled. This will help debug issues when the URL
retrieval fails.

.github/workflows/share-preview-url.yml [27-33]

 - name: retrieve sst app url
   continue-on-error: true
   id: get_app_url
   working-directory: ./previews
   run: |
-    APP_URL=$(npm run sst shell node get_app_url.js -- --stage $GITHUB_HEAD_REF)
+    if ! APP_URL=$(npm run sst shell node get_app_url.js -- --stage $GITHUB_HEAD_REF); then
+      echo "Failed to retrieve app URL"
+      exit 1
+    fi
     echo "PREVIEW_APP_URL=$APP_URL" >> $GITHUB_OUTPUT
Suggestion importance[1-10]: 6

Why: The suggestion improves error handling and debugging capabilities by adding explicit error checking and logging when retrieving the app URL fails. This is important since the step has continue-on-error enabled.

6
Reorder export and import statements to follow common code organization patterns

Consider moving the export statement before the import to follow the convention of
having exports before imports. This improves code organization and readability.

previews/sst-env.d.ts [5-6]

+export {};
 import 'sst';
-export {};
Suggestion importance[1-10]: 2

Why: While the suggestion aims to improve code organization, reordering exports and imports is a minor stylistic change with minimal impact on functionality or maintainability. The current order is also valid and commonly used.

2

Previous suggestions

Suggestions up to commit 830eef8
CategorySuggestion                                                                                                                                    Score
Possible issue
Remove continue-on-error from critical steps to ensure workflow fails on important errors

Remove continue-on-error from critical steps as it may hide important failures

.github/workflows/share-preview-url.yml [24-29]

 - name: install sst
-  continue-on-error: true
   run: |
     curl -fsSL https://ion.sst.dev/install | VERSION=3.4.5 bash
 - name: retrieve sst app url
-  continue-on-error: true
+  run: |
Suggestion importance[1-10]: 9

Why: Using continue-on-error on critical steps like SST installation and URL retrieval could mask serious deployment issues, potentially leading to incomplete or failed deployments without proper notification.

9
Best practice
Add explicit error handling to ensure workflow fails if secret setting operations fail

Add error handling for the sst secret commands using '|| exit 1' to ensure the
workflow fails if any secret setting fails

.github/workflows/deploy-preview.yml [96-99]

-npm run sst secret set PartnerId ${{ secrets.PREVIEW_PARTNER_ID }} -- --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} &&
-npm run sst secret set CallbackUrl ${{ secrets.PREVIEW_CALLBACK_URL }} -- --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} &&
-npm run sst secret set SmileIdApiKey ${{ secrets.PREVIEW_SMILEID_API_KEY }} -- --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} &&
-npm run sst secret set SmileIdEnvironment ${{ secrets.PREVIEW_SMILEID_ENVIRONMENT }} -- --stage ${{ steps.get_branch_name.outputs.SST_STAGE }}
+npm run sst secret set PartnerId ${{ secrets.PREVIEW_PARTNER_ID }} -- --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} || exit 1 &&
+npm run sst secret set CallbackUrl ${{ secrets.PREVIEW_CALLBACK_URL }} -- --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} || exit 1 &&
+npm run sst secret set SmileIdApiKey ${{ secrets.PREVIEW_SMILEID_API_KEY }} -- --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} || exit 1 &&
+npm run sst secret set SmileIdEnvironment ${{ secrets.PREVIEW_SMILEID_ENVIRONMENT }} -- --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} || exit 1
Suggestion importance[1-10]: 8

Why: Adding explicit error handling with '|| exit 1' is crucial for CI/CD reliability, ensuring immediate failure detection if any secret configuration fails rather than silently continuing with missing secrets.

8
Add error handling and feedback for critical cleanup operations in deployment scripts

Add error handling to ensure the sst remove command executes successfully, and
provide clear feedback if it fails.

.github/workflows/destroy-preview.yml [37]

-npm run sst remove -- --stage ${{ steps.get_branch_name.outputs.SS_STAGE }}
+npm run sst remove -- --stage ${{ steps.get_branch_name.outputs.SS_STAGE }} || { echo "Failed to remove SST app"; exit 1; }
Suggestion importance[1-10]: 7

Why: Adding proper error handling for cleanup operations is important to ensure resources are properly removed and failures are clearly reported. The suggestion improves reliability and debugging capabilities.

7
Security
Enhance security by verifying the integrity of downloaded scripts in CI/CD pipelines

Consider pinning the curl command to a specific hash to prevent potential supply
chain attacks. You can add the SHA256 hash verification to ensure the downloaded
script's integrity.

.github/workflows/destroy-preview.yml [26]

-curl -fsSL https://ion.sst.dev/install | VERSION=3.4.5 bash
+curl -fsSL https://ion.sst.dev/install --output install.sh && echo "<SHA256_HASH> install.sh" | sha256sum -c && VERSION=3.4.5 bash install.sh
Suggestion importance[1-10]: 8

Why: Adding hash verification for downloaded scripts is a critical security practice that helps prevent supply chain attacks in CI/CD pipelines. The suggestion provides a concrete implementation for script integrity checking.

8
Suggestions up to commit 830eef8
CategorySuggestion                                                                                                                                    Score
Best practice
Add error handling to ensure infrastructure cleanup failures are properly caught and reported

Add error handling to the sst remove command to ensure the workflow doesn't fail
silently if removal encounters issues. Use set -e and add error checking.

.github/workflows/destroy-preview.yml [37]

-npm run sst remove -- --stage ${{ steps.get_branch_name.outputs.SS_STAGE }}
+set -e
+npm run sst remove -- --stage ${{ steps.get_branch_name.outputs.SS_STAGE }} || {
+  echo "Failed to remove SST app"
+  exit 1
+}
Suggestion importance[1-10]: 8

Why: Adding error handling for infrastructure cleanup is crucial as silent failures could leave orphaned resources. The suggestion provides proper error detection and reporting.

8
Add error handling and status checking for secret configuration commands in the deployment workflow

Add error handling for the sst secret set commands by checking the exit status and
providing appropriate error messages. This will help diagnose issues if secret
setting fails.

.github/workflows/deploy-preview.yml [95-99]

 - name: configure sst secrets
   run: |
-    npm run sst secret set PartnerId ${{ secrets.PREVIEW_PARTNER_ID }} -- --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} &&
-    npm run sst secret set CallbackUrl ${{ secrets.PREVIEW_CALLBACK_URL }} -- --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} &&
-    npm run sst secret set SmileIdApiKey ${{ secrets.PREVIEW_SMILEID_API_KEY }} -- --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} &&
-    npm run sst secret set SmileIdEnvironment ${{ secrets.PREVIEW_SMILEID_ENVIRONMENT }} -- --stage ${{ steps.get_branch_name.outputs.SST_STAGE }}
+    for secret in "PartnerId:${{ secrets.PREVIEW_PARTNER_ID }}" "CallbackUrl:${{ secrets.PREVIEW_CALLBACK_URL }}" "SmileIdApiKey:${{ secrets.PREVIEW_SMILEID_API_KEY }}" "SmileIdEnvironment:${{ secrets.PREVIEW_SMILEID_ENVIRONMENT }}"; do
+      key="${secret%%:*}"
+      value="${secret#*:}"
+      if ! npm run sst secret set "$key" "$value" -- --stage ${{ steps.get_branch_name.outputs.SST_STAGE }}; then
+        echo "Failed to set secret: $key"
+        exit 1
+      fi
+    done
Suggestion importance[1-10]: 7

Why: The suggestion improves error handling and visibility by adding proper status checking for each secret configuration, making it easier to identify which specific secret failed to set.

7
Possible issue
Remove error suppression from critical workflow steps to ensure failures are properly caught and handled

Remove the continue-on-error directive from critical steps like retrieving the app
URL, as this could mask important failures that should stop the workflow.

.github/workflows/share-preview-url.yml [28-29]

 - name: retrieve sst app url
-  continue-on-error: true
   id: get_app_url
   working-directory: ./previews
Suggestion importance[1-10]: 8

Why: Removing continue-on-error from the critical app URL retrieval step is important as it prevents masking of failures that could indicate serious deployment issues.

8
Verify successful installation of dependencies before proceeding with deployment steps

Verify the SST version installation was successful before proceeding with subsequent
steps to prevent potential issues with uninstalled or incorrectly installed SST.

.github/workflows/destroy-preview.yml [26]

 curl -fsSL https://ion.sst.dev/install | VERSION=3.4.5 bash
+sst version || { echo "SST installation failed"; exit 1; }
Suggestion importance[1-10]: 7

Why: Verifying SST installation success is important to prevent downstream failures. The suggestion adds a practical validation step with clear error reporting.

7
Suggestions up to commit cff5268
CategorySuggestion                                                                                                                                    Score
Possible bug
Fix incorrect npm command syntax that would cause the command to fail

Fix the command syntax by adding 'run' between npm and sst.

.github/workflows/destroy-preview.yml [37]

-npm sst remove -- --stage ${{ steps.get_branch_name.outputs.SS_STAGE }}
+npm run sst remove -- --stage ${{ steps.get_branch_name.outputs.SS_STAGE }}
Suggestion importance[1-10]: 9

Why: This fixes a critical bug in the destroy-preview workflow where the incorrect npm command syntax would cause the SST removal to fail completely.

9
Best practice
Add error handling to prevent the workflow from failing if a single secret fails to set

Add error handling for the SST secret setting commands by using set -e or checking
exit codes. If one secret fails to set, the others should still be attempted.

.github/workflows/deploy-preview.yml [96-99]

-npm run sst secret set PartnerId ${{ secrets.PREVIEW_PARTNER_ID }} -- --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} &&
-npm run sst secret set CallbackUrl ${{ secrets.PREVIEW_CALLBACK_URL }} -- --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} &&
-npm run sst secret set SmileIdApiKey ${{ secrets.PREVIEW_SMILEID_API_KEY }} -- --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} &&
+set +e
+npm run sst secret set PartnerId ${{ secrets.PREVIEW_PARTNER_ID }} -- --stage ${{ steps.get_branch_name.outputs.SST_STAGE }}
+npm run sst secret set CallbackUrl ${{ secrets.PREVIEW_CALLBACK_URL }} -- --stage ${{ steps.get_branch_name.outputs.SST_STAGE }}
+npm run sst secret set SmileIdApiKey ${{ secrets.PREVIEW_SMILEID_API_KEY }} -- --stage ${{ steps.get_branch_name.outputs.SST_STAGE }}
 npm run sst secret set SmileIdEnvironment ${{ secrets.PREVIEW_SMILEID_ENVIRONMENT }} -- --stage ${{ steps.get_branch_name.outputs.SST_STAGE }}
+set -e
Suggestion importance[1-10]: 7

Why: The suggestion improves workflow reliability by preventing a complete failure if one secret fails to set. This is important for CI/CD robustness.

7
Suggestions up to commit 628f337
CategorySuggestion                                                                                                                                    Score
Typo
Correct inconsistent environment variable naming across workflow files

Fix typo in stage variable name from SS_STAGE to SST_STAGE to match other workflow
files.

.github/workflows/destroy-preview.yml [43]

-npx sst remove --stage ${{ steps.get_branch_name.outputs.SS_STAGE }}
+npx sst remove --stage ${{ steps.get_branch_name.outputs.SST_STAGE }}
Suggestion importance[1-10]: 9

Why: This fixes a critical typo in the stage variable name that would cause the destroy-preview workflow to fail, as it's using SS_STAGE instead of SST_STAGE used in other workflows.

9
Best practice
Add error handling to prevent deployment from proceeding if secret configuration fails

Add error handling and status checks after each secret set command to ensure they
complete successfully before proceeding with deployment.

.github/workflows/deploy-preview.yml [96-99]

-npx sst secret set PartnerId ${{ secrets.PREVIEW_PARTNER_ID }} --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} &&
-npx sst secret set CallbackUrl ${{ secrets.PREVIEW_CALLBACK_URL }} --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} &&
-npx sst secret set SmileIdApiKey ${{ secrets.PREVIEW_SMILEID_API_KEY }} --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} &&
-npx sst secret set SmileIdEnvironment ${{ secrets.PREVIEW_SMILEID_ENVIRONMENT }} --stage ${{ steps.get_branch_name.outputs.SST_STAGE }}
+npx sst secret set PartnerId ${{ secrets.PREVIEW_PARTNER_ID }} --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} || exit 1
+npx sst secret set CallbackUrl ${{ secrets.PREVIEW_CALLBACK_URL }} --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} || exit 1
+npx sst secret set SmileIdApiKey ${{ secrets.PREVIEW_SMILEID_API_KEY }} --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} || exit 1
+npx sst secret set SmileIdEnvironment ${{ secrets.PREVIEW_SMILEID_ENVIRONMENT }} --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} || exit 1
Suggestion importance[1-10]: 7

Why: The suggestion adds important error handling to prevent silent failures during secret configuration, which could lead to deployment issues. This improves the reliability of the deployment process.

7

@ayinloya ayinloya closed this Dec 16, 2024
@ayinloya ayinloya reopened this Dec 16, 2024
@smileidentity smileidentity deleted a comment from github-actions bot Dec 16, 2024
@prfectionist
Copy link

prfectionist bot commented Dec 16, 2024

Persistent review updated to latest commit cff5268

@ayinloya ayinloya closed this Dec 16, 2024
@ayinloya ayinloya reopened this Dec 16, 2024
@ayinloya ayinloya marked this pull request as draft December 16, 2024 18:02
@prfectionist
Copy link

prfectionist bot commented Dec 16, 2024

Persistent review updated to latest commit 830eef8

@ayinloya ayinloya marked this pull request as ready for review December 16, 2024 18:02
@prfectionist
Copy link

prfectionist bot commented Dec 16, 2024

Persistent review updated to latest commit 830eef8

@ayinloya ayinloya closed this Dec 16, 2024
@ayinloya ayinloya reopened this Dec 16, 2024
@prfectionist
Copy link

prfectionist bot commented Dec 16, 2024

Persistent review updated to latest commit 8ca6a23

Copy link

This branch has been deployed to s3 / cloudfront.

✅ Preview URL for Smart Camera Web:
https://cdn.smileidentity.com/js/preview-update-sst/smart-camera-web.js
✅ Preview URL for Embed:
https://cdn.smileidentity.com/inline/preview-update-sst/js/script.min.js
✅ Preview URL for Web Client:

@ayinloya ayinloya closed this Dec 16, 2024
@ayinloya
Copy link
Collaborator Author

Opening a new pr to test comments

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.

1 participant