Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write a script to run e2e test #237

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ internal/api/pacts/

dist/
node_modules/

internal/runner/testdata/jest/jest-result.json

internal/runner/testdata/rspec/rspec-result.json
34 changes: 34 additions & 0 deletions bin/e2e
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

# This script is used to run bktec against the sample project for the given test runner.
# Sample project can be found in internal/runner/testdata/<test-runner>
#
# Usage: ./bin/e2e <test-runner> <parallel-job>
#
# Note: you need to manually set the following environment variables
# - BUILDKITE_ORGANIZATION_SLUG
# - BUILDKITE_TEST_ENGINE_API_ACCESS_TOKEN
# - BUILDKITE_TEST_ENGINE_SUITE_SLUG

export BUILDKITE_BUILD_ID=$(uuidgen)
export BUILDKITE_PARALLEL_JOB=${2:-0}
export BUILDKITE_PARALLEL_JOB_COUNT=2
export BUILDKITE_STEP_ID=$BUILDKITE_TEST_ENGINE_TEST_RUNNER
export BUILDKITE_TEST_ENGINE_RESULT_PATH="${BUILDKITE_TEST_ENGINE_TEST_RUNNER}-result.json"
export BUILDKITE_TEST_ENGINE_TEST_RUNNER=${1:-rspec}

# Override the following variables to the default value, in case they are set somewhere else
export BUILDKITE_TEST_ENGINE_TEST_CMD=""
export BUILDKITE_TEST_ENGINE_TEST_FILE_PATTERN=""

# Extra configuration for playwright
if [ "$BUILDKITE_TEST_ENGINE_TEST_RUNNER" == "playwright" ]; then
# We need to tell bktec to use playwright's result path configured in playwright.config.js
export BUILDKITE_TEST_ENGINE_RESULT_PATH="test-results/results.json"
# error.spec.js will prevent other tests from running, so we exclude it
export BUILDKITE_TEST_ENGINE_TEST_FILE_EXCLUDE_PATTERN="**/*/error.spec.js"
fi

cd ./internal/runner/testdata/$BUILDKITE_TEST_ENGINE_TEST_RUNNER

go run ../../../../main.go
5 changes: 5 additions & 0 deletions internal/runner/testdata/rspec/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true
Copy link
Contributor Author

@nprizal nprizal Dec 10, 2024

Choose a reason for hiding this comment

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

I added this so we can run bktec from this project using the default command bundle exec rspec ...


source "https://rubygems.org"

gem "rspec"
27 changes: 27 additions & 0 deletions internal/runner/testdata/rspec/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.5.1)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.2)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.2)

PLATFORMS
arm64-darwin-23
ruby

DEPENDENCIES
rspec

BUNDLED WITH
2.5.16