Semaphore
Create a secret named visualci with the environment variable VISUALCI_TOKEN (a project token). The CLI reads the commit from SEMAPHORE_GIT_PR_SHA or SEMAPHORE_GIT_SHA, the branch from SEMAPHORE_GIT_PR_BRANCH or SEMAPHORE_GIT_BRANCH, and the pull request from SEMAPHORE_GIT_PR_NUMBER.
version: v1.0
name: Tests
agent:
machine:
type: e1-standard-2
os_image: ubuntu2204
blocks:
- name: Test
task:
secrets:
- name: visualci
jobs:
- name: Test
commands:
- checkout
- curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.5 VISUALCI_INSTALL_DIR="$HOME/bin" sh
- export PATH="$HOME/bin:$PATH"
- export VISUALCI_BUILD_ID=$(visualci build create)
- npm test -- -u # write snapshots instead of failing; see the snapshot guides
- visualci upload --from auto src tests
- visualci build finalize
Parallelism
With parallelism: <n>, every job creates the build with the workflow's id and finalizes its own shard. Semaphore numbers jobs from 1, VisualCI from 0:
export VISUALCI_BUILD_ID=$(visualci build create --nonce "$SEMAPHORE_WORKFLOW_ID" --shards "$SEMAPHORE_JOB_COUNT")
# ... tests and uploads ...
visualci build finalize --shard "$((SEMAPHORE_JOB_INDEX - 1))"
See Other CI providers for the environment variables and how shards work.