Skip to content

Commit e60dc0d

Browse files
committed
Use shared CI setup action and add actionlint
1 parent 8077d5b commit e60dc0d

12 files changed

+110
-98
lines changed

.github/actions/setup/action.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: 'Setup Environment'
2+
description: 'Install uv, Python, and project dependencies'
3+
4+
inputs:
5+
python-version:
6+
description: 'Python version to install'
7+
required: false
8+
default: '3.11'
9+
install-playwright:
10+
description: 'Install Playwright browsers'
11+
required: false
12+
default: 'false'
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- name: Install uv
18+
uses: astral-sh/setup-uv@v7
19+
with:
20+
enable-cache: true
21+
22+
- name: Set up Python
23+
run: uv python install ${{ inputs.python-version }}
24+
shell: bash
25+
26+
- name: Install dependencies
27+
run: uv sync --all-extras
28+
shell: bash
29+
30+
- name: Install Playwright browsers
31+
if: inputs.install-playwright == 'true'
32+
run: uv run playwright install chromium --with-deps
33+
shell: bash

.github/workflows/copilot-setup-steps.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,7 @@ jobs:
1111
- name: Checkout code
1212
uses: actions/checkout@v4
1313

14-
- name: Install uv
15-
uses: astral-sh/setup-uv@v7
14+
- name: Setup environment
15+
uses: ./.github/actions/setup
1616
with:
17-
enable-cache: true
18-
19-
- name: Set up Python
20-
run: uv python install 3.11
21-
22-
- name: Install all dependencies
23-
run: uv sync --all-extras
24-
25-
- name: Install Playwright browsers
26-
run: uv run playwright install chromium --with-deps
17+
install-playwright: 'true'

.github/workflows/test-docker-gitlab.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,10 @@ jobs:
1414
- name: Checkout code
1515
uses: actions/checkout@v4
1616

17-
- name: Install uv
18-
uses: astral-sh/setup-uv@v7
17+
- name: Setup environment
18+
uses: ./.github/actions/setup
1919
with:
20-
enable-cache: true
21-
22-
- name: Set up Python
23-
run: uv python install 3.11
24-
25-
- name: Install dependencies
26-
run: uv sync --all-extras
27-
28-
- name: Install Playwright browsers
29-
run: uv run playwright install chromium --with-deps
20+
install-playwright: 'true'
3021

3122
- name: Build Docker image
3223
run: uv run invoke envs.docker.build --site=gitlab --tag=test

.github/workflows/test-docker-map.yml.disabled

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,10 @@ jobs:
2222
- name: Checkout code
2323
uses: actions/checkout@v4
2424

25-
- name: Install uv
26-
uses: astral-sh/setup-uv@v7
25+
- name: Setup environment
26+
uses: ./.github/actions/setup
2727
with:
28-
enable-cache: true
29-
30-
- name: Set up Python
31-
run: uv python install 3.11
32-
33-
- name: Install dependencies
34-
run: uv sync --all-extras
35-
36-
- name: Install Playwright browsers
37-
run: uv run playwright install chromium --with-deps
28+
install-playwright: 'true'
3829

3930
- name: Restore map test data cache
4031
id: map-data-cache

.github/workflows/test-docker-reddit.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,10 @@ jobs:
1414
- name: Checkout code
1515
uses: actions/checkout@v4
1616

17-
- name: Install uv
18-
uses: astral-sh/setup-uv@v7
17+
- name: Setup environment
18+
uses: ./.github/actions/setup
1919
with:
20-
enable-cache: true
21-
22-
- name: Set up Python
23-
run: uv python install 3.11
24-
25-
- name: Install dependencies
26-
run: uv sync --all-extras
27-
28-
- name: Install Playwright browsers
29-
run: uv run playwright install chromium --with-deps
20+
install-playwright: 'true'
3021

3122
- name: Build Docker image
3223
run: uv run invoke envs.docker.build --site=reddit --tag=test

.github/workflows/test-docker-shopping-admin.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,10 @@ jobs:
1414
- name: Checkout code
1515
uses: actions/checkout@v4
1616

17-
- name: Install uv
18-
uses: astral-sh/setup-uv@v7
17+
- name: Setup environment
18+
uses: ./.github/actions/setup
1919
with:
20-
enable-cache: true
21-
22-
- name: Set up Python
23-
run: uv python install 3.11
24-
25-
- name: Install dependencies
26-
run: uv sync --all-extras
27-
28-
- name: Install Playwright browsers
29-
run: uv run playwright install chromium --with-deps
20+
install-playwright: 'true'
3021

3122
- name: Build Docker image
3223
run: uv run invoke envs.docker.build --site=shopping_admin --tag=test

