From e1420ca7dd3970743f085a02b29e1f2ec4179fa6 Mon Sep 17 00:00:00 2001 From: Bryan Oltman Date: Fri, 7 Jul 2023 13:00:01 -0400 Subject: [PATCH] chore: add basic e2e test to shorebird_cli (#773) --- .github/workflows/e2e.yaml | 42 +++++++++++++++---- .../shorebird_cli_integration_test.dart | 19 +++++++++ 2 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 packages/shorebird_cli/integration_test/shorebird_cli_integration_test.dart diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 55d04ceb..daf49036 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -9,15 +9,12 @@ env: SHOREBIRD_TOKEN: ${{ secrets.SHOREBIRD_TOKEN }} jobs: - verify_cli_installation: + test: strategy: fail-fast: false matrix: os: [macos-latest, windows-latest, ubuntu-latest] - - defaults: - run: - shell: bash + package: [packages/shorebird_cli] runs-on: ${{ matrix.os }} @@ -25,11 +22,42 @@ jobs: - name: 📚 Git Checkout uses: actions/checkout@v3 - - name: 🐦 Verify Shorebird Installation (${{ matrix.os }}) + - name: Add Shorebird to macOS/Linux PATH + shell: bash + if: runner.os != 'Windows' + run: echo "${GITHUB_WORKSPACE}/bin/" >> $GITHUB_PATH + + - name: 🐦 Verify Shorebird Installation (macOS / Linux) + if: runner.os != 'Windows' run: | - if [[ $(./bin/shorebird --version) =~ "Shorebird Engine • revision" ]]; then + if [[ $(shorebird --version) =~ "Shorebird Engine • revision" ]]; then echo '✅ Shorebird CLI is installed!' else echo '❌ Shorebird CLI is not installed.' exit 1 fi + shell: bash + + - name: Add Shorebird to Windows PATH + shell: pwsh + if: runner.os == 'Windows' + run: Add-Content $env:GITHUB_PATH "${env:GITHUB_WORKSPACE}\bin" + + - name: 🐦 Verify Shorebird Installation (Windows) + if: runner.os == 'Windows' + run: | + $shorebird_version = shorebird --version + if ($shorebird_version -match "Shorebird Engine") { + Write-Output "✅ Shorebird CLI is installed!" + } else { + Write-Output "❌ Shorebird CLI is not installed." + exit 1 + } + shell: pwsh + + - name: 🎯 Set up dart + uses: dart-lang/setup-dart@v1 + + - name: Run Integration Tests + run: dart test integration_test + working-directory: packages/shorebird_cli diff --git a/packages/shorebird_cli/integration_test/shorebird_cli_integration_test.dart b/packages/shorebird_cli/integration_test/shorebird_cli_integration_test.dart new file mode 100644 index 00000000..57f1e02d --- /dev/null +++ b/packages/shorebird_cli/integration_test/shorebird_cli_integration_test.dart @@ -0,0 +1,19 @@ +import 'dart:io'; + +import 'package:test/test.dart'; + +void main() { + test('--version', () async { + final result = await Process.run( + 'shorebird', + ['--version'], + runInShell: true, + ); + expect(result.stderr, isEmpty); + expect( + result.stdout, + stringContainsInOrder(['Shorebird Engine', 'revision']), + ); + expect(result.exitCode, 0); + }); +}