Set up or verify the three-layer test structure (unit, activity, workflow) for a Python Temporal workflow project: tests/unit, tests/activity, tests/workflow subdirectories, corresponding Makefile targets (test, test-unit, test-activity, test-workflow), and matching steps in .github/workflows/ci.yaml. Use when asked to set up tests, add test layers, wire up CI testing, or fix test/Makefile/CI structure for a Temporal workflow project.
94%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Ensures a Python Temporal workflow project has the standard three-layer test
layout (unit, activity, workflow), Makefile targets to run each layer
individually and all together, and a CI workflow that runs each layer as a
separate step via make.
This repository is a monorepo where each Temporal project lives under
workflows/<project_name>/ with its own Makefile, pyproject.toml, and
tests/ directory (see workflows/template/ for the canonical layout).
Always determine the target project directory first — do not assume the
repository root. If the user did not specify a project, ask which
workflows/<name>/ directory to operate on, or infer it from the current
working directory.
tests/unit, tests/activity, tests/workflow subdirectories existIn the target project directory:
tests/unit, tests/activity, and tests/workflow already
exist.mkdir -p.tests/__init__.py (check the current
tests/ directory), add matching empty __init__.py files to each new
subdirectory for consistency.tests/ that look like they belong in one of the three layers,
and ask the user before moving them, since this can break coverage/CI
expectations if done blindly.test, test-unit, test-activity, test-workflow targetsRead the project's Makefile first. Follow its existing conventions (e.g.
$(POETRY) run $(PYTEST), --cov=$(PY_PACKAGE) flag, .PHONY declarations)
instead of inventing a new style. A typical existing test target looks like:
.PHONY: test
test: ## Run tests
$(POETRY) run $(PYTEST) --cov=$(PY_PACKAGE) testsRework it into four targets, each .PHONY, using the same pytest invocation
style but scoped to the relevant subdirectory, with test depending on the
other three so make test still runs everything:
.PHONY: test-unit
test-unit: ## Run unit tests
$(POETRY) run $(PYTEST) --cov=$(PY_PACKAGE) tests/unit
.PHONY: test-activity
test-activity: ## Run activity tests
$(POETRY) run $(PYTEST) --cov=$(PY_PACKAGE) tests/activity
.PHONY: test-workflow
test-workflow: ## Run workflow tests
$(POETRY) run $(PYTEST) --cov=$(PY_PACKAGE) tests/workflow
.PHONY: test
test: test-unit test-activity test-workflow ## Run all testsOnly add targets that are missing; if test-unit/test-activity/test-workflow
already exist, leave them alone unless they don't point at the right
directory. Preserve any other targets (lint, fmt, check, etc.) and their
dependency on test (e.g. check: clean install-dev lint test) unchanged.
.github/workflows/ci.yaml runs each layer as a separate step via make.github/workflows/ci.yaml, add or
update it there..github/workflows/ci.yaml
(which drives testing indirectly through the reusable
.github/workflows/check_make.yaml workflow and matrix of changed
directories), do not fork the whole pipeline. Instead:
Confirm check_make.yaml's single command: test input already fans out
correctly, since make test now runs all three layers in sequence
(from step 2). This satisfies "runs all tests" automatically.
If the user explicitly wants the three layers visible as separate
steps/jobs in CI output (not just one make test step), add three
sequential steps to the relevant workflow, each invoking make directly,
for example:
- name: Run unit tests
run: |
cd workflows/${{ matrix.dir }}
make test-unit
- name: Run activity tests
run: |
cd workflows/${{ matrix.dir }}
make test-activity
- name: Run workflow tests
run: |
cd workflows/${{ matrix.dir }}
make test-workflowNever invoke pytest directly — always go through the make
targets so local and CI behavior stay identical.
.github/workflows/ci.yaml, add three steps calling make test-unit,
make test-activity, and make test-workflow respectively (after any
install/lint steps), instead of a single make test step.After making changes:
make -n test test-unit test-activity test-workflow in the project
directory to confirm all targets resolve without executing them.make test-unit (and the other two) if a working Python/Poetry
environment is available, to confirm they actually collect tests (even
zero tests is fine for empty new directories — a pytest "no tests
collected" exit code is expected until tests are added).ci.yaml with yamllint or a YAML parser if available,
since indentation errors here silently break CI.canonical/copilot-collections
481cc93
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.