diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index d87733e..3a99e75 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -33,7 +33,7 @@ jobs: run: npm install -g @devcontainers/cli - name: "Generating Debian tests for '${{ matrix.features }}'" - run: devcontainer features test -f ${{ matrix.features }} -i debian --preserve-test-containers + run: devcontainer features test -f ${{ matrix.features }} -i debian:bookworm --preserve-test-containers test-ubuntu: needs: validate name: "Test on Ubuntu Linux" @@ -43,6 +43,7 @@ jobs: features: - rye - cypress + - playwright steps: - uses: actions/checkout@v4 diff --git a/.gitignore b/.gitignore index 9b1ee42..1298790 100644 --- a/.gitignore +++ b/.gitignore @@ -173,3 +173,4 @@ dist # Finder (MacOS) folder config .DS_Store +.direnv diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..b27632e --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1755186698, + "narHash": "sha256-wNO3+Ks2jZJ4nTHMuks+cxAiVBGNuEBXsT29Bz6HASo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fbcf476f790d8a217c3eab4e12033dc4a0f6d23c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..457eeec --- /dev/null +++ b/flake.nix @@ -0,0 +1,34 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + outputs = + { self, nixpkgs }: + + let + pkgs = nixpkgs.legacyPackages.x86_64-linux; + in + { + + nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ( + { config, pkgs, ... }: + { + virtualisation.docker.enable = true; + users.users.schlich.extraGroups = [ "docker" ]; + } + ) + ]; + }; + devShells.x86_64-linux.default = pkgs.mkShell { + buildInputs = with pkgs; [ + nodejs + deno + devcontainer + docker + ]; + }; + }; +} diff --git a/src/playwright/devcontainer-feature.json b/src/playwright/devcontainer-feature.json index a199a5d..1b04281 100644 --- a/src/playwright/devcontainer-feature.json +++ b/src/playwright/devcontainer-feature.json @@ -1,9 +1,17 @@ { - "id": "playwright", - "version": "0.1.0", - "name": "Playwright", - "description": "Playwright enables reliable end-to-end testing for modern web apps.", - "dependsOn": { - "ghcr.io/devcontainers/features/node:1": {} + "id": "playwright", + "version": "0.1.1", + "name": "Playwright", + "description": "Playwright enables reliable end-to-end testing for modern web apps.", + "dependsOn": { + "ghcr.io/devcontainers/features/common-utils:2": {}, + "ghcr.io/devcontainers/features/node:1": {} + }, + "options": { + "browsers": { + "type": "string", + "description": "A SPACE-separated list of browsers to install", + "default": "" } -} + } +} \ No newline at end of file diff --git a/src/playwright/install.sh b/src/playwright/install.sh index d4c2fdc..61696d8 100644 --- a/src/playwright/install.sh +++ b/src/playwright/install.sh @@ -1,3 +1,3 @@ #!/bin/bash -npx playwright install --with-deps \ No newline at end of file +npx playwright install --with-deps ${BROWSERS} diff --git a/test/playwright/scenarios.json b/test/playwright/scenarios.json new file mode 100644 index 0000000..c66658a --- /dev/null +++ b/test/playwright/scenarios.json @@ -0,0 +1,18 @@ +{ + "select_single_browser": { + "image": "ubuntu:focal", + "features": { + "playwright": { + "browsers": "firefox" + } + } + }, + "select_multiple_browsers": { + "image": "ubuntu:focal", + "features": { + "playwright": { + "browsers": "firefox chromium" + } + } + } +} \ No newline at end of file diff --git a/test/playwright/select_multiple_browsers.sh b/test/playwright/select_multiple_browsers.sh new file mode 100644 index 0000000..f45aa55 --- /dev/null +++ b/test/playwright/select_multiple_browsers.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +source dev-container-features-test-lib + +echo "$(npx playwright install --list)" + +check "Multiple browsers" bash -c '[[ $(npx playwright install --list) == *firefox* ]]' +check "Multiple browsers" bash -c '[[ $(npx playwright install --list) == *chromium* ]]' + +reportResults diff --git a/test/playwright/select_single_browser.sh b/test/playwright/select_single_browser.sh new file mode 100644 index 0000000..8cf6c73 --- /dev/null +++ b/test/playwright/select_single_browser.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +source dev-container-features-test-lib + +check "Chromium missing" bash -c '[[ $(npx playwright install --list) != *chromium* ]]' + +reportResults diff --git a/test/playwright/test.sh b/test/playwright/test.sh index f4bbcfd..65dec67 100644 --- a/test/playwright/test.sh +++ b/test/playwright/test.sh @@ -6,4 +6,4 @@ source dev-container-features-test-lib check "get version" npx playwright --version -reportResults \ No newline at end of file +reportResults