.github/workflows/test-docker-shopping.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,10 @@ jobs:
1414
- name: Checkout code
1515
uses: actions/checkout@v4
1616

17-
- name: Install uv
18-
uses: astral-sh/setup-uv@v7
17+
- name: Setup environment
18+
uses: ./.github/actions/setup
1919
with:
20-
enable-cache: true
21-
22-
- name: Set up Python
23-
run: uv python install 3.11
24-
25-
- name: Install dependencies
26-
run: uv sync --all-extras
27-
28-
- name: Install Playwright browsers
29-
run: uv run playwright install chromium --with-deps
20+
install-playwright: 'true'
3021

3122
- name: Build Docker image
3223
run: uv run invoke envs.docker.build --site=shopping --tag=test

.github/workflows/test-docker-wikipedia.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,10 @@ jobs:
1414
- name: Checkout code
1515
uses: actions/checkout@v4
1616

17-
- name: Install uv
18-
uses: astral-sh/setup-uv@v7
17+
- name: Setup environment
18+
uses: ./.github/actions/setup
1919
with:
20-
enable-cache: true
21-
22-
- name: Set up Python
23-
run: uv python install 3.11
24-
25-
- name: Install dependencies
26-
run: uv sync --all-extras
27-
28-
- name: Install Playwright browsers
29-
run: uv run playwright install chromium --with-deps
20+
install-playwright: 'true'
3021

3122
- name: Download CI ZIM
3223
run: uv run invoke dev.ci.setup-wikipedia

.github/workflows/test-env-ctrl.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,10 @@ jobs:
1919
- name: Checkout code
2020
uses: actions/checkout@v4
2121

22-
- name: Install uv
23-
uses: astral-sh/setup-uv@v7
22+
- name: Setup environment
23+
uses: ./.github/actions/setup
2424
with:
25-
enable-cache: true
26-
27-
- name: Set up Python
28-
run: uv python install 3.11
29-
30-
- name: Install dependencies
31-
run: uv sync --all-extras
32-
33-
- name: Install Playwright browsers
34-
run: uv run playwright install chromium --with-deps
25+
install-playwright: 'true'
3526

3627
- name: Build Docker image
3728
run: docker build -t webarena-verified:test .

dev/code_tasks.py

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Code quality tasks (linting, formatting, type checking)."""
1+
"""Code quality tasks (linting, formatting, type checking, testing)."""
22

33
from __future__ import annotations
44

@@ -9,12 +9,54 @@
99
if TYPE_CHECKING:
1010
from invoke.context import Context
1111

12+
from dev.utils import logging_utils
13+
14+
15+
@task(name="lint")
16+
@logging_utils.with_banner()
17+
def lint(ctx: Context) -> None:
18+
"""Run linting and type checking (no fixes) - for CI."""
19+
logging_utils.print_info("Running ruff check...")
20+
ctx.run("uv run ruff check")
21+
22+
logging_utils.print_info("Running ruff format check...")
23+
ctx.run("uv run ruff format --check")
24+
25+
logging_utils.print_info("Running ty check...")
26+
ctx.run("uv run ty check src dev tests")
27+
28+
logging_utils.print_info("Running actionlint...")
29+
ctx.run("uv run actionlint")
30+
31+
logging_utils.print_success("All checks passed")
32+
1233

1334
@task(name="format")
1435
def format_and_check(c: Context) -> None:
15-
"""Format code using ruff and run type checking."""
36+
"""Format code using ruff and run type checking - for local dev."""
1637
c.run("uv run ruff check src dev --fix --unsafe-fixes")
1738
c.run("uv run ruff format src dev")
1839
c.run("uv run ty check src dev")
1940
# Verify environment_control package is Python 3.9 compatible
2041
c.run("uv run vermin -t=3.9 --eval-annotations --no-tips packages/environment_control/environment_control/")
42+
43+
44+
@task(name="test")
45+
@logging_utils.with_banner()
46+
def run_tests(ctx: Context, docker_img: str = "webarena-verified:test") -> None:
47+
"""Run tests.
48+
49+
Args:
50+
docker_img: Docker image to use for tests.
51+
"""
52+
logging_utils.print_info("Building Docker image...")
53+
ctx.run(f"docker build -t {docker_img} .")
54+
55+
logging_utils.print_info("Running tests...")
56+
ctx.run(
57+
f"uv run pytest --webarena-verified-docker-img {docker_img} "
58+
"--ignore=tests/integration/environment_control/ "
59+
"--ignore=tests/integration/environments/"
60+
)
61+
62+
logging_utils.print_success("All tests passed")

0 commit comments

Comments
 (0)