Repository navigation
72 lines (61 loc) · 2.85 KB
/
Copy pathtest_python_templates.yaml
File metadata and controls
72 lines (61 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Test Python templates
on:
workflow_call:
jobs:
test-python-templates:
name: Test Python templates
strategy:
matrix:
os: [ubuntu-24.04, windows-latest]
python-version: ['3.11', '3.12', '3.13', '3.14']
# Duration-balanced template slice, see TEST_SHARD in test/templates.test.js.
shard: ['1/2', '2/2']
fail-fast: false
runs-on: ${{ matrix.os }}
timeout-minutes: 30
steps:
# The harness installs templates under os.tmpdir(); on Windows that is the
# network-backed C: disk, ~5x slower at small files than D: (RUNNER_TEMP). #907
- name: Install templates on the runner's fast disk
shell: bash
run: |
echo "TMP=$RUNNER_TEMP" >> "$GITHUB_ENV"
echo "TEMP=$RUNNER_TEMP" >> "$GITHUB_ENV"
- name: Checkout repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: .nvmrc
- name: Install pnpm and dependencies
uses: apify/actions/pnpm-install@v1.5.0
# --with-deps on Linux installs the apt libraries Chromium needs. On Windows it
# installs the Media Foundation feature instead, which cost 3m16s of this step's
# 3m30s — the browser downloads themselves take 15s. Media Foundation provides
# video codecs; these templates only crawl pages, so skip it there.
- name: Install playwright browsers
run: pnpm exec playwright install chromium ${{ runner.os == 'Linux' && '--with-deps' || '' }}
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: templates/**/requirements.txt
# For uv-based templates (e.g. python-uv); uv provides its own Python from .python-version.
- name: Setup uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
- name: Install Chrome and Chromedriver
# Use pnpm dlx instead of npx — npx is the npm CLI and trips
# devEngines.packageManager=pnpm at the repo root.
run: |
pnpm dlx @puppeteer/browsers install chrome
pnpm dlx @puppeteer/browsers install chromedriver
- name: Test Python templates
run: pnpm run test-python-templates
env:
TEST_SHARD: ${{ matrix.shard }}
# The camoufox browser fetch hits the GitHub releases API —
# unauthenticated it flakes on runner-IP rate limits.
GITHUB_TOKEN: ${{ github.token }}
APIFY_TOKEN: ${{ secrets.APIFY_TEST_USER_API_TOKEN }}
OPENAI_API_KEY: ${{ secrets.APIFY_SERVICE_ACCOUNT_OPENAI_API_KEY }}