Semaphore
Selective detects Semaphore automatically, including the pull request branch and commit range when there is one. No setup step is needed beyond the secret.
Create a secret containing SELECTIVE_API_KEY, attach it to the pipeline, and swap the test command:
- name: Tests commands: - bundle exec selective rspecRun the command in as many parallel jobs as you want nodes. A working pipeline is in the selective-ruby-rspec repository.
Daily map recording
Section titled “Daily map recording”Test selection needs a fresh map of which files each test executes. Create a task that runs the pipeline daily on the default branch, with a parameter SELECTIVE_TEST_MAP_RECORD whose value is 1. Task parameters reach the jobs as environment variables, so the scheduled run’s tests print Recording a test map. See keeping the map fresh.
Warm-up
Section titled “Warm-up”With test selection on, a block that tells Selective about the run as the pipeline starts has the commit’s file tree, the map and the semantic decision ready before the test jobs connect. See warm-up.
blocks: - name: Selective warm-up dependencies: [] task: secrets: - name: selective jobs: - name: warm-up commands: - | BASE=""; [ -n "$SEMAPHORE_GIT_COMMIT_RANGE" ] && BASE="${SEMAPHORE_GIT_COMMIT_RANGE%%...*}" TARGET=""; [ -n "$SEMAPHORE_GIT_PR_BRANCH" ] && TARGET="$SEMAPHORE_GIT_BRANCH" curl -sS --max-time 20 -X POST https://app.selective.ci/warmup \ -H "authorization: $SELECTIVE_API_KEY" -H "content-type: application/json" \ -d "{\"sha\": \"$SEMAPHORE_GIT_SHA\", \"git_repo_full_name\": \"$SEMAPHORE_GIT_REPO_SLUG\", \"base_sha\": \"$BASE\", \"target_branch\": \"$TARGET\", \"branch\": \"${SEMAPHORE_GIT_PR_BRANCH:-$SEMAPHORE_GIT_BRANCH}\"}" \ || true - name: Tests dependencies: [] task: secrets: - name: selective jobs: - name: tests parallelism: 4 commands: - checkout - bundle exec selective rspecdependencies: [] on both blocks starts them together. The base and target are computed the same way the runner computes them on Semaphore.