ci: cancel superseded runs and cache Playwright browsers (#86) #636
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: test | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| # Cancel superseded runs on the same ref (e.g. a new push to a PR) so they stop | |
| # competing for the shared runner pool instead of piling up. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| lsp-tests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout the repository and submodules | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install uv | |
| run: | | |
| curl -LsSf https://astral.sh/uv/install.sh | sh | |
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
| - name: Install rsm-lang | |
| run: uv sync | |
| - name: Build tree-sitter-rsm | |
| working-directory: tree-sitter-rsm | |
| run: | | |
| npm install | |
| npm run prebuildify | |
| - name: Install LSP dependencies | |
| working-directory: packages/rsm-lsp | |
| run: npm ci | |
| - name: Build LSP server | |
| working-directory: packages/rsm-lsp | |
| run: npm run build | |
| - name: Run all LSP tests | |
| working-directory: packages/rsm-lsp | |
| run: npm test -- --run | |
| pytest: | |
| runs-on: ${{ matrix.os }}-latest | |
| env: | |
| PYTEST_ADDOPTS: "--color=yes" | |
| strategy: | |
| matrix: | |
| os: [ubuntu, macos] | |
| python-version: ['3.11', '3.12', '3.13', '3.14'] | |
| steps: | |
| - name: Checkout the repository and submodules | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install uv | |
| run: | | |
| curl -LsSf https://astral.sh/uv/install.sh | sh | |
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
| - name: Install rsm-lang | |
| run: | | |
| uv sync | |
| uv pip list | |
| - name: Run unit tests | |
| run: | | |
| uv run pytest -vv -m "not visual and not accessibility and not interactive and not pandoc" | |
| - name: Run doctests in source files | |
| run: | | |
| uv run pytest -vv --doctest-modules rsm | |
| - name: Run doctests in doc files | |
| run: | | |
| cd docs && uv run make doctest | |
| pandoc-tests: | |
| runs-on: ${{ matrix.os }}-latest | |
| strategy: | |
| matrix: | |
| os: [ubuntu, macos] | |
| env: | |
| PYTEST_ADDOPTS: "--color=yes" | |
| steps: | |
| - name: Checkout the repository and submodules | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install uv | |
| run: | | |
| curl -LsSf https://astral.sh/uv/install.sh | sh | |
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
| - name: Install rsm-lang | |
| run: uv sync | |
| - name: Install pandoc (Ubuntu) | |
| if: matrix.os == 'ubuntu' | |
| run: sudo apt-get install -y pandoc | |
| - name: Install pandoc (macOS) | |
| if: matrix.os == 'macos' | |
| run: brew install pandoc | |
| - name: Run pandoc tests | |
| run: uv run pytest -vv tests/test_pandoc.py | |
| visual-tests: | |
| runs-on: macos-latest | |
| timeout-minutes: 30 | |
| env: | |
| PYTEST_ADDOPTS: "--color=yes" | |
| steps: | |
| - name: Checkout the repository and submodules | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install uv | |
| run: | | |
| curl -LsSf https://astral.sh/uv/install.sh | sh | |
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
| - name: Install rsm-lang | |
| run: | | |
| uv sync | |
| uv pip list | |
| - name: Install Playwright browsers | |
| run: | | |
| uv run playwright install --with-deps chromium | |
| - name: Run visual tests | |
| run: | | |
| uv run pytest -vv -m visual -n 2 --timeout=60 --max-worker-restart=2 | |
| - name: Upload visual test diffs | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: visual-test-diffs | |
| path: tests/visual/snapshot_tests_failures/ | |
| retention-days: 7 | |
| interactive-tests: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| env: | |
| PYTEST_ADDOPTS: "--color=yes" | |
| PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/.pw-browsers | |
| steps: | |
| - name: Checkout the repository and submodules | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install uv | |
| run: | | |
| curl -LsSf https://astral.sh/uv/install.sh | sh | |
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
| - name: Install rsm-lang | |
| run: uv sync | |
| - name: Cache Playwright browsers | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ github.workspace }}/.pw-browsers | |
| key: playwright-${{ runner.os }}-${{ hashFiles('uv.lock') }} | |
| - name: Install Playwright browsers | |
| run: uv run playwright install --with-deps chromium | |
| - name: Run interactive tests | |
| run: uv run pytest tests/interactive/ -vv --browser chromium --timeout=60 | |
| docs-build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout the repository and submodules | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install uv | |
| run: | | |
| curl -LsSf https://astral.sh/uv/install.sh | sh | |
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
| - name: Install rsm-lang | |
| run: uv sync | |
| - name: Build docs (warnings as errors) | |
| run: uv run python -m sphinx -b html -W docs/source docs/build/html | |
| accessibility-tests: | |
| runs-on: macos-latest | |
| timeout-minutes: 15 | |
| env: | |
| PYTEST_ADDOPTS: "--color=yes" | |
| PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/.pw-browsers | |
| steps: | |
| - name: Checkout the repository and submodules | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install uv | |
| run: | | |
| curl -LsSf https://astral.sh/uv/install.sh | sh | |
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
| - name: Install rsm-lang | |
| run: | | |
| uv sync | |
| uv pip list | |
| - name: Cache Playwright browsers | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ github.workspace }}/.pw-browsers | |
| key: playwright-${{ runner.os }}-${{ hashFiles('uv.lock') }} | |
| - name: Install Playwright browsers | |
| run: | | |
| uv run playwright install --with-deps chromium | |
| - name: Run accessibility tests | |
| run: | | |
| uv run pytest -vv -m accessibility -n 2 --timeout=180 |