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

fix: github ci support daily build dev #6552

Open
wants to merge 4 commits into
base: x
Choose a base branch
from
Open

Conversation

sidmorizon
Copy link
Contributor

@sidmorizon sidmorizon commented Jan 20, 2025

(cherry picked from commit f1a887e)

Summary by CodeRabbit

This release refines our build and deployment workflows, ensuring faster and more reliable updates while enhancing testing feedback. Key improvements include:

  • New Features:
    • Introduced new automated workflows for daily builds and releases across desktop, mobile, and web channels.
    • Centralized environment configuration for consistent setup during deployments.
  • Refactor:
    • Streamlined processes by removing redundant configuration steps.
  • Tests:
    • Added automated test report uploads for improved test tracking.
  • Chores:
    • Enhanced disk space management to support efficient build operations.

Copy link

codesandbox bot commented Jan 20, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link
Contributor

coderabbitai bot commented Jan 20, 2025

Walkthrough

This update introduces a unified way to set up environment variables by adding a new shared action. The workflows across several projects now call the shared action instead of using inline dotenv steps. In addition, some workflows add new steps for tasks like disk clean-up, artifact uploads, and test reporting. The overall approach streamlines the configuration and reduces redundancy across the CI/CD pipelines.

Changes

File(s) Change Summary
.github/actions/shared-env/action.yml New composite action added for setting up environment variables. Introduces inputs such as additional_env, env_file_name, sentry_project, covalent_key, sentry_token, privy_app_id, privy_mobile_client_id, and various RevenueCat API keys.
.github/workflows/daily-build-dev.yml New daily build workflow added. Sets up a static build number, saves workflow parameters, and uploads them as an artifact.
.github/workflows/release-android-debug.yml, .github/workflows/release-android.yml Android workflows now replace the dotenv action with “Run Shared Env Setup”. Added free disk space steps and new jobs for building and uploading WebEmbed artifacts.
.github/workflows/release-desktop-mas.yml, .github/workflows/release-desktop-snap.yml, .github/workflows/release-desktop-winms.yml, .github/workflows/release-desktop.yml Desktop workflows remove the old dotenv and environment injection steps in favor of “Run Shared Env Setup”. Some files introduce new jobs and slight reordering of steps to manage environment variables.
.github/workflows/release-ext.yml Modified to remove dotenv action. Now uses the shared environment setup action with updated secret inputs.
.github/workflows/release-ios-debug.yml, .github/workflows/release-ios.yml iOS workflows replace the old environment variable setup with a single “Run Shared Env Setup” step. Removed build number generation and redundant injections.
.github/workflows/release-web.yml Web workflow now includes an enhanced checkout step (with Git LFS enabled) and uses the shared action. Removed prior env injection steps.
.github/workflows/unittest.yml Added a new “Upload Test Report” step to upload test-report.html as an artifact after tests run.

Sequence Diagram(s)

sequenceDiagram
    participant R as Runner
    participant C as Checkout
    participant S as Shared Env Setup
    participant B as Build/Deploy
    participant A as Artifact Upload

    R->>C: Trigger workflow and checkout code
    C->>S: Initiate shared environment setup
    S->>B: Inject environment variables
    B->>A: Execute build and upload artifacts
Loading

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or Summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sidmorizon sidmorizon changed the title fix: github ci fix: github ci support daily build dev Feb 8, 2025
@sidmorizon sidmorizon marked this pull request as ready for review February 8, 2025 02:20
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 28

🔭 Outside diff range comments (1)
.github/workflows/release-ext.yml (1)

39-47: Check the 'Setup ENV' step.
Extracting the package version and setting up the ARTIFACTS_URL works well. No changes are needed aside from ensuring no trailing whitespace remains.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 426576f and f63cfd0.

📒 Files selected for processing (13)
  • .github/actions/shared-env/action.yml (1 hunks)
  • .github/workflows/daily-build-dev.yml (1 hunks)
  • .github/workflows/release-android-debug.yml (4 hunks)
  • .github/workflows/release-android.yml (4 hunks)
  • .github/workflows/release-desktop-mas.yml (1 hunks)
  • .github/workflows/release-desktop-snap.yml (2 hunks)
  • .github/workflows/release-desktop-winms.yml (1 hunks)
  • .github/workflows/release-desktop.yml (1 hunks)
  • .github/workflows/release-ext.yml (1 hunks)
  • .github/workflows/release-ios-debug.yml (2 hunks)
  • .github/workflows/release-ios.yml (3 hunks)
  • .github/workflows/release-web.yml (1 hunks)
  • .github/workflows/unittest.yml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/release-desktop-snap.yml

