Skip to content

Commit e875c30

Browse files
committed
split projects
1 parent 01fbd42 commit e875c30

13 files changed

+921
-90
lines changed

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

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,16 @@ permissions:
44
contents: read
55

66
on:
7-
pull_request:
8-
paths:
9-
- 'ab-testing/**'
10-
- '.github/workflows/ab-testing-*.yml'
117
push:
12-
branches:
13-
- main
148
paths:
159
- 'ab-testing/**'
16-
- '.github/workflows/ab-testing-*.yml'
10+
- '.github/workflows/ab-testing-ci.yml'
11+
- '!.github/workflows/ab-testing-deployment-lambda/**'
1712

1813
jobs:
19-
dictionaries-ci:
14+
config-ci:
2015
runs-on: ubuntu-latest
21-
name: Dictionaries CI
16+
name: Config CI
2217
defaults:
2318
run:
2419
working-directory: ab-testing
@@ -55,35 +50,6 @@ jobs:
5550
name: ab-testing-build
5651
path: ab-testing/dist
5752

58-
lambda-ci:
59-
name: Deploy Lambda CI
60-
runs-on: ubuntu-latest
61-
defaults:
62-
run:
63-
working-directory: ab-testing/dictionary-deploy-lambda
64-
permissions:
65-
contents: read
66-
steps:
67-
- uses: actions/checkout@v5
68-
69-
- name: Set up Node environment
70-
uses: ./.github/actions/setup-node-env
71-
72-
- name: Build Lambda
73-
run: pnpm build
74-
75-
- name: Zip app artifact
76-
run: |
77-
cd dist
78-
zip -r lambda.zip .
79-
zip -j lambda.zip ../package.json
80-
81-
- name: Save build
82-
uses: actions/upload-artifact@v5
83-
with:
84-
name: ab-testing-lambda-build
85-
path: ab-testing/dictionary-deploy-lambda/dist/lambda.zip
86-
8753
ui-ci:
8854
name: UI CI
8955
runs-on: ubuntu-latest
@@ -110,7 +76,7 @@ jobs:
11076

11177
riff-raff:
11278
runs-on: ubuntu-latest
113-
needs: [dictionaries-ci, ui-ci, lambda-ci]
79+
needs: [dictionaries-ci, ui-ci]
11480
permissions:
11581
id-token: write
11682
contents: read
@@ -129,7 +95,7 @@ jobs:
12995
- name: Set up Node
13096
uses: ./.github/actions/setup-node-env
13197

132-
- name: Fetch build
98+
- name: Fetch config build
13399
uses: actions/[email protected]
134100
with:
135101
name: ab-testing-build
@@ -141,12 +107,6 @@ jobs:
141107
name: ui-build
142108
path: ab-testing/frontend/output/ab-tests.html
143109

144-
- name: Fetch Lambda build
145-
uses: actions/[email protected]
146-
with:
147-
name: ab-testing-lambda-build
148-
path: ab-testing/dictionary-deploy-lambda/dist/lambda.zip
149-
150110
- name: CDK Test
151111
run: pnpm cdk:test
152112

