e2e: ui: fix playwright tag once and for all (#26840)

I don't ever want to see this error again:

```
Error: browserType.launch: Executable doesn't exist at /ms-playwright/chromium_headless_shell-1193/chrome-linux/headless_shell
╔══════════════════════════════════════════════════════════════════════╗
║ Looks like Playwright Test or Playwright was just updated to 1.55.1. ║
║ Please update docker image as well.                                  ║
║ -  current: mcr.microsoft.com/playwright:v1.55.0-jammy               ║
║ - required: mcr.microsoft.com/playwright:v1.55.1-jammy               ║
║                                                                      ║
║ <3 Playwright Team                                                   ║
╚══════════════════════════════════════════════════════════════════════╝

   at global-setup.js:20

  18 |   }
  19 |
> 20 |   const browser = await chromium.launch();
     |                                  ^
  21 |   const context = await browser.newContext({ ignoreHTTPSErrors: true });
  22 |   const page = await context.newPage();
  23 |   await page.goto(NOMAD_ADDR+'/ui/settings/tokens');
    at module.exports (/src/global-setup.js:20:34)
```

I'm sure this will be the end of it!
This commit is contained in:
Daniel Bennett
2025-09-25 13:02:49 -04:00
committed by GitHub
parent 9bc2190508
commit bdf08e1461

View File

@@ -33,9 +33,22 @@ EOF
}
IMAGE="mcr.microsoft.com/playwright:v1.55.0-jammy"
pushd $(dirname "${BASH_SOURCE[0]}") > /dev/null
IMAGE="mcr.microsoft.com/playwright"
# since playwright looks for latest browser(s),
# it will throw an error in non-latest containers.
# so, instead of constantly changing the image
# tag manually, pull it from the registry API.
get_image_tag() {
1>&2 echo 'detecting playwright image tag'
local os='noble'
curl -sS 'https://mcr.microsoft.com/api/v1/catalog/playwright/tags?reg=mar' \
| jq -r '[ .[].name | select(match("^v.*-jammy$")) ] | last '
# '[ ..query.. ] | last' gets the bottom one in the api response
# that matches the regex. the api returns them sorted oldest to newest.
}
run_tests() {
run bash script.sh $@
}
@@ -47,6 +60,12 @@ run_shell() {
run() {
local tty_args=''
[ -t 1 ] && tty_args='-it'
local tag="$(get_image_tag)"
if [ -z "$tag" ]; then
echo 'failed to detect docker image tag'
return 1
fi
echo "got playwright tag '$tag'"
docker run $tty_args --rm \
-v $(pwd):/src \
-w /src \
@@ -54,8 +73,8 @@ run() {
-e NOMAD_TOKEN=$NOMAD_TOKEN \
--ipc=host \
--net=host \
"$IMAGE" \
$@
"$IMAGE:$tag" \
"$@"
}
run_proxy() {