Skip to content
This repository has been archived by the owner on Nov 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from guardian/infra
Browse files Browse the repository at this point in the history
Initialise an empty GuCDK project
  • Loading branch information
njdehoog authored Sep 18, 2023
2 parents e109e15 + 52c7e27 commit e0d4e9c
Show file tree
Hide file tree
Showing 14 changed files with 8,090 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Find full documentation here https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions
name: CI

on:
pull_request:

# Manual invocation.
workflow_dispatch:

push:
# TODO uncomment these lines
# branches:
# main

# Ensure we only ever have one build running at a time.
# If we push twice in quick succession, the first build will be stopped once the second starts.
# This avoids any race conditions.
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
CI:
runs-on: ubuntu-latest

# See https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
permissions:
# required by aws-actions/configure-aws-credentials
id-token: write
contents: read
steps:
- uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
cache-dependency-path: 'cdk/package-lock.json'

- name: CDK build
working-directory: cdk
run: |
npm ci
npm run lint
npm test
npm run synth
# Setup AWS credentials to enable uploading to S3 for Riff-Raff.
# See https://github.com/aws-actions/configure-aws-credentials
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.GU_RIFF_RAFF_ROLE_ARN }}
aws-region: eu-west-1

# See https://github.com/guardian/actions-riff-raff
- name: Upload to riff-raff
uses: guardian/actions-riff-raff@v2
with:
projectName: interactives::interactive-tilemaker
configPath: cdk/cdk.out/riff-raff.yaml # Generated by https://github.com/guardian/cdk/tree/main/src/experimental/riff-raff-yaml-file
contentDirectories: |
cdk.out:
- cdk/cdk.out
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.16.0
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# TODO
- [X] Follow https://github.com/guardian/cdk/blob/main/docs/setting-up-a-gucdk-project.md to create a new GuCDK project
```sh
npx @guardian/cdk@latest new \
--app riff-raff \
--stack deploy \
--stage CODE \
--stage PROD \
--package-manager npm
```
- [x] Setup the project in CI (https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions) and CD
- [ ] Run the Dockerfile in AWS (via GuCDK)
- [ ] Profit?
11 changes: 11 additions & 0 deletions cdk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.js
!jest.config.js
!jest.setup.js
!.eslintrc.js
*.d.ts
node_modules
dist

# CDK asset staging directory
.cdk.staging
cdk.out
5 changes: 5 additions & 0 deletions cdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Infrastructure

This directory defines the components to be deployed to AWS.

See [`package.json`](./package.json) for a list of available scripts.
7 changes: 7 additions & 0 deletions cdk/bin/cdk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import "source-map-support/register";
import { GuRootExperimental } from "@guardian/cdk/lib/experimental/constructs/root";
import { InteractiveTilemaker } from "../lib/interactive-tilemaker";

const app = new GuRootExperimental();

new InteractiveTilemaker(app, "InteractiveTilemaker-PROD", { stack: "interactives", stage: "PROD", env: { region: 'eu-west-1' } });
7 changes: 7 additions & 0 deletions cdk/cdk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"app": "npx ts-node bin/cdk.ts",
"context": {
"aws-cdk:enableDiffNoFail": "true",
"@aws-cdk/core:stackRelativeExports": "true"
}
}
1 change: 1 addition & 0 deletions cdk/jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jest.mock("@guardian/cdk/lib/constants/tracking-tag");
10 changes: 10 additions & 0 deletions cdk/lib/__snapshots__/interactive-tilemaker.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`The InteractiveTilemaker stack matches the snapshot 1`] = `
{
"Metadata": {
"gu:cdk:constructs": [],
"gu:cdk:version": "TEST",
},
}
`;
12 changes: 12 additions & 0 deletions cdk/lib/interactive-tilemaker.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { App } from "aws-cdk-lib";
import { Template } from "aws-cdk-lib/assertions";
import { InteractiveTilemaker } from "./interactive-tilemaker";

describe("The InteractiveTilemaker stack", () => {
it("matches the snapshot", () => {
const app = new App();
const stack = new InteractiveTilemaker(app, "InteractiveTilemaker", { stack: "interactives", stage: "TEST" });
const template = Template.fromStack(stack);
expect(template.toJSON()).toMatchSnapshot();
});
});
11 changes: 11 additions & 0 deletions cdk/lib/interactive-tilemaker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { join } from "path";

Check warning on line 1 in cdk/lib/interactive-tilemaker.ts

View workflow job for this annotation

GitHub Actions / CI

'join' is defined but never used
import type { GuStackProps } from "@guardian/cdk/lib/constructs/core";
import { GuStack } from "@guardian/cdk/lib/constructs/core";
import type { App } from "aws-cdk-lib";
import { CfnInclude } from "aws-cdk-lib/cloudformation-include";

Check warning on line 5 in cdk/lib/interactive-tilemaker.ts

View workflow job for this annotation

GitHub Actions / CI

'CfnInclude' is defined but never used

export class InteractiveTilemaker extends GuStack {
constructor(scope: App, id: string, props: GuStackProps) {
super(scope, id, props);
}
}
Loading

0 comments on commit e0d4e9c

Please sign in to comment.