diff --git a/.github/workflows/tusk-test-runner-pytest-unit-tests.yml b/.github/workflows/tusk-test-runner-pytest-unit-tests.yml new file mode 100755 index 0000000..150e1e0 --- /dev/null +++ b/.github/workflows/tusk-test-runner-pytest-unit-tests.yml @@ -0,0 +1,109 @@ +name: Tusk Test Runner - pytest unit tests + +# Required for Tusk +on: + workflow_dispatch: + inputs: + runId: + description: "Tusk Run ID" + required: true + tuskUrl: + description: "Tusk server URL" + required: true + commitSha: + description: "Commit SHA to checkout" + required: true + runnerIndexes: + description: "Runner indexes" + required: false + default: "[\"1\"]" + +jobs: + test-action: + name: Tusk Test Runner + runs-on: ubuntu-latest + + # Required for test parallelization where available, do not remove. + strategy: + matrix: + runnerIndex: ${{ fromJson(github.event.inputs.runnerIndexes) }} + + steps: + - name: Checkout + id: checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.commitSha }} # Required for Tusk to access files for the commit being tested + + - name: Install uv + uses: astral-sh/setup-uv@v4 + with: + version: "latest" + + - name: Setup Python + run: uv python install 3.9 + + - name: Cache uv + Python installs + venv + uses: actions/cache@v4 + with: + path: | + ~/.cache/uv + ~/.local/share/uv/python + .venv + key: ${{ runner.os }}-uv-3.9-${{ hashFiles('uv.lock') }} + + - name: Install dependencies + run: uv sync --all-extras + + - name: Start runner + id: test-action + uses: Use-Tusk/test-runner@v1 + # See https://github.com/Use-Tusk/test-runner for full details and examples. + with: + # Required for the test runner, do not remove this input + runId: ${{ github.event.inputs.runId }} + + # Required for the test runner, do not remove this input + tuskUrl: ${{ github.event.inputs.tuskUrl }} + + # Required for the test runner, do not remove this input + commitSha: ${{ github.event.inputs.commitSha }} + + # Your Tusk auth token. It is recommended to add it to your repo's secrets. + # Please adapt the secret name accordingly if you have named it differently. + authToken: ${{ secrets.TUSK_AUTH_TOKEN }} + + # The directory containing your service code. If you have a monorepo containing multiple + # services, create a separate workflow for each service with a different (and non-overlapping) appDir. + # appDir should be relative to the root of the repo. + # Remove this input if this doesn't apply to your repo (i.e., it is a single-service repo). + # appDir: + + # You may specify the test framework if it is a different one + testFramework: "pytest" + + # Test file regex to match all test files in the service + # This is relative to the root of the repo (i.e., the appDir should be included in it, if applicable). + testFileRegex: '^tests/.*test_.*\.py$|^benchmarks/.*test_.*\.py$' + + # The script to run to lint the code (adapt accordingly). + # This should be a command that fixes lint errors, not just checking for them. + # {{file}} placeholder is required and will be replaced by Tusk with the file being linted. + # If you don't have a lint command, you can remove this input. + # Example (Python w/ black): "black {{file}}" + # Example (TypeScript w/ prettier + eslint): "npx prettier --write {{file}} && npx eslint --fix {{file}}" + # If you need to run a compilation check (e.g. tsc), contact support@usetusk.ai to ensure it is set up correctly. + lintScript: "uv run ruff format {{file}} && uv run ruff check --fix {{file}}" + + # The script to run to test the code (adapt accordingly). Required for the test runner. + # {{file}} placeholder is required and will be replaced by Tusk with the file being tested. + # Example (pytest): "pytest {{file}}" + # If your test output is known to contain a lot of console logs, we recommend suppressing these logs (e.g., use --silent / --quiet flags or equivalent). + testScript: "uv run pytest {{file}} -q" + + # The runner may run tests in parallel. + # Set this value to 1 if you know that your tests should not be run concurrently in each environment. + # maxConcurrency: 1 + + # Required for test parallelization where available, do not remove. + runnerIndex: ${{ matrix.runnerIndex }}