Skip to content

Optimize cross platform check#3890

Merged
jolestar merged 3 commits into
mainfrom
ci/disk-optimization
Dec 31, 2025
Merged

Optimize cross platform check#3890
jolestar merged 3 commits into
mainfrom
ci/disk-optimization

Conversation

@jolestar

Copy link
Copy Markdown
Contributor

Summary

Summary about this PR

  • Closes #issue

Copilot AI review requested due to automatic review settings December 30, 2025 15:28
@vercel

vercel Bot commented Dec 30, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
rooch-portal-v2.1 Ready Ready Preview, Comment Dec 31, 2025 0:27am
test-portal Ready Ready Preview, Comment Dec 31, 2025 0:27am
1 Skipped Deployment
Project Deployment Review Updated (UTC)
rooch Ignored Ignored Preview Dec 31, 2025 0:27am

@github-actions

github-actions Bot commented Dec 30, 2025

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails
actions/actions/upload-artifact 4.*.* 🟢 6.5
Details
CheckScoreReason
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Maintained🟢 1030 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Code-Review🟢 10all changesets reviewed
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
Packaging⚠️ -1packaging workflow not detected
Binary-Artifacts🟢 10no binaries found in the repo
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Pinned-Dependencies⚠️ 1dependency not pinned by hash detected -- score normalized to 1
Fuzzing⚠️ 0project is not fuzzed
License🟢 10license file detected
Signed-Releases⚠️ -1no releases found
Security-Policy🟢 9security policy file detected
Branch-Protection⚠️ 0branch protection not enabled on development/release branches
Vulnerabilities🟢 100 existing vulnerabilities detected
SAST🟢 9SAST tool detected but not run on all commits

Scanned Files

  • .github/workflows/cross_platform_check.yml

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes the cross-platform build check workflow by introducing conditional build strategies based on the event type. For pull requests, it runs only a quick syntax check (cargo check) to minimize disk usage, while full debug builds are reserved for the main branch. The changes also add disk space monitoring, build failure diagnostics, and attempt to optimize caching configuration.

Key Changes

  • Conditional build strategy: cargo check for PRs vs full build for main branch
  • Added disk space monitoring before/after builds
  • Configured cargo environment variables to limit build jobs and improve network retry behavior

Comment on lines +191 to +198
# Cleanup on success to save disk space for other jobs
- name: Cleanup build artifacts (Main Branch Only)
if: success() && github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
echo "Cleaning up build artifacts to save disk space..."
cargo clean
echo "=== Cleanup completed ==="
df -h

Copilot AI Dec 30, 2025

Copy link

Choose a reason for hiding this comment

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

Running cargo clean after a successful build defeats the purpose of the rust-cache configuration. The cache is meant to speed up subsequent builds, but cleaning removes all build artifacts that would be cached. This step should be removed or reconsidered, as the cache action already handles optimal cache management.

Suggested change
# Cleanup on success to save disk space for other jobs
- name: Cleanup build artifacts (Main Branch Only)
if: success() && github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
echo "Cleaning up build artifacts to save disk space..."
cargo clean
echo "=== Cleanup completed ==="
df -h
# Cleanup step kept for observability; skip cargo clean to preserve Rust cache
- name: Cleanup build artifacts (Main Branch Only)
if: success() && github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
echo "Skipping 'cargo clean' to preserve Rust build cache. Disk usage after build:"
df -h

Copilot uses AI. Check for mistakes.
Comment on lines +56 to +58
- name: Check disk space before build
run: df -h

Copilot AI Dec 30, 2025

Copy link

Choose a reason for hiding this comment

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

The df -h command is not available on Windows by default. This step needs to be conditional or use a cross-platform alternative. Consider adding a shell-specific condition or using PowerShell equivalent Get-PSDrive for Windows.