[error] 12-12: trailing spaces

(trailing-spaces)


[error] 25-25: trailing spaces

(trailing-spaces)


[error] 26-26: trailing spaces

(trailing-spaces)

.github/workflows/daily-build-dev.yml

[warning] 3-3: truthy value should be one of [false, true]

(truthy)


[error] 22-22: trailing spaces

(trailing-spaces)


[error] 31-31: trailing spaces

(trailing-spaces)


[error] 38-38: trailing spaces

(trailing-spaces)


[error] 41-41: no new line character at the end of file

(new-line-at-end-of-file)


[error] 41-41: trailing spaces

(trailing-spaces)

.github/workflows/release-ios-debug.yml

[error] 26-26: trailing spaces

(trailing-spaces)

.github/workflows/unittest.yml

[error] 73-73: too many blank lines

(1 > 0) (empty-lines)

.github/workflows/release-desktop-winms.yml

[error] 25-25: trailing spaces

(trailing-spaces)

.github/workflows/release-ios.yml

[error] 26-26: trailing spaces

(trailing-spaces)

.github/workflows/release-ext.yml

[error] 24-24: trailing spaces

(trailing-spaces)


[error] 25-25: trailing spaces

(trailing-spaces)

.github/workflows/release-desktop.yml

[error] 25-25: trailing spaces

(trailing-spaces)

.github/workflows/release-web.yml

[error] 25-25: trailing spaces

(trailing-spaces)

.github/workflows/release-android.yml

[error] 16-16: trailing spaces

(trailing-spaces)


[error] 25-25: trailing spaces

(trailing-spaces)


[error] 26-26: trailing spaces

(trailing-spaces)


[error] 94-94: trailing spaces

(trailing-spaces)


[error] 117-117: too many blank lines

(1 > 0) (empty-lines)

.github/workflows/release-android-debug.yml

[error] 22-22: trailing spaces

(trailing-spaces)


[error] 28-28: trailing spaces

(trailing-spaces)

.github/workflows/release-desktop-mas.yml

[error] 25-25: trailing spaces

(trailing-spaces)

.github/actions/shared-env/action.yml

[error] 67-67: trailing spaces

(trailing-spaces)


[error] 91-91: trailing spaces

(trailing-spaces)


[error] 181-181: trailing spaces

(trailing-spaces)


[error] 204-204: too many blank lines

(2 > 0) (empty-lines)

🪛 actionlint (1.7.4)
.github/workflows/release-ios.yml

22-22: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

.github/workflows/release-web.yml

21-21: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

.github/workflows/release-android.yml

22-22: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

.github/workflows/release-android-debug.yml

24-24: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: lint (20.x)
  • GitHub Check: unittest (20.x)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (20)
.github/workflows/release-web.yml (1)

20-24: 🧹 Nitpick (assertive)

Update Checkout Action Version
The "Checkout Source Code" step uses actions/checkout@v3. Consider checking if a newer version (for example, v4 if available) can offer enhanced performance and security.

-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
🧰 Tools
🪛 actionlint (1.7.4)

21-21: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

.github/workflows/daily-build-dev.yml (1)

15-24: 🧹 Nitpick (assertive)

Inspect the 'Setup ENV' step.
You compute a dynamic build number but then override it with a static value. Verify that this behavior is intentional. Also, please remove any trailing spaces from these lines.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 22-22: trailing spaces

(trailing-spaces)

.github/workflows/release-android-debug.yml (2)

76-84: Build APK step review.
The build commands look good and should generate the required artifacts. Confirm that the directory structure remains correct after the build.


23-27: 🧹 Nitpick (assertive)

Review the Checkout step.
The checkout action (actions/checkout@v3) is used here. While it works, verify if an upgrade to a newer version is preferred based on your CI requirements.

🧰 Tools
🪛 actionlint (1.7.4)

24-24: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

.github/workflows/release-android.yml (3)

67-67: Updated build.gradle Parameters
The versionName parameter now uses env.BUILD_APP_VERSION. Ensure that this environment variable is always set correctly upstream.


