Skip to content

Commit edb8166

Browse files
committed
basic acceptance of tags in jobs
1 parent edb20d5 commit edb8166

File tree

5 files changed

+112
-16
lines changed

5 files changed

+112
-16
lines changed

.github/actions/e2e/action.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ inputs:
1515
description: "password for staging test user"
1616
staging_test_user_mfa_key:
1717
description: "mfa key for staging test user"
18+
playwright_tags:
19+
description: "pipe separated list of tags denoting groups of tests to run"
1820
total_shards:
1921
description: "total number of test shards in parent run"
2022
default: "1"
@@ -77,7 +79,8 @@ runs:
7779
npm install @playwright/test
7880
npx playwright install --with-deps
7981
80-
- name: Run e2e tests (Shard ${{ inputs.shard }}/${{ inputs.total_shards }})
82+
- name: Run all e2e tests (Shard ${{ inputs.shard }}/${{ inputs.total_shards }})
83+
if: ${{ inputs.playwright_tags == '' }}
8184
working-directory: ./frontend
8285
env:
8386
CI: true
@@ -88,10 +91,25 @@ runs:
8891
STAGING_TEST_USER_PASSWORD: ${{ inputs.staging_test_user_password }}
8992
STAGING_TEST_USER_MFA_KEY: ${{ inputs.staging_test_user_mfa_key }}
9093
run: |
91-
echo $STAGING_TEST_USER_EMAIL
9294
npm run test:e2e
9395
shell: bash
9496

97+
98+
- name: Run e2e tests for ${{ inputs.playwright_tags }} (Shard ${{ inputs.shard }}/${{ inputs.total_shards }})
99+
if: ${{ inputs.playwright_tags != '' }}
100+
working-directory: ./frontend
101+
env:
102+
CI: true
103+
TOTAL_SHARDS: ${{ inputs.total_shards }}
104+
CURRENT_SHARD: ${{ inputs.current_shard }}
105+
PLAYWRIGHT_TARGET_ENV: ${{ inputs.target }}
106+
STAGING_TEST_USER_EMAIL: ${{ inputs.staging_test_user_email }}
107+
STAGING_TEST_USER_PASSWORD: ${{ inputs.staging_test_user_password }}
108+
STAGING_TEST_USER_MFA_KEY: ${{ inputs.staging_test_user_mfa_key }}
109+
run: |
110+
npm run test:e2e -- --grep "${{ inputs.playwright_tags }}"
111+
shell: bash
112+
95113
- name: Debug logging on failure
96114
if: ${{ failure() && inputs.api_logs == 'true' }}
97115
working-directory: ./frontend

.github/workflows/ci-frontend-e2e.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ on:
1414
inputs:
1515
api_logs:
1616
description: "print api logs on failure?"
17+
required: true
18+
default: "false"
19+
type: choice
20+
options:
21+
- "true"
22+
- "false"
23+
playwright_tags:
24+
description: "pipe separated list of @tags denoting groups of tests to run"
25+
required: false
1726
type: string
1827
workflow_call:
1928
pull_request:
@@ -100,6 +109,7 @@ jobs:
100109
total_shards: ${{ matrix.total_shards }}
101110
current_shard: ${{ matrix.shard }}
102111
api_logs: ${{ inputs.api_logs }}
112+
playwright_tags: ${{ inputs.playwright_tags }}
103113
staging_test_user_email: ${{ secrets.STAGING_TEST_USER_EMAIL }}
104114
staging_test_user_password: ${{ secrets.STAGING_TEST_USER_PASSWORD }}
105115
staging_test_user_mfa_key: ${{ secrets.STAGING_TEST_USER_MFA_KEY }}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: E2E Tests (Experimental)
2+
on:
3+
push:
4+
branches:
5+
- "dschrashun/8184-test-job-tag-groups"
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: "git reference to deploy (e.g., a branch, tag, or commit SHA)"
10+
required: true
11+
type: string
12+
target:
13+
description: "application environment to run tests against (dev / prod TK)"
14+
required: true
15+
default: "staging"
16+
type: choice
17+
options:
18+
- staging
19+
playwright_tags:
20+
description: "pipe separated list of @tags denoting groups of tests to run"
21+
required: false
22+
type: string
23+
24+
concurrency:
25+
group: ${{ github.workflow }}-${{ github.ref }}
26+
cancel-in-progress: true
27+
28+
jobs:
29+
e2e-tests-deployed:
30+
runs-on: ubuntu-22.04
31+
strategy:
32+
fail-fast: true
33+
matrix:
34+
shard: [1, 2, 3, 4]
35+
total_shards: [4]
36+
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v6
40+
41+
- name: Set target
42+
run: if [[ -z "${{ inputs.target }}" ]]; then echo "defaulted_target=staging" >> "$GITHUB_ENV"; else echo 'defaulted_target="${{ inputs.target }}"' >> "$GITHUB_ENV"; fi
43+
44+
- uses: ./.github/actions/e2e
45+
with:
46+
version: ${{ inputs.version || github.ref }}
47+
target: ${{ env.defaulted_target }}
48+
total_shards: ${{ matrix.total_shards }}
49+
current_shard: ${{ matrix.shard }}
50+
playwright_tags: "@smoke"
51+
staging_test_user_email: ${{ secrets.STAGING_TEST_USER_EMAIL }}
52+
staging_test_user_password: ${{ secrets.STAGING_TEST_USER_PASSWORD }}
53+
staging_test_user_mfa_key: ${{ secrets.STAGING_TEST_USER_MFA_KEY }}
54+
55+
create-report:
56+
name: Create Merged Test Report
57+
if: ${{ !cancelled() }}
58+
needs: e2e-tests-deployed
59+
uses: ./.github/workflows/e2e-create-report.yml
60+
secrets: inherit
61+
with:
62+
run_id: ${{ github.run_id }}

