Skip to content

Commit

Permalink
Merge pull request #272 from guardian/add-github-action-ci
Browse files Browse the repository at this point in the history
Add Continuous Integration (CI) as GitHub Action
  • Loading branch information
rtyley authored Jun 29, 2022
2 parents ca608a4 + 6490ae5 commit 9271a64
Show file tree
Hide file tree
Showing 9 changed files with 8,299 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI
on:
pull_request:
workflow_dispatch:
push:
branches:
- main
jobs:
CI:
runs-on: ubuntu-latest
permissions:
id-token: write # Needed to interact with GitHub's OIDC Token endpoint
contents: read
steps:
- uses: actions/checkout@v3
- uses: aws-actions/configure-aws-credentials@v1 # Needed for S3 read access for the tests!
with:
# The AWS role is configured as a GitHub Repo secret, the value is the cloudformation-output of the
# 'Facia-Scala-Client-CI-Role-Provider' cloudformation stack.
role-to-assume: ${{ secrets.AWS_ROLE_FOR_TESTS }}
aws-region: eu-west-1
- uses: coursier/cache-action@v6
- uses: olafurpg/setup-scala@v13
with:
java-version: [email protected]
- name: Build and Test
run: sbt test
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.
9 changes: 9 additions & 0 deletions cdk/bin/cdk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'source-map-support/register';
import { App } from 'aws-cdk-lib';
import { FaciaScalaClientTesting } from '../lib/facia-scala-client-testing';

const app = new App();
new FaciaScalaClientTesting(app, 'FaciaScalaClientTesting-INFRA', {
stack: 'facia-scala-client',
stage: 'INFRA',
});
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"
}
}
32 changes: 32 additions & 0 deletions cdk/lib/facia-scala-client-testing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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 {GuGithubActionsRole} from "@guardian/cdk/lib/constructs/iam";
import {GuAllowPolicy} from "@guardian/cdk/lib/constructs/iam/policies/base-policy";

export class FaciaScalaClientTesting extends GuStack {
constructor(scope: App, id: string, props: GuStackProps) {
super(scope, id, props);
let fapiBucketArn = "arn:aws:s3:::facia-tool-store"
new GuGithubActionsRole(this, {
policies: [new GuAllowPolicy(
this,
"fapi-s3-bucket-access",
{
actions: [
"s3:GetObject", // required by FAPI to download files
"s3:ListBucket" // avoiding S3 AccessDenied errors when FAPI tries to get nonexistent objects
],
resources: [
`${fapiBucketArn}/DEV/*`, // object resource specified for s3:GetObject
fapiBucketArn // bucket resource specified for s3:ListBucket
]
}
)],
condition: {
githubOrganisation: "guardian",
repositories: "facia-scala-client:*"
}
})
}
}
Loading

0 comments on commit 9271a64

Please sign in to comment.