CI Foundry

Note

This document provides an overview of the testing strategy for the foundryup.sh script in the CI/CD environment.

Non-Interactive Design: The script now assumes it is running in a CI/CD environment, thus ensuring it can run without human interaction.

Consistent Logging: Ensures all log messages are consistent and CI-friendly. Automatic Directory Creation: Automatically creates necessary directories and ensures no manual intervention is required.

Simplified Argument Parsing: Simplified argument parsing to make it more robust for automated environments.

Error Handling: Enhanced error handling to ensure the script fails fast and provides meaningful error messages for debugging in CI/CD logs.

Steps for Creating Tests

  1. Basic Command Execution:

    • Ensure essential commands like git, curl, and cargo are called.
  2. Argument Parsing:

    • Test with different combinations of arguments to verify proper parsing.
  3. Environment Setup:

    • Ensure environment variables and directories are set up correctly.
  4. Platform and Architecture Handling:

    • Verify correct handling of different platforms and architectures.
  5. Error Handling:

    • Ensure proper error messages are displayed for invalid inputs or failures.
  6. File and Directory Operations:

    • Test file and directory creation, deletion, and symlinking operations.
  7. Function Output Verification:

    • Verify output of functions like say, warn, and err.
  8. Binary Installation:

    • Ensure binaries are downloaded and installed correctly.
  9. Local Repository Installation:

    • Verify installation from a local repository.
  10. Help Message:

    • Ensure the help message is displayed correctly.

Explanation of Each Test

  1. Basic Command Execution:

    • Tests that git and curl commands are called during the script execution.
  2. Argument Parsing:

    • Ensures the script handles unknown options correctly and displays an appropriate warning message.
  3. Environment Setup:

    • Tests that cd and cargo commands are called when installing from a local repository.
  4. Platform and Architecture Handling:

    • Verifies the script handles platform and architecture correctly.
  5. Error Handling:

    • Ensures the ensure function fails correctly when a command fails.
    • Tests that warn, say, and err functions display messages correctly.
  6. Help Message:

    • Ensures the help message is displayed correctly with the --help option.

These tests cover various aspects of the script to ensure it works correctly in a CI/CD environment.