Suggested change
- name: Check disk space before build
run: df -h
- name: Check disk space before build (Unix)
if: matrix.os != 'windows-latest'
run: df -h
- name: Check disk space before build (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
Get-PSDrive -PSProvider FileSystem

Copilot uses AI. Check for mistakes.
if: github.event_name == 'pull_request'
run: |
echo "Running quick check for PR (cargo check)..."
cargo check --target ${{ matrix.target }} --jobs 2 2>&1 | tail -50

Copilot AI Dec 30, 2025

Copy link

Choose a reason for hiding this comment

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

The tail command is not available in PowerShell by default on Windows. This will cause the PR check to fail on the Windows matrix job. Consider using Select-Object -Last 50 for Windows or make this command conditional.

Copilot uses AI. Check for mistakes.
echo "Running quick check for PR (cargo check)..."
cargo check --target ${{ matrix.target }} --jobs 2 2>&1 | tail -50
echo "=== Quick check completed ==="
df -h

Copilot AI Dec 30, 2025

Copy link

Choose a reason for hiding this comment

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

The df -h command is not available on Windows by default and will cause the quick check step to fail on Windows matrix jobs. Use a cross-platform approach or add conditional logic.

Copilot uses AI. Check for mistakes.
Comment on lines +154 to +156
- name: Build (Debug, Main Branch Only)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |

Copilot AI Dec 30, 2025

Copy link

Choose a reason for hiding this comment

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

The tee command is not available in PowerShell by default on Windows. This will cause the build step to fail on Windows matrix jobs. Consider using Tee-Object for Windows or redirecting output differently.

Suggested change
- name: Build (Debug, Main Branch Only)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
- name: Build (Debug, Main Branch Only, Windows)
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && matrix.os == 'windows-latest'
shell: pwsh
run: |
Write-Host "Starting full debug build for main branch (Windows)..."
cargo build --target ${{ matrix.target }} --jobs 2 2>&1 | Tee-Object -FilePath build.log
Write-Host "=== Build completed ==="
env:
OPENSSL_DIR: ${{ matrix.os == 'macos-latest' && '/usr/local/opt/openssl@3' || (matrix.os == 'ubuntu-latest' && '/usr' || '') }}
OPENSSL_LIB_DIR: ${{ matrix.os == 'macos-latest' && '/usr/local/opt/openssl@3/lib' || (matrix.os == 'ubuntu-latest' && '/usr/lib/x86_64-linux-gnu' || '') }}
OPENSSL_INCLUDE_DIR: ${{ matrix.os == 'macos-latest' && '/usr/local/opt/openssl@3/include' || (matrix.os == 'ubuntu-latest' && '/usr/include' || '') }}
LIBGIT2_SYS_USE_PKG_CONFIG: ${{ matrix.os == 'ubuntu-latest' && '1' || '0' }}
- name: Build (Debug, Main Branch Only, non-Windows)
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && matrix.os != 'windows-latest'
shell: bash
run: |

Copilot uses AI. Check for mistakes.
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
# Optimize for disk space and stability
CARGO_BUILD_JOBS: 2

Copilot AI Dec 30, 2025

Copy link

Choose a reason for hiding this comment

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

Setting CARGO_BUILD_JOBS: 2 globally limits parallel compilation to 2 jobs, which may significantly slow down builds on machines with more CPU cores (GitHub runners typically have 4 cores). While this may help with disk space, it trades off build speed. Consider if this trade-off aligns with the optimization goals, or make it conditional only for resource-constrained scenarios.

Suggested change
CARGO_BUILD_JOBS: 2

Copilot uses AI. Check for mistakes.
Comment on lines +192 to +198
- name: Cleanup build artifacts (Main Branch Only)
if: success() && github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
echo "Cleaning up build artifacts to save disk space..."
cargo clean
echo "=== Cleanup completed ==="
df -h

Copilot AI Dec 30, 2025

Copy link

Choose a reason for hiding this comment

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

The df -h command is not available on Windows. Since this cleanup step only runs on main branch, and the diagnostic command will fail on Windows, add OS-specific conditionals or remove the diagnostic command from Windows runs.

Suggested change
- name: Cleanup build artifacts (Main Branch Only)
if: success() && github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
echo "Cleaning up build artifacts to save disk space..."
cargo clean
echo "=== Cleanup completed ==="
df -h
- name: Cleanup build artifacts (Main Branch Only, non-Windows)
if: success() && github.event_name == 'push' && github.ref == 'refs/heads/main' && matrix.os != 'windows-latest'
run: |
echo "Cleaning up build artifacts to save disk space..."
cargo clean
echo "=== Cleanup completed ==="
df -h
- name: Cleanup build artifacts (Main Branch Only, Windows)
if: success() && github.event_name == 'push' && github.ref == 'refs/heads/main' && matrix.os == 'windows-latest'
run: |
echo "Cleaning up build artifacts to save disk space..."
cargo clean
echo "=== Cleanup completed ==="

Copilot uses AI. Check for mistakes.
Comment on lines +69 to +70
cache-targets: true
cache-all-crates: true

Copilot AI Dec 30, 2025

Copy link

Choose a reason for hiding this comment

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

The options cache-targets and cache-all-crates do not exist in rust-cache@v2. The valid options are: key, shared-key, prefix-key, cache-directories, cache-on-failure, workspaces, save-if, and cache-provider. These invalid options will be silently ignored, which may not provide the intended optimization benefits.

Suggested change
cache-targets: true
cache-all-crates: true

Copilot uses AI. Check for mistakes.
name: build-failure-${{ matrix.os }}-${{ matrix.target }}
path: |
build.log
target/

Copilot AI Dec 30, 2025

Copy link

Choose a reason for hiding this comment

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

Uploading the entire target/ directory on build failure could be extremely large (10-20GB as mentioned in comments) and may cause the upload action to fail or consume excessive storage. Consider uploading only relevant failure artifacts like error logs, or add size limits to prevent storage issues.

Suggested change
target/
if-no-files-found: ignore

Copilot uses AI. Check for mistakes.
with:
name: build-failure-${{ matrix.os }}-${{ matrix.target }}
path: |
build.log

Copilot AI Dec 30, 2025

Copy link

Choose a reason for hiding this comment

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

The build.log file will only be created during the full build step (line 158), which only runs for main branch pushes. However, this upload step runs on failure() for all workflow runs including PR builds. For PR builds, the build.log won't exist since only cargo check runs. Consider making this path conditional based on the event type.

Copilot uses AI. Check for mistakes.
@jolestar jolestar merged commit 1cfef0e into main Dec 31, 2025
13 of 16 checks passed
@jolestar jolestar deleted the ci/disk-optimization branch December 31, 2025 00:24
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.

2 participants