|
1 | 1 | # Visual Regression Test Docker Instructions |
2 | 2 |
|
3 | | -The Visual Regression Tests utilize headless browsers provided by the |
4 | | -[Playwright](https://playwright.dev/) project. Browsers tend to be very platform |
5 | | -specific in terms of exactly how pixels end up being rendered out. The |
6 | | -differences should be small, but they tend to be big enough such that a simple |
7 | | -image comparison algorithm cannot reliably tell what is a real regression and |
8 | | -what is just a platform difference. |
| 3 | +The Visual Regression Tests utilize headless browsers provided by the [Playwright](https://playwright.dev/) project. Browsers are highly platform-specific, and even small pixel differences can cause significant issues for image comparison algorithms. These differences can prevent reliable detection of regressions. |
9 | 4 |
|
10 | | -In order to prevent this issue, the Visual Regression Tests are built to run |
11 | | -inside a Docker container which guarantees a consistent platform environment |
12 | | -for the given headless browser to run in. |
| 5 | +To avoid these issues, Visual Regression Tests run inside a containerized environment. This guarantees a consistent platform for headless browsers, ensuring reproducible results. |
13 | 6 |
|
14 | | -Whenever new commits to a PR are pushed, a GitHub Action runs the Visual |
15 | | -Regression Tests in a Linux-based Docker container to determine if the PR should |
16 | | -be allowed to merge or not. |
| 7 | +For PRs, a GitHub Action runs these tests in a Linux-based container. Locally, you must use `--ci` mode, which launches tests in a container to produce snapshots identical to the GitHub Action environment. |
17 | 8 |
|
18 | | -When you need to capture new snapshots or update existing ones, you must run the |
19 | | -Visual Regression Test Runner locally in `--ci` mode. This launches the tests in |
20 | | -a Docker container giving you exactly the same snapshot results as the tests |
21 | | -that run in the cloud on GitHub Actions. |
| 9 | +This guide covers installing the required tools (`docker`, `colima`, or `podman`) and building the Visual Regression Test image. |
22 | 10 |
|
23 | | -Below are the instructions for both installing Docker and building the Visual |
24 | | -Regression Test Image that is used when you run the tests in `--ci`. |
| 11 | +--- |
25 | 12 |
|
26 | | -## Installing Docker |
| 13 | +## Installing a Container Runtime |
27 | 14 |
|
28 | 15 | ### Mac |
29 | 16 |
|
30 | | -If you have a license for [Docker Desktop](https://www.docker.com/products/docker-desktop/) |
31 | | -you can install that and all should be well. However, if you don't follow the |
32 | | -alternative steps below: |
| 17 | +You can use Docker Desktop if you have a license. If you don’t, use Colima or Podman as alternatives. |
| 18 | + |
| 19 | +#### Option 1: Docker Desktop (Requires License) |
| 20 | + |
| 21 | +1. Download and install [Docker Desktop](https://www.docker.com/products/docker-desktop). |
| 22 | +2. After installation, test Docker: |
| 23 | + ```bash |
| 24 | + docker ps |
| 25 | + ``` |
| 26 | + |
| 27 | +#### Option 2: Colima (Open Source Docker Alternative) |
| 28 | + |
| 29 | +1. Install the Docker CLI using [Homebrew](https://brew.sh/): |
| 30 | + ```bash |
| 31 | + brew install docker |
| 32 | + ``` |
| 33 | +2. Install [Colima](https://colima.dev/): |
| 34 | + ```bash |
| 35 | + brew install colima |
| 36 | + ``` |
| 37 | +3. Start Colima: |
| 38 | + ```bash |
| 39 | + colima start |
| 40 | + ``` |
| 41 | +4. Test Docker with Colima: |
| 42 | + ```bash |
| 43 | + docker ps |
| 44 | + ``` |
| 45 | + It should run without errors. |
| 46 | + |
| 47 | +#### Option 3: Podman (Docker Alternative) |
| 48 | + |
| 49 | +1. Install [Podman](https://podman.io/): |
| 50 | + ```bash |
| 51 | + brew install podman |
| 52 | + ``` |
| 53 | +2. Start Podman: |
| 54 | + ```bash |
| 55 | + podman machine init |
| 56 | + podman machine start |
| 57 | + ``` |
| 58 | +3. Test Podman: |
| 59 | + ```bash |
| 60 | + podman ps |
| 61 | + ``` |
| 62 | + |
| 63 | +### Linux |
| 64 | + |
| 65 | +Docker is natively supported on Linux, but you can also use Podman for a rootless container environment. |
| 66 | + |
| 67 | +#### Option 1: Docker |
| 68 | + |
| 69 | +1. Follow the instructions for your Linux distribution to install Docker: |
| 70 | + - [Ubuntu/Debian](https://docs.docker.com/engine/install/debian/) |
| 71 | + - [Fedora/CentOS](https://docs.docker.com/engine/install/centos/) |
| 72 | +2. After installation, test Docker: |
| 73 | + ```bash |
| 74 | + docker ps |
| 75 | + ``` |
| 76 | + |
| 77 | +#### Option 2: Podman |
| 78 | + |
| 79 | +1. Install [Podman](https://podman.io/) for your Linux distribution: |
| 80 | + - [Podman Installation Guide](https://podman.io/getting-started/installation) |
| 81 | +2. Test Podman: |
| 82 | + ```bash |
| 83 | + podman ps |
| 84 | + ``` |
| 85 | + |
| 86 | +### Windows |
| 87 | + |
| 88 | +Windows users can use Docker Desktop if they have a license or install Podman as an alternative. |
| 89 | + |
| 90 | +#### Option 1: Docker Desktop (Requires License) |
| 91 | + |
| 92 | +1. Download and install [Docker Desktop](https://www.docker.com/products/docker-desktop). |
| 93 | +2. After installation, test Docker: |
| 94 | + ```powershell |
| 95 | + docker ps |
| 96 | + ``` |
| 97 | + |
| 98 | +#### Option 2: Podman (Open Source Alternative) |
| 99 | + |
| 100 | +1. Install [Podman](https://podman.io/) via the Windows installer: |
| 101 | + - [Podman for Windows](https://podman.io/getting-started/installation) |
| 102 | +2. Start the Podman machine: |
| 103 | + ```powershell |
| 104 | + podman machine init |
| 105 | + podman machine start |
| 106 | + ``` |
| 107 | +3. Test Podman: |
| 108 | + ```powershell |
| 109 | + podman ps |
| 110 | + ``` |
| 111 | + |
| 112 | +--- |
33 | 113 |
|
34 | | -1. Using [Homebrew](https://brew.sh/) install the Docker Client: |
35 | | - |
36 | | -``` |
37 | | -brew install docker |
38 | | -``` |
| 114 | +## Building the Test Image |
39 | 115 |
|
40 | | -2. Install [Colima](https://github.com/abiosoft/colima) |
| 116 | +After installing a container runtime, you must build the Visual Regression Test image. |
41 | 117 |
|
42 | | -``` |
43 | | -brew install colima |
44 | | -``` |
| 118 | +1. Run the build script: |
45 | 119 |
|
46 | | -3. Start Colima |
| 120 | + ```bash |
| 121 | + pnpm build:docker |
| 122 | + ``` |
47 | 123 |
|
48 | | -``` |
49 | | -colima start |
50 | | -``` |
| 124 | +2. The script automatically detects your runtime (`docker` or `podman`) and builds the image. After a successful build, you should see the image: |
51 | 125 |
|
52 | | -4. Test Docker |
| 126 | + ```bash |
| 127 | + docker images |
| 128 | + ``` |
53 | 129 |
|
54 | | -``` |
55 | | -docker ps |
56 | | -``` |
| 130 | + Or, if using Podman: |
57 | 131 |
|
58 | | -It should run without errors. |
| 132 | + ```bash |
| 133 | + podman images |
| 134 | + ``` |
59 | 135 |
|
60 | | -## Building the Test Image |
| 136 | + Example output: |
61 | 137 |
|
62 | | -After installing Docker, you must build the Visual Regression Test Image before |
63 | | -running the test runner in `--ci` mode. |
| 138 | + ``` |
| 139 | + REPOSITORY TAG IMAGE ID CREATED SIZE |
| 140 | + visual-regression latest 40476ed4acae 3 minutes ago 2.09GB |
| 141 | + ``` |
64 | 142 |
|
65 | | -``` |
66 | | -pnpm build:docker |
67 | | -``` |
| 143 | +--- |
68 | 144 |
|
69 | | -If all goes well it should create an image called **visual-regression** locally. |
| 145 | +## References |
70 | 146 |
|
71 | | -``` |
72 | | -❯ docker images |
73 | | -REPOSITORY TAG IMAGE ID CREATED SIZE |
74 | | -visual-regression latest 40476ed4acae 3 minutes ago 2.09GB |
75 | | -``` |
| 147 | +- **Docker Desktop**: [docker.com/products/docker-desktop](https://www.docker.com/products/docker-desktop) |
| 148 | +- **Colima**: [colima.dev](https://colima.dev/) |
| 149 | +- **Podman**: [podman.io](https://podman.io/) |
0 commit comments