Skip to content

Commit

Permalink
Merge pull request #30 from 21CSM/playwright-ci
Browse files Browse the repository at this point in the history
build(flake): add check for Playwright browsers
  • Loading branch information
21CSM authored Sep 21, 2024
2 parents 0ed9f11 + ac6fd35 commit 6895a6c
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,23 @@
pnpm
playwright-test
];
commonEnv = {
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "1";
PLAYWRIGHT_BROWSERS_PATH = "${pkgs.playwright-driver.browsers}";
};
in
{
devShells.default = pkgs.mkShell {
inherit buildInputs;
shellHook = ''
export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
export PLAYWRIGHT_BROWSERS_PATH="${pkgs.playwright-driver.browsers}"
export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=${commonEnv.PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD}
export PLAYWRIGHT_BROWSERS_PATH=${commonEnv.PLAYWRIGHT_BROWSERS_PATH}
'';
};

checks.default = pkgs.runCommand "check-env" {
inherit buildInputs;
inherit (commonEnv) PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD PLAYWRIGHT_BROWSERS_PATH;
} ''
echo "Checking Node.js version..."
if ! node --version | grep -q "v22"; then
Expand All @@ -43,7 +48,27 @@
echo "Checking pnpm availability..."
pnpm --version || (echo "pnpm not found" && exit 1)
echo "Checking PLAYWRIGHT_BROWSERS_PATH..."
if [ -z "$PLAYWRIGHT_BROWSERS_PATH" ]; then
echo "PLAYWRIGHT_BROWSERS_PATH is not set"
exit 1
fi
echo "Checking if PLAYWRIGHT_BROWSERS_PATH exists..."
if [ ! -d "$PLAYWRIGHT_BROWSERS_PATH" ]; then
echo "PLAYWRIGHT_BROWSERS_PATH directory does not exist"
exit 1
fi
echo "Checking for specific browsers..."
for browser in chromium firefox webkit; do
if [ ! -d "$PLAYWRIGHT_BROWSERS_PATH/$browser"* ]; then
echo "$browser not found in PLAYWRIGHT_BROWSERS_PATH"
exit 1
fi
done
touch $out
'';
}
Expand Down

0 comments on commit 6895a6c

Please sign in to comment.