2323 path : |
2424 ~\AppData\Local\ms-playwright
2525 third_party\ms-playwright
26- key : ${{ runner.os }}-playwright-${{ hashFiles('requirements-base.txt') }}
26+ key : ${{ runner.os }}-${{ runner.arch }}- playwright-${{ hashFiles('requirements-base.txt') }}
2727 restore-keys : |
28- ${{ runner.os }}-playwright-
28+ ${{ runner.os }}-${{ runner.arch }}- playwright-
2929
3030 - name : Cache Playwright browsers (macOS)
3131 if : ${{ inputs.platform == 'macos' }}
@@ -108,6 +108,8 @@ runs:
108108 shell : bash
109109 run : |
110110 echo "=== Installing Playwright browsers ==="
111+ echo "Platform: ${{ inputs.platform }}"
112+ echo "Architecture: ${{ inputs.arch }}"
111113
112114 # Resolve Python executable (prefer virtualenv if available)
113115 PYTHON_EXE="python"
@@ -118,6 +120,35 @@ runs:
118120 echo "VIRTUAL_ENV not set or python not found in venv; falling back to runner python"
119121 fi
120122
123+ # Verify Python architecture matches expected architecture
124+ echo "Verifying Python architecture..."
125+ PYTHON_ARCH=$("$PYTHON_EXE" -c "import platform; print(platform.machine())")
126+ echo "Python architecture: $PYTHON_ARCH"
127+
128+ # Map architecture names
129+ EXPECTED_ARCH="${{ inputs.arch }}"
130+ if [ "$EXPECTED_ARCH" = "amd64" ]; then
131+ EXPECTED_ARCH_ALT="x86_64"
132+ elif [ "$EXPECTED_ARCH" = "aarch64" ]; then
133+ EXPECTED_ARCH_ALT="arm64"
134+ else
135+ EXPECTED_ARCH_ALT="$EXPECTED_ARCH"
136+ fi
137+
138+ if [ "$PYTHON_ARCH" != "$EXPECTED_ARCH" ] && [ "$PYTHON_ARCH" != "$EXPECTED_ARCH_ALT" ]; then
139+ echo "[ERROR] Python architecture ($PYTHON_ARCH) does not match expected (${{ inputs.arch }}/$EXPECTED_ARCH_ALT)"
140+ echo "[ERROR] This should not happen if setup-python-env is configured correctly"
141+ echo "[ERROR] Please check that 'architecture' parameter is passed to setup-python-env"
142+ echo ""
143+ echo "Expected setup-python-env call:"
144+ echo " with:"
145+ echo " architecture: 'x64' or 'arm64' (explicitly set)"
146+ echo ""
147+ exit 1
148+ else
149+ echo "[OK] Python architecture matches expected ($PYTHON_ARCH)"
150+ fi
151+
121152 # Determine cache location
122153 if [ "${{ inputs.platform }}" = "macos" ]; then
123154 playwright_cache="$HOME/Library/Caches/ms-playwright"
@@ -164,8 +195,13 @@ runs:
164195 if [ -n "$browser" ]; then
165196 echo "Installing $browser browser..."
166197 "$PYTHON_EXE" -m playwright install "$browser" $INSTALL_ARGS
198+ if [ $? -ne 0 ]; then
199+ echo "[ERROR] Failed to install $browser browser"
200+ echo "This might be due to architecture mismatch"
201+ exit 1
202+ fi
167203 fi
168204 done
169205
170- echo "Playwright browsers installed successfully"
206+ echo "[OK] Playwright browsers installed successfully"
171207
0 commit comments