Skip to content

Commit 31957c1

Browse files
committed
feat(ci): run ui tests in ci
Signed-off-by: phanirithvij <phanirithvij2000@gmail.com>
1 parent 1b4d970 commit 31957c1

4 files changed

Lines changed: 63 additions & 0 deletions

File tree

.github/workflows/netlify-deploy.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
deploy-preview:
1818
name: Push Preview to Netlify
1919
runs-on: ubuntu-latest
20+
outputs:
21+
PREVIEW_URL: ${{ steps.deploy.outputs.PREVIEW_URL }}
2022
permissions:
2123
deployments: write # deployments
2224
statuses: write # commit statuses
@@ -63,6 +65,7 @@ jobs:
6365
run: npm install -g netlify-cli
6466

6567
- name: Deploy to Netlify
68+
id: deploy
6669
if: env.PR_NUMBER != ''
6770
env:
6871
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
@@ -85,6 +88,7 @@ jobs:
8588
echo "DEPLOY_URL=$DEPLOY_URL"
8689
echo "DEPLOY_ID=$DEPLOY_ID"
8790
} >>"$GITHUB_ENV"
91+
echo "PREVIEW_URL=$PREVIEW_URL" >> "$GITHUB_OUTPUT"
8892
8993
- name: Post PR Comment
9094
if: env.PR_NUMBER != ''
@@ -222,3 +226,27 @@ jobs:
222226
-f state="success" \
223227
-f environment_url="${{ env.DEPLOY_URL }}" \
224228
-f description="Preview is ready!"
229+
230+
e2e-staging:
231+
name: UI tests on staging deployment
232+
runs-on: ubuntu-latest
233+
needs: deploy-preview
234+
if: needs.deploy-preview.result == 'success'
235+
steps:
236+
- name: Check out repository
237+
uses: actions/checkout@v6
238+
with:
239+
ref: ${{ github.event.workflow_run.head_sha }}
240+
241+
- name: Install Nix
242+
uses: cachix/install-nix-action@19effe9fe722874e6d46dd7182e4b8b7a43c4a99 # v31.10.0
243+
244+
- uses: cachix/cachix-action@v16
245+
with:
246+
name: ngi-forge
247+
248+
- name: Run Playwright tests
249+
run: |
250+
nix develop -c playwright test -c ui/tests/e2e
251+
env:
252+
BASE_URL: ${{ needs.deploy-preview.outputs.PREVIEW_URL }}

.github/workflows/test.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,25 @@ jobs:
3434
- name: Run checks
3535
run: nix flake check --accept-flake-config
3636

37+
e2e-local:
38+
name: UI tests local
39+
runs-on: ubuntu-latest
40+
needs: test
41+
steps:
42+
- name: Check out repository
43+
uses: actions/checkout@v6
44+
45+
- name: Install Nix
46+
uses: cachix/install-nix-action@19effe9fe722874e6d46dd7182e4b8b7a43c4a99 # v31.10.0
47+
48+
- uses: cachix/cachix-action@v16
49+
with:
50+
name: ngi-forge
51+
52+
- name: Run Playwright tests
53+
run: |
54+
nix develop -c playwright test -c ui/tests/e2e
55+
3756
build-preview-ui:
3857
name: Build UI artifact
3958
runs-on: ubuntu-latest

flake/develop/default.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
self'.packages.elm-watch
2727
self'.packages.elm2nix
2828
playwright-test
29+
playwright-driver.browsers
2930
systemd-manager-tui
3031
watchman
3132
podman-compose
@@ -39,6 +40,20 @@
3940
(devShell.extend (
4041
final: prev: {
4142
packages = prev.packages ++ devPkgs;
43+
env = (prev.env or [ ]) ++ [
44+
{
45+
name = "PLAYWRIGHT_BROWSERS_PATH";
46+
value = "${pkgs.playwright-driver.browsers}";
47+
}
48+
{
49+
name = "PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD";
50+
value = "1";
51+
}
52+
{
53+
name = "PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS";
54+
value = "1";
55+
}
56+
];
4257
}
4358
)).finalPackage;
4459
};

flake/develop/devshell.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ let
6767
"commands"
6868
"packages"
6969
"packagesFrom"
70+
"env"
7071

7172
"devshell"
7273
"bash"

0 commit comments

Comments
 (0)