21-25: 🧹 Nitpick (assertive)

Update Checkout Action Version
The checkout step still uses actions/checkout@v3. Consider upgrading to a more recent version for improved stability and performance.

🧰 Tools
🪛 actionlint (1.7.4)

22-22: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 YAMLlint (1.35.1)

[error] 25-25: trailing spaces

(trailing-spaces)


87-94: 🧹 Nitpick (assertive)

Add WebEmbed Build Step
A new “Build WebEmbed” step is added. The environment variables and command look appropriate. Please double-check that NODE_OPTIONS and SENTRY_DISABLE_AUTO_UPLOAD meet your requirements. Also, remove any trailing spaces.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 94-94: trailing spaces

(trailing-spaces)

.github/workflows/release-ios.yml (1)

71-77: Update plist Modification for OneKeyWallet
The Modify OneKeyWallet info.plist step now uses env.BUILD_APP_VERSION correctly. Ensure that the buildNumber and versionName align with your external build configuration.

.github/workflows/release-desktop-snap.yml (1)

44-52: Setup ENV and Package Version Extraction
The "Setup ENV" step correctly extracts the package version and sets PKG_VERSION and ARTIFACTS_URL. The logic is clear and concise.

.github/workflows/release-desktop-winms.yml (1)

41-49: Setup ENV Consistency
The code extracts the package version and sets PKG_VERSION and ARTIFACTS_URL. Everything appears correct, so please verify the artifact URL if needed.

.github/workflows/release-desktop.yml (2)

40-48: Simplified ENV Extraction
The "Setup ENV" step now extracts the package version and sets necessary environment variables without redundant steps. This improves clarity.


149-161: Slack Notification Update
The Slack notification step passes artifact metadata. Confirm that artifact-version-name and artifact-version-code correctly reference env.BUILD_NUMBER. Consider checking if the dependency (steps.dotenv.outputs.version) is still valid after migrating to shared env setup.

🧰 Tools
🪛 actionlint (1.7.4)

158-158: property "dotenv" is not defined in object type {yarn-cache: {conclusion: string; outcome: string; outputs: {string => string}}; yarn-cache-dir-path: {conclusion: string; outcome: string; outputs: {string => string}}}

(expression)

.github/workflows/release-desktop-mas.yml (1)

39-46: Retain Environment Setup for Additional Values.
The subsequent “Setup ENV” step (lines 39–46) still calculates the package version and artifact URL. Verify that this step complements the shared env action and does not create conflicts.

.github/actions/shared-env/action.yml (7)

1-3: Action Metadata Clarity.
The metadata (name and description) is concise and clearly expresses the purpose of this composite action.


4-50: Comprehensive Input Definitions.
The inputs are well defined with clear types, requirements, and descriptions. This setup covers all the necessary keys (e.g., Sentry, Covalent, RevenueCat) to standardize environment injection across workflows. Consider including examples in the descriptions if needed in the future.


55-66: Checkout and Parameter Download Steps.
The steps to check out the source and download workflow parameters (lines 55–66) are implemented cleanly. The use of a conditional to trigger parameter download when a workflow run exists is effective.


85-90: Dotenv Action Integration.
Loading the “.env.version” file using the Dotenv Action is a neat solution. Ensure that the file is maintained properly so that the version output remains accurate.


91-108: Setting Up App Version and GitHub Tag.
The “Setup ENV” step processes the app version and converts the GitHub reference into a tag-friendly format. This string manipulation is pragmatic. Double-check that the replacement patterns match all possible ref formats.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 91-91: trailing spaces

(trailing-spaces)


112-122: Fallback Build Number Assignment.
When the workflow wasn’t triggered by a run event, setting BUILD_NUMBER to “1” is a simple and clear fallback.


147-182: Injecting Environment Variables.
This step consolidates multiple environment variables into the target env file. It covers all necessary keys, and the optional injection of additional variables is a flexible touch. Be sure that printing or logging these values does not inadvertently expose sensitive data.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 181-181: trailing spaces

(trailing-spaces)

.github/workflows/release-web.yml Show resolved Hide resolved
Comment on lines +26 to +31
- name: Save workflow parameters
run: |
mkdir -p ./workflow-data
echo "WORKFLOW_GITHUB_REF_NAME=${{ github.ref_name }}" >> ./workflow-data/params.env
echo "WORKFLOW_BUILD_NUMBER=1" >> ./workflow-data/params.env

Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Review the 'Save workflow parameters' step.
The parameters are stored as expected. Remember to remove any trailing spaces in these lines to comply with YAML lint rules.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 31-31: trailing spaces

