Skip to content

update

update #8

name: Validate Generated Code
on:
pull_request: # Typically, you'd want this on PRs to catch issues before merge
branches:
- main # Or your default branch, e.g., 'master'
push:
branches:
- main # Also useful on push to ensure main is always clean
workflow_dispatch: # Allows manual triggering from the GitHub UI
jobs:
validate_generated_code:
runs-on: ubuntu-latest # Or your preferred runner environment
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20' # Specify your Node.js version
# Removed 'cache: yarn' to prevent potential conflicts with Corepack's management.
- name: Enable Corepack and Install dependencies
run: |
corepack enable # This command enables Corepack to manage package managers like Yarn 2+
# Explicitly use 'corepack yarn' to ensure the correct Yarn version is invoked
corepack yarn install --frozen-lockfile # Use --frozen-lockfile for CI environments
- name: Set up Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable # Install the latest stable Rust toolchain
override: true
profile: minimal # Install minimal components for faster setup
- name: Install Solana CLI and Verify build-sbf
run: |
# Use --tlsv1.2 to explicitly specify TLSv1.2, which might resolve SSL handshake issues.
sh -c "$(curl -sSfL --tlsv1.2 https://release.solana.com/stable/install)"
# Add Solana CLI to PATH for current and subsequent steps
SOLANA_INSTALL_DIR="$HOME/.local/share/solana/install/active/bin"
echo "$SOLANA_INSTALL_DIR" >> $GITHUB_PATH
# Verify that build-sbf is now in PATH and callable
echo "Verifying build-sbf availability..."
which build-sbf || { echo "Error: 'build-sbf' command not found in PATH after Solana CLI installation."; exit 1; }
build-sbf --version || { echo "Error: 'build-sbf' command is in PATH but not callable or returned an error."; exit 1; }
echo "'build-sbf' verified successfully."
- name: Build code
run: corepack yarn build # Also use 'corepack yarn' for the build step
- name: Check for uncommitted generated changes
run: |
# Check if there are any uncommitted changes after the build
if git status --porcelain | grep -q .; then
echo "Error: Generated code differences detected!"
echo "Please run 'yarn build' locally and commit the changes."
git status --porcelain # Show the specific files that are different
exit 1 # Fail the workflow
else
echo "No differences found in generated code. Build is clean."
fi