feat(cli): implement upgrade command #8
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Integration Tests | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - 'src/**' | |
| - 'Cargo.toml' | |
| - 'Cargo.lock' | |
| - 'tests/**' | |
| - '.github/workflows/integration-test.yml' | |
| pull_request: | |
| branches: [ main ] | |
| paths: | |
| - 'src/**' | |
| - 'Cargo.toml' | |
| - 'Cargo.lock' | |
| - 'tests/**' | |
| - '.github/workflows/integration-test.yml' | |
| permissions: | |
| contents: read | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| integration-test: | |
| name: E2E Tests (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| binary: rnr | |
| shell: bash | |
| - os: macos-latest | |
| binary: rnr | |
| shell: bash | |
| - os: windows-latest | |
| binary: rnr.exe | |
| shell: bash | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Build release binary | |
| run: cargo build --release | |
| - name: Copy binary to test location | |
| shell: bash | |
| run: | | |
| cp target/release/${{ matrix.binary }} tests/ | |
| # ==================== Basic Tests ==================== | |
| - name: "Test: --help" | |
| shell: bash | |
| working-directory: tests | |
| run: | | |
| echo "## --help output" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| ./${{ matrix.binary }} --help >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| - name: "Test: --version" | |
| shell: bash | |
| working-directory: tests | |
| run: | | |
| ./${{ matrix.binary }} --version | |
| - name: "Test: --list (basic fixture)" | |
| shell: bash | |
| working-directory: tests/fixtures/basic | |
| run: | | |
| echo "## --list output (basic)" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| ../../${{ matrix.binary }} --list >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| # ==================== Basic Task Execution ==================== | |
| - name: "Test: shorthand task" | |
| shell: bash | |
| working-directory: tests/fixtures/basic | |
| run: | | |
| OUTPUT=$(../../${{ matrix.binary }} hello 2>&1) | |
| echo "$OUTPUT" | |
| if ! echo "$OUTPUT" | grep -q "Hello, World!"; then | |
| echo "ERROR: Expected 'Hello, World!' in output" | |
| exit 1 | |
| fi | |
| echo "✅ Shorthand task passed" | |
| - name: "Test: full task with description" | |
| shell: bash | |
| working-directory: tests/fixtures/basic | |
| run: | | |
| OUTPUT=$(../../${{ matrix.binary }} build 2>&1) | |
| echo "$OUTPUT" | |
| if ! echo "$OUTPUT" | grep -q "Building project"; then | |
| echo "ERROR: Expected 'Building project' in output" | |
| exit 1 | |
| fi | |
| echo "✅ Full task passed" | |
| - name: "Test: task with environment variables" | |
| shell: bash | |
| working-directory: tests/fixtures/basic | |
| run: | | |
| OUTPUT=$(../../${{ matrix.binary }} with-env 2>&1) | |
| echo "$OUTPUT" | |
| if ! echo "$OUTPUT" | grep -q "Environment variables are set"; then | |
| echo "ERROR: Expected 'Environment variables are set' in output" | |
| exit 1 | |
| fi | |
| echo "✅ Environment variables task passed" | |
| # ==================== Steps Tests ==================== | |
| - name: "Test: sequential steps" | |
| shell: bash | |
| working-directory: tests/fixtures/steps | |
| run: | | |
| OUTPUT=$(../../${{ matrix.binary }} sequential 2>&1) | |
| echo "$OUTPUT" | |
| if ! echo "$OUTPUT" | grep -q "Step 1"; then | |
| echo "ERROR: Expected 'Step 1' in output" | |
| exit 1 | |
| fi | |
| if ! echo "$OUTPUT" | grep -q "Step 2"; then | |
| echo "ERROR: Expected 'Step 2' in output" | |
| exit 1 | |
| fi | |
| if ! echo "$OUTPUT" | grep -q "Step 3"; then | |
| echo "ERROR: Expected 'Step 3' in output" | |
| exit 1 | |
| fi | |
| echo "✅ Sequential steps passed" | |
| - name: "Test: task delegation in steps" | |
| shell: bash | |
| working-directory: tests/fixtures/steps | |
| run: | | |
| OUTPUT=$(../../${{ matrix.binary }} delegate 2>&1) | |
| echo "$OUTPUT" | |
| if ! echo "$OUTPUT" | grep -q "Running step A"; then | |
| echo "ERROR: Expected 'Running step A' in output" | |
| exit 1 | |
| fi | |
| if ! echo "$OUTPUT" | grep -q "Running step B"; then | |
| echo "ERROR: Expected 'Running step B' in output" | |
| exit 1 | |
| fi | |
| if ! echo "$OUTPUT" | grep -q "Running step C"; then | |
| echo "ERROR: Expected 'Running step C' in output" | |
| exit 1 | |
| fi | |
| echo "✅ Task delegation passed" | |
| - name: "Test: mixed sequential and parallel" | |
| shell: bash | |
| working-directory: tests/fixtures/steps | |
| run: | | |
| OUTPUT=$(../../${{ matrix.binary }} mixed 2>&1) | |
| echo "$OUTPUT" | |
| if ! echo "$OUTPUT" | grep -q "Starting"; then | |
| echo "ERROR: Expected 'Starting' in output" | |
| exit 1 | |
| fi | |
| if ! echo "$OUTPUT" | grep -q "Parallel task 1"; then | |
| echo "ERROR: Expected 'Parallel task 1' in output" | |
| exit 1 | |
| fi | |
| if ! echo "$OUTPUT" | grep -q "Parallel task 2"; then | |
| echo "ERROR: Expected 'Parallel task 2' in output" | |
| exit 1 | |
| fi | |
| if ! echo "$OUTPUT" | grep -q "Done"; then | |
| echo "ERROR: Expected 'Done' in output" | |
| exit 1 | |
| fi | |
| echo "✅ Mixed steps passed" | |
| # ==================== Nested Task Tests ==================== | |
| - name: "Test: command in subdirectory" | |
| shell: bash | |
| working-directory: tests/fixtures/nested | |
| run: | | |
| OUTPUT=$(../../${{ matrix.binary }} run-in-subdir 2>&1) | |
| echo "$OUTPUT" | |
| if ! echo "$OUTPUT" | grep -q "Running in subproject directory"; then | |
| echo "ERROR: Expected 'Running in subproject directory' in output" | |
| exit 1 | |
| fi | |
| echo "✅ Command in subdirectory passed" | |
| - name: "Test: nested task delegation" | |
| shell: bash | |
| working-directory: tests/fixtures/nested | |
| run: | | |
| OUTPUT=$(../../${{ matrix.binary }} build-subproject 2>&1) | |
| echo "$OUTPUT" | |
| if ! echo "$OUTPUT" | grep -q "Building subproject"; then | |
| echo "ERROR: Expected 'Building subproject' in output" | |
| exit 1 | |
| fi | |
| echo "✅ Nested task delegation passed" | |
| # ==================== Init Command Tests ==================== | |
| - name: "Test: init --current-platform-only" | |
| shell: bash | |
| run: | | |
| INIT_DIR=$(mktemp -d) | |
| cd "$INIT_DIR" | |
| $GITHUB_WORKSPACE/tests/${{ matrix.binary }} init --current-platform-only | |
| # Verify files were created | |
| if [ ! -f ".rnr/config.yaml" ]; then | |
| echo "ERROR: .rnr/config.yaml not created" | |
| exit 1 | |
| fi | |
| if [ ! -d ".rnr/bin" ]; then | |
| echo "ERROR: .rnr/bin directory not created" | |
| exit 1 | |
| fi | |
| if [ ! -f "rnr.yaml" ]; then | |
| echo "ERROR: rnr.yaml not created" | |
| exit 1 | |
| fi | |
| if [ ! -f "rnr" ]; then | |
| echo "ERROR: rnr wrapper not created" | |
| exit 1 | |
| fi | |
| if [ ! -f "rnr.cmd" ]; then | |
| echo "ERROR: rnr.cmd wrapper not created" | |
| exit 1 | |
| fi | |
| # Verify config has exactly one platform | |
| PLATFORM_COUNT=$(grep -c "^-" .rnr/config.yaml || echo "0") | |
| if [ "$PLATFORM_COUNT" != "1" ]; then | |
| echo "ERROR: Expected 1 platform, got $PLATFORM_COUNT" | |
| exit 1 | |
| fi | |
| echo "✅ init --current-platform-only passed" | |
| rm -rf "$INIT_DIR" | |
| - name: "Test: init --platforms with multiple platforms" | |
| shell: bash | |
| run: | | |
| INIT_DIR=$(mktemp -d) | |
| cd "$INIT_DIR" | |
| $GITHUB_WORKSPACE/tests/${{ matrix.binary }} init --platforms linux-amd64,macos-arm64,windows-amd64 | |
| # Verify config has the right platforms | |
| if ! grep -q "linux-amd64" .rnr/config.yaml; then | |
| echo "ERROR: linux-amd64 not in config" | |
| exit 1 | |
| fi | |
| if ! grep -q "macos-arm64" .rnr/config.yaml; then | |
| echo "ERROR: macos-arm64 not in config" | |
| exit 1 | |
| fi | |
| if ! grep -q "windows-amd64" .rnr/config.yaml; then | |
| echo "ERROR: windows-amd64 not in config" | |
| exit 1 | |
| fi | |
| # Verify binaries exist | |
| if [ ! -f ".rnr/bin/rnr-linux-amd64" ]; then | |
| echo "ERROR: rnr-linux-amd64 binary not created" | |
| exit 1 | |
| fi | |
| if [ ! -f ".rnr/bin/rnr-macos-arm64" ]; then | |
| echo "ERROR: rnr-macos-arm64 binary not created" | |
| exit 1 | |
| fi | |
| if [ ! -f ".rnr/bin/rnr-windows-amd64.exe" ]; then | |
| echo "ERROR: rnr-windows-amd64.exe binary not created" | |
| exit 1 | |
| fi | |
| echo "✅ init --platforms passed" | |
| rm -rf "$INIT_DIR" | |
| - name: "Test: init --add-platform and --remove-platform" | |
| shell: bash | |
| run: | | |
| INIT_DIR=$(mktemp -d) | |
| cd "$INIT_DIR" | |
| # First init with one platform | |
| $GITHUB_WORKSPACE/tests/${{ matrix.binary }} init --platforms linux-amd64 | |
| # Add a platform | |
| $GITHUB_WORKSPACE/tests/${{ matrix.binary }} init --add-platform macos-arm64 | |
| if ! grep -q "macos-arm64" .rnr/config.yaml; then | |
| echo "ERROR: macos-arm64 not added to config" | |
| exit 1 | |
| fi | |
| if [ ! -f ".rnr/bin/rnr-macos-arm64" ]; then | |
| echo "ERROR: rnr-macos-arm64 binary not created" | |
| exit 1 | |
| fi | |
| # Remove a platform | |
| $GITHUB_WORKSPACE/tests/${{ matrix.binary }} init --remove-platform linux-amd64 | |
| if grep -q "linux-amd64" .rnr/config.yaml; then | |
| echo "ERROR: linux-amd64 should have been removed from config" | |
| exit 1 | |
| fi | |
| if [ -f ".rnr/bin/rnr-linux-amd64" ]; then | |
| echo "ERROR: rnr-linux-amd64 binary should have been removed" | |
| exit 1 | |
| fi | |
| echo "✅ init --add-platform and --remove-platform passed" | |
| rm -rf "$INIT_DIR" | |
| - name: "Test: init --show-platforms" | |
| shell: bash | |
| run: | | |
| INIT_DIR=$(mktemp -d) | |
| cd "$INIT_DIR" | |
| $GITHUB_WORKSPACE/tests/${{ matrix.binary }} init --platforms linux-amd64,windows-amd64 | |
| OUTPUT=$($GITHUB_WORKSPACE/tests/${{ matrix.binary }} init --show-platforms 2>&1) | |
| if ! echo "$OUTPUT" | grep -q "linux-amd64"; then | |
| echo "ERROR: --show-platforms should list linux-amd64" | |
| exit 1 | |
| fi | |
| if ! echo "$OUTPUT" | grep -q "windows-amd64"; then | |
| echo "ERROR: --show-platforms should list windows-amd64" | |
| exit 1 | |
| fi | |
| echo "✅ init --show-platforms passed" | |
| rm -rf "$INIT_DIR" | |
| - name: "Test: init refuses to remove last platform" | |
| shell: bash | |
| run: | | |
| INIT_DIR=$(mktemp -d) | |
| cd "$INIT_DIR" | |
| $GITHUB_WORKSPACE/tests/${{ matrix.binary }} init --platforms linux-amd64 | |
| # Try to remove the only platform - should fail | |
| if $GITHUB_WORKSPACE/tests/${{ matrix.binary }} init --remove-platform linux-amd64 2>&1; then | |
| echo "ERROR: Should not be able to remove last platform" | |
| exit 1 | |
| fi | |
| echo "✅ init correctly refuses to remove last platform" | |
| rm -rf "$INIT_DIR" | |
| # ==================== Error Cases ==================== | |
| - name: "Test: nonexistent task (should fail)" | |
| shell: bash | |
| working-directory: tests/fixtures/basic | |
| run: | | |
| if ../../${{ matrix.binary }} nonexistent 2>&1; then | |
| echo "ERROR: Expected nonexistent task to fail" | |
| exit 1 | |
| fi | |
| echo "✅ Nonexistent task correctly failed" | |
| # ==================== Summary ==================== | |
| - name: Generate test summary | |
| if: always() | |
| shell: bash | |
| run: | | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "## Integration Test Results - ${{ matrix.os }}" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "✅ All integration tests completed" >> $GITHUB_STEP_SUMMARY |