.github/workflows/e2e-staging.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ on:
1616
type: choice
1717
options:
1818
- staging
19+
playwright_tags:
20+
description: "pipe separated list of @tags denoting groups of tests to run"
21+
required: false
22+
type: string
1923

2024
concurrency:
2125
group: ${{ github.workflow }}-${{ github.ref }}
@@ -43,6 +47,7 @@ jobs:
4347
target: ${{ env.defaulted_target }}
4448
total_shards: ${{ matrix.total_shards }}
4549
current_shard: ${{ matrix.shard }}
50+
playwright_tags: ${{ inputs.playwright_tags }}
4651
staging_test_user_email: ${{ secrets.STAGING_TEST_USER_EMAIL }}
4752
staging_test_user_password: ${{ secrets.STAGING_TEST_USER_PASSWORD }}
4853
staging_test_user_mfa_key: ${{ secrets.STAGING_TEST_USER_MFA_KEY }}

frontend/tests/e2e/index.spec.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,24 @@ test.beforeEach(async ({ page }) => {
1010
await page.goto("/", { waitUntil: "domcontentloaded", timeout });
1111
});
1212

13-
test("has title", async ({ page }) => {
13+
test("has title", { tag: "@smoke" }, async ({ page }) => {
1414
await expect(page).toHaveTitle(/Simpler.Grants.gov/);
1515
});
1616

17-
test("clicking 'follow on GitHub' link opens a new tab pointed at Github repository", async ({
18-
page,
19-
context,
20-
}) => {
21-
const pagePromise = context.waitForEvent("page");
22-
// Click the Follow on GitHub link
23-
await page.getByRole("link", { name: "Follow on GitHub" }).click();
24-
const newPage = await pagePromise;
25-
await newPage.waitForLoadState();
26-
await expect(newPage).toHaveURL(
27-
/https:\/\/github.com\/HHS\/simpler-grants-gov/,
28-
);
29-
});
17+
test(
18+
"clicking 'follow on GitHub' link opens a new tab pointed at Github repository",
19+
{ tag: "@full-regression" },
20+
async ({ page, context }) => {
21+
const pagePromise = context.waitForEvent("page");
22+
// Click the Follow on GitHub link
23+
await page.getByRole("link", { name: "Follow on GitHub" }).click();
24+
const newPage = await pagePromise;
25+
await newPage.waitForLoadState();
26+
await expect(newPage).toHaveURL(
27+
/https:\/\/github.com\/HHS\/simpler-grants-gov/,
28+
);
29+
},
30+
);
3031

3132
test("skips to main content when navigating via keyboard", async ({
3233
page,

0 commit comments

Comments
 (0)