(trailing-spaces)

Comment on lines +32 to +37
- name: Upload workflow parameters
uses: actions/upload-artifact@v4
with:
name: workflow-params
path: workflow-data/params.env
retention-days: 1
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Examine the 'Upload workflow parameters' step.
The artifact upload configuration is correct. Please clean up any trailing whitespace present in these lines.





Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

End-of-file cleanup.
A newline is missing and trailing spaces exist. Adding a final newline will improve file consistency.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 41-41: no new line character at the end of file

(new-line-at-end-of-file)


[error] 41-41: trailing spaces

(trailing-spaces)

Comment on lines +67 to +73
- name: Upload Test Report
uses: actions/upload-artifact@v4
if: always()
with:
name: test-report
path: test-report.html

Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

New 'Upload Test Report' step added.
The step is correctly configured to run always. However, there are extra blank lines that trigger YAML lint warnings; please remove them for better readability.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 73-73: too many blank lines

(1 > 0) (empty-lines)

Comment on lines +183 to +203
- name: Print ENV file content
shell: bash
run: |
echo "=== .env ==="
if [ -f .env ]; then
cat .env
fi
echo "--------------------------------"

echo "=== .env.expo ==="
if [ -f .env.expo ]; then
cat .env.expo
fi
echo "--------------------------------"

echo "=== .env.version ==="
if [ -f .env.version ]; then
cat .env.version
fi
echo "--------------------------------"

Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Print ENV File Content for Debugging.
Printing the contents of the .env files is useful for debugging. Just ensure that any sensitive information is masked or removed when in production logs.

echo "REVENUECAT_API_KEY_GOOGLE=${{ env.REVENUECAT_API_KEY_GOOGLE }}" >> ${TARGET_ENV_FILE}
if [[ ! -z "${{ inputs.additional_env }}" ]]; then
echo "${{ inputs.additional_env }}" >> ${TARGET_ENV_FILE}
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Trim Trailing Spaces in Injection Block.
There are trailing spaces at the end of line 181. Removing these will improve formatting compliance.

Proposed diff:

-        fi 
+        fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fi
fi
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 181-181: trailing spaces

(trailing-spaces)

workflow: daily-build-dev
name: workflow-params
run_id: ${{ github.event.workflow_run.id }}

Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Remove Trailing Spaces.
Line 67 contains extra trailing spaces. Cleaning these up will help with YAML linting.

Proposed diff:

-        lfs: true 
+        lfs: true
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
lfs: true
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 67-67: trailing spaces

(trailing-spaces)

with:
path: .env.version

- name: Setup ENV
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Eliminate Unnecessary Spaces.
There are unwanted trailing spaces on line 91. Removing them will make the YAML cleaner.

Proposed diff:

-      id: dotenv 
+      id: dotenv

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 91-91: trailing spaces

(trailing-spaces)

fi
echo "--------------------------------"


Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Remove Extra Blank Lines.
Line 204 shows too many blank lines at the end. Removing the extra lines will tidy up the file per YAML guidelines.

Proposed diff:

-  
-  
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# (The two extra blank lines at the end are removed)
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 204-204: too many blank lines

(2 > 0) (empty-lines)

@sidmorizon sidmorizon enabled auto-merge (squash) February 8, 2025 02:28
Comment on lines +183 to +203
- name: Print ENV file content
shell: bash
run: |
echo "=== .env ==="
if [ -f .env ]; then
cat .env
fi
echo "--------------------------------"

echo "=== .env.expo ==="
if [ -f .env.expo ]; then
cat .env.expo
fi
echo "--------------------------------"

echo "=== .env.version ==="
if [ -f .env.version ]; then
cat .env.version
fi
echo "--------------------------------"

Copy link
Contributor

Choose a reason for hiding this comment

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

这里 cat .env 会把环境变量文件打印出来?有泄露风险么?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

问题不大,github secrets 里的会自动变成 ****,其他的本身也会在前端代码里暴露出来

Copy link
Contributor Author

Choose a reason for hiding this comment

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

保险起见,这里先注释掉

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.

3 participants