Skip to content
Merged
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
41 changes: 41 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: test
run-name: tests by @${{ github.actor }}

on:
pull_request:
branches: [main]
push:
branches: [main]

permissions:
contents: read

concurrency:
group: test-${{ github.ref }}
cancel-in-progress: true

jobs:
unit:
name: Unit tests (bats)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install yq
run: |
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq

- name: Run unit tests
run: make test-unit

lint:
Comment thread Fixed
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Run shellcheck
run: shellcheck --severity=error src/crabcode
Comment thread Fixed
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "tests/bats"]
path = tests/bats
url = https://github.com/bats-core/bats-core.git
[submodule "tests/test_helper/bats-support"]
path = tests/test_helper/bats-support
url = https://github.com/bats-core/bats-support.git
[submodule "tests/test_helper/bats-assert"]
path = tests/test_helper/bats-assert
url = https://github.com/bats-core/bats-assert.git
22 changes: 15 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
.PHONY: test test-docker test-e2e install lint help
.PHONY: test test-unit test-integration test-docker test-e2e install lint help

help:
@echo "Crabcode Makefile"
@echo ""
@echo "Commands:"
@echo " make test Run unit tests"
@echo " make test-docker Run tests in Docker"
@echo " make test-e2e Run end-to-end tests in Docker (full promptfoo-cloud simulation)"
@echo " make install Install crabcode to /usr/local/bin"
@echo " make lint Run shellcheck"
@echo " make test Run all tests (unit + integration)"
@echo " make test-unit Run bats unit tests only"
@echo " make test-integration Run integration tests only"
@echo " make test-docker Run integration tests in Docker"
@echo " make test-e2e Run end-to-end tests in Docker (full promptfoo-cloud simulation)"
@echo " make install Install crabcode to /usr/local/bin"
@echo " make lint Run shellcheck"
@echo ""

test:
test: test-unit test-integration

test-unit:
@git submodule update --init --recursive tests/bats tests/test_helper/bats-support tests/test_helper/bats-assert 2>/dev/null || true
@./tests/bats/bin/bats tests/unit/

test-integration:
@chmod +x tests/run.sh
@./tests/run.sh

Expand Down
Loading