@@ -159,13 +119,11 @@ jobs:
159119
roleArn: ${{ secrets.GU_RIFF_RAFF_ROLE_ARN }}
160120
githubToken: ${{ secrets.GITHUB_TOKEN }}
161121
projectName: dotcom:ab-testing
162-
configPath: ab-testing/cdk.out/riff-raff.yaml
122+
configPath: ab-testing/cdk.out/ab-testing-config/riff-raff.yaml
163123
contentDirectories: |
164124
ab-testing-config-artifacts:
165125
- ab-testing/dist
166-
ab-testing:
167-
- ab-testing/dictionary-deploy-lambda/dist/lambda.zip
168126
ab-testing-ui-artifact:
169127
- ab-testing/frontend/output/ab-tests.html
170128
cdk.out:
171-
- ab-testing/cdk.out
129+
- ab-testing/cdk.out/ab-testing-config
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: 🧪 AB testing
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
paths:
9+
- 'ab-testing/dictionary-deploy-lambda/**'
10+
- 'ab-testing/lib/**'
11+
- '.github/workflows/ab-testing-lambda-ci.yml'
12+
13+
jobs:
14+
lambda-ci:
15+
name: Deploy Lambda CI
16+
runs-on: ubuntu-latest
17+
defaults:
18+
run:
19+
working-directory: ab-testing/dictionary-deploy-lambda
20+
permissions:
21+
contents: read
22+
steps:
23+
- uses: actions/checkout@v5
24+
25+
- name: Set up Node environment
26+
uses: ./.github/actions/setup-node-env
27+
28+
- name: Build Lambda
29+
run: pnpm build
30+
31+
- name: Zip app artifact
32+
run: |
33+
cd dist
34+
zip -r lambda.zip .
35+
zip -j lambda.zip ../package.json
36+
37+
- name: Save build
38+
uses: actions/upload-artifact@v5
39+
with:
40+
name: ab-testing-lambda-build
41+
path: ab-testing/dictionary-deploy-lambda/dist/lambda.zip
42+
43+
riff-raff:
44+
runs-on: ubuntu-latest
45+
needs: [lambda-ci]
46+
permissions:
47+
id-token: write
48+
contents: read
49+
pull-requests: write
50+
defaults:
51+
run:
52+
working-directory: ab-testing
53+
54+
steps:
55+
- name: Checkout
56+
uses: actions/checkout@v5
57+
with:
58+
fetch-depth: 0
59+
persist-credentials: false
60+
61+
- name: Set up Node
62+
uses: ./.github/actions/setup-node-env
63+
64+
- name: Fetch Lambda build
65+
uses: actions/[email protected]
66+
with:
67+
name: ab-testing-lambda-build
68+
path: ab-testing/dictionary-deploy-lambda/dist/lambda.zip
69+
70+
- name: CDK Test
71+
run: pnpm cdk:test
72+
73+
- name: CDK synth
74+
run: pnpm synth:deployment-lambda
75+
76+
- name: Riff-Raff Upload
77+
uses: guardian/[email protected]
78+
with:
79+
roleArn: ${{ secrets.GU_RIFF_RAFF_ROLE_ARN }}
80+
githubToken: ${{ secrets.GITHUB_TOKEN }}
81+
projectName: dotcom:ab-testing-deployment-lambda
82+
configPath: ab-testing/cdk.out/deployment-lambda/riff-raff.yaml
83+
contentDirectories: |
84+
ab-testing-deployment-lambda:
85+
- ab-testing/dictionary-deploy-lambda/dist/lambda.zip
86+
cdk.out:
87+
- ab-testing/cdk.out/deployment-lambda

ab-testing/cdk.context.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"acknowledged-issue-numbers": [34892]
3+
}

