Skip to content

Commit 137c9c5

Browse files
authored
Migrate AB Testing scripts to node (#14837)
1 parent 10fa906 commit 137c9c5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2571
-1733
lines changed

.github/workflows/ab-testing-checks.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,26 @@ jobs:
3030
steps:
3131
- uses: actions/checkout@v5
3232

33-
# https://github.com/denoland/setup-deno#latest-stable-for-a-major
34-
- uses: denoland/setup-deno@v1
35-
with:
36-
deno-version: v2.3
33+
- name: Set up Node environment
34+
uses: ./.github/actions/setup-node-env
3735

3836
- name: Test
39-
run: deno test
37+
run: pnpm test
38+
39+
- name: Lint
40+
run: pnpm lint
41+
42+
- name: Prettier Check
43+
run: pnpm prettier:check
44+
45+
- name: Typecheck
46+
run: pnpm tsc
4047

4148
- name: Validate
42-
run: deno run scripts/validation/index.ts
49+
run: pnpm validate
4350

4451
- name: Build
45-
run: deno task build
52+
run: pnpm build
4653

4754
- if: ${{ inputs.save_build_artifact }}
4855
uses: actions/upload-artifact@v5

.github/workflows/ab-testing-deploy.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ jobs:
2626
steps:
2727
- uses: actions/checkout@v5
2828

29-
# https://github.com/denoland/setup-deno#latest-stable-for-a-major
30-
- uses: denoland/setup-deno@v1
31-
with:
32-
deno-version: v2.3
29+
- name: Set up Node environment
30+
uses: ./.github/actions/setup-node-env
3331

3432
- name: Download build artifact
3533
uses: actions/download-artifact@v6.0.0
@@ -38,7 +36,7 @@ jobs:
3836
path: ab-testing/dist
3937

4038
- name: Deploy
41-
run: deno run deploy
39+
run: pnpm run deploy
4240
env:
4341
FASTLY_AB_TESTING_CONFIG: ${{ secrets.FASTLY_AB_TESTING_CONFIG }}
4442
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}

.github/workflows/ab-testing-ui.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 🦕 AB testing UI
1+
name: 🧪 AB testing UI
22
on:
33
pull_request:
44
paths:
@@ -15,22 +15,20 @@ jobs:
1515
build-ui:
1616
name: AB testing UI build
1717
runs-on: ubuntu-latest
18-
permissions:
19-
contents: read
2018
defaults:
2119
run:
2220
working-directory: ab-testing/frontend
21+
permissions:
22+
contents: read
2323
steps:
2424
- uses: actions/checkout@v5
2525

26-
# https://github.com/denoland/setup-deno#latest-stable-for-a-major
27-
- uses: denoland/setup-deno@v1
28-
with:
29-
deno-version: v2.3
30-
- name: Install
31-
run: deno install
32-
- name: Build
33-
run: deno run build
26+
- name: Set up Node environment
27+
uses: ./.github/actions/setup-node-env
28+
29+
- name: Build UI
30+
run: pnpm build
31+
3432
- name: Save build
3533
uses: actions/upload-artifact@v5
3634
with:
@@ -41,6 +39,7 @@ jobs:
4139
riff-raff:
4240
name: AB testing Riffraff upload
4341
runs-on: ubuntu-latest
42+
needs: build-ui
4443
permissions:
4544
id-token: write
4645
contents: read

.vscode/settings.json.required

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Copy these to .vscode/settings.json to apply them to your editor – but don't commit it!
33
// https://github.com/guardian/recommendations/blob/main/VSCode.md#do-not-commit-vscode
44
{
5-
"deno.enablePaths": ["scripts/deno", "ab-testing/scripts"],
5+
"deno.enablePaths": ["scripts/deno"],
66
"deno.lint": true,
77
"deno.unstable": false,
88
"typescript.tsdk": "node_modules/typescript/lib",

ab-testing/.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
frontend/.svelte-kit

ab-testing/.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ABTest } from './types';
1+
import type { ABTest } from "./types.ts";
22

33
/**
44
* Tests are defined here. They will be assigned mvt ranges based on the
@@ -21,18 +21,18 @@ import type { ABTest } from './types';
2121

2222
const ABTests: ABTest[] = [
2323
{
24-
name: 'commercial-prebid-v10',
25-
description: 'Testing Prebid.js v10 integration on DCR',
26-
owners: ['commercial.dev@guardian.co.uk'],
27-
status: 'ON',
28-
expirationDate: '2025-12-30',
29-
type: 'client',
24+
name: "commercial-prebid-v10",
25+
description: "Testing Prebid.js v10 integration on DCR",
26+
owners: ["commercial.dev@guardian.co.uk"],
27+
status: "ON",
28+
expirationDate: "2025-12-30",
29+
type: "client",
3030
audienceSize: 0 / 100,
31-
groups: ['control', 'variant'],
31+
groups: ["control", "variant"],
3232
shouldForceMetricsCollection: true,
3333
},
3434
];
3535

36-
const activeABtests = ABTests.filter((test) => test.status === 'ON');
36+
const activeABtests = ABTests.filter((test) => test.status === "ON");
3737

3838
export { ABTests as allABTests, activeABtests };

ab-testing/deno.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

ab-testing/deno.lock

Lines changed: 0 additions & 124 deletions
This file was deleted.

ab-testing/eslint.config.mjs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import guardian from "@guardian/eslint-config";
2+
import { defineConfig, globalIgnores } from "eslint/config";
3+
4+
export default defineConfig([
5+
globalIgnores(["frontend", "eslint.config.mjs", "index.ts"]),
6+
...guardian.configs.recommended,
7+
{
8+
languageOptions: {
9+
parserOptions: {
10+
project: ["./tsconfig.json"],
11+
tsconfigRootDir: "./",
12+
},
13+
},
14+
rules: {
15+
curly: ["error", "multi-line"],
16+
"no-use-before-define": [
17+
"error",
18+
{ functions: true, classes: true },
19+
],
20+
"import/exports-last": "error",
21+
"no-else-return": "error",
22+
},
23+
},
24+
{
25+
files: ["**/*.test.ts"],
26+
rules: {
27+
"@typescript-eslint/no-floating-promises": [
28+
"off",
29+
{
30+
allowForKnownSafeCalls: [
31+
{
32+
from: "package",
33+
name: ["it", "describe"],
34+
package: "node:test",
35+
},
36+
],
37+
},
38+
],
39+
"@typescript-eslint/unbound-method": "off",
40+
// Allowing async tests without await for mocking convenience
41+
"@typescript-eslint/require-await": "off",
42+
},
43+
},
44+
]);

0 commit comments

Comments
 (0)