Skip to content

Link Browser Use Box runtime demo #183

Link Browser Use Box runtime demo

Link Browser Use Box runtime demo #183

Workflow file for this run

name: test
permissions:
actions: read
contents: write
pull-requests: write # Allow writing comments on PRs
issues: write # Allow writing comments on issues
statuses: write # Allow writing statuses on PRs
discussions: write
on:
push:
branches:
- main
- stable
- 'releases/**'
tags:
- '*'
pull_request:
workflow_dispatch:
jobs:
find_tests:
runs-on: ubuntu-latest
outputs:
TEST_FILENAMES: ${{ steps.lsgrep.outputs.TEST_FILENAMES }}
# ["test_eventbus", ...]
steps:
- uses: actions/checkout@v4
- id: lsgrep
run: |
TEST_FILENAMES="$(ls tests/test_*.py | sed 's|^tests/||' | sed 's|\.py$||' | jq -R -s -c 'split("\n")[:-1]')"
echo "TEST_FILENAMES=${TEST_FILENAMES}" >> "$GITHUB_OUTPUT"
echo "$TEST_FILENAMES"
# https://code.dblock.org/2021/09/03/generating-task-matrix-by-looping-over-repo-files-with-github-actions.html
- name: Check that at least one test file is found
run: |
if [ -z "${{ steps.lsgrep.outputs.TEST_FILENAMES }}" ]; then
echo "Failed to find any test_*.py files in tests/ folder!" > /dev/stderr
exit 1
fi
tests:
needs: find_tests
runs-on: ubuntu-latest
env:
IN_DOCKER: 'True'
strategy:
matrix:
test_filename: ${{ fromJson(needs.find_tests.outputs.TEST_FILENAMES || '["FAILED_TO_DISCOVER_TESTS"]') }}
# autodiscovers all the files in tests/test_*.py
# - test_eventbus
# ... and more
name: ${{ matrix.test_filename }}
steps:
- name: Check that the previous step managed to find some test files for us to run
run: |
if [[ "${{ matrix.test_filename }}" == "FAILED_TO_DISCOVER_TESTS" ]]; then
echo "Failed get list of test files in tests/test_*.py from find_tests job" > /dev/stderr
exit 1
fi
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
with:
enable-cache: true
activate-environment: true
- run: uv sync --dev --all-extras
- run: pytest -x tests/${{ matrix.test_filename }}.py --cov=bubus --cov-report=term
- name: Check coverage files
run: |
echo "Looking for coverage files..."
ls -la .coverage* 2>/dev/null || ls -la | grep coverage || echo "No coverage files found"
if [ -f .coverage ]; then
echo "Found .coverage file, size: $(stat -f%z .coverage 2>/dev/null || stat -c%s .coverage) bytes"
fi
- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.test_filename }}
path: .coverage
retention-days: 7
include-hidden-files: true
if: always()
coverage:
needs: tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
with:
enable-cache: true
activate-environment: true
- run: uv sync --dev --all-extras
- name: Download all coverage data
uses: actions/download-artifact@v4
with:
pattern: coverage-*
path: coverage-data/
- name: Combine coverage data
run: |
# Find all .coverage files and copy them with unique names
counter=1
for coverage_file in $(find coverage-data -name ".coverage" -type f); do
cp "$coverage_file" ".coverage.$counter"
counter=$((counter + 1))
done
- name: Combine coverage & fail if it's <80%
run: |
uv tool install 'coverage[toml]'
coverage combine
coverage html --skip-covered --skip-empty
# Report and write to summary.
coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
# Report again and fail if under 80%.
coverage report --fail-under=80
- name: Upload combined coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: |
htmlcov/
coverage.xml
retention-days: 7
- name: Upload coverage to Codecov (optional)
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
fail_ci_if_error: false
continue-on-error: true