ab-testing/cdk.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"app": "node cdk/bin/cdk.ts",
32
"context": {
43
"aws-cdk:enableDiffNoFail": "true",
54
"@aws-cdk/core:stackRelativeExports": "true"

ab-testing/cdk/bin/cdk.ts renamed to ab-testing/cdk/bin/ab-testing-config.cdk.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
11
import "source-map-support/register.js";
22
import { RiffRaffYamlFile } from "@guardian/cdk/lib/riff-raff-yaml-file/index.js";
33
import { App } from "aws-cdk-lib";
4-
import { AbTestingStack } from "../lib/abTestingStack.ts";
4+
import { AbTestingConfig } from "../lib/abTestingConfig.ts";
55

6-
const app = new App();
6+
const app = new App({ outdir: "cdk.out/ab-testing-config" });
77

8-
const appName = "ab-testing";
9-
10-
new AbTestingStack(app, "AbTestingCode", {
8+
new AbTestingConfig(app, "AbTestingConfigCode", {
119
stack: "frontend",
1210
stage: "CODE",
1311
env: {
1412
region: "eu-west-1",
1513
},
16-
app: appName,
1714
});
1815

19-
new AbTestingStack(app, "AbTestingProd", {
16+
new AbTestingConfig(app, "AbTestingConfigProd", {
2017
stack: "frontend",
2118
stage: "PROD",
2219
env: {
2320
region: "eu-west-1",
2421
},
25-
app: appName,
2622
});
2723

2824
const riffRaff = new RiffRaffYamlFile(app);
@@ -58,9 +54,15 @@ deployments.set("admin/ab-testing", {
5854
},
5955
});
6056

57+
console.log(deployments);
58+
59+
const cfnDeployment = deployments.get(
60+
`cfn-eu-west-1-frontend-ab-testing-config`,
61+
)!;
62+
6163
// We need the test artifacts in place before deploying the lambda that uses them
62-
deployments
63-
.get(`cfn-eu-west-1-frontend-ab-testing-stack`)
64-
?.dependencies?.push("config/ab-testing");
64+
cfnDeployment.dependencies = cfnDeployment.dependencies
65+
? [...cfnDeployment.dependencies, "config/ab-testing"]
66+
: ["config/ab-testing"];
6567

6668
riffRaff.synth();
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import "source-map-support/register.js";
2+
import { GuRoot } from "@guardian/cdk/lib/constructs/root.js";
3+
import { DeploymentLambda } from "../lib/deploymentLambda.ts";
4+
5+
const app = new GuRoot({ outdir: "cdk.out/deployment-lambda" });
6+
7+
new DeploymentLambda(app, "AbTestingDeploymentLambdaCode", {
8+
stack: "frontend",
9+
stage: "CODE",
10+
env: {
11+
region: "eu-west-1",
12+
},
13+
});
14+
15+
new DeploymentLambda(app, "AbTestingDeploymentLambdaProd", {
16+
stack: "frontend",
17+
stage: "PROD",
18+
env: {
19+
region: "eu-west-1",
20+
},
21+
});
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
exports[`The ID5 Baton Lambda stack > matches the CODE snapshot 1`] = `
2+
{
3+
"Metadata": {
4+
"gu:cdk:constructs": [],
5+
"gu:cdk:version": "62.0.1"
6+
},
7+
"Resources": {
8+
"InvokeDictionaryDeployLambda": {
9+
"Type": "Custom::FastlyEdgeDictionaryDeploy",
10+
"Properties": {
11+
"ServiceToken": {
12+
"Fn::Join": [
13+
"",
14+
[
15+
"arn:",
16+
{
17+
"Ref": "AWS::Partition"
18+
},
19+
":lambda:eu-west-1:",
20+
{
21+
"Ref": "AWS::AccountId"
22+
},
23+
":function:undefined-CODE"
24+
]
25+
]
26+
},
27+
"ServiceTimeout": "300"
28+
},
29+
"UpdateReplacePolicy": "Delete",
30+
"DeletionPolicy": "Delete"
31+
}
32+
}
33+
}
34+
`;
35+
36+
exports[`The ID5 Baton Lambda stack > matches the PROD snapshot 1`] = `
37+
{
38+
"Metadata": {
39+
"gu:cdk:constructs": [],
40+
"gu:cdk:version": "62.0.1"
41+
},
42+
"Resources": {
43+
"InvokeDictionaryDeployLambda": {
44+
"Type": "Custom::FastlyEdgeDictionaryDeploy",
45+
"Properties": {
46+
"ServiceToken": {
47+
"Fn::Join": [
48+
"",
49+
[
50+
"arn:",
51+
{
52+
"Ref": "AWS::Partition"
53+
},
54+
":lambda:eu-west-1:",
55+
{
56+
"Ref": "AWS::AccountId"
57+
},
58+
":function:undefined-PROD"
59+
]
60+
]
61+
},
62+
"ServiceTimeout": "300"
63+
},
64+
"UpdateReplacePolicy": "Delete",
65+
"DeletionPolicy": "Delete"
66+
}
67+
}
68+
}
69+
`;

0 commit comments

Comments
 (0)