Skip to content

Commit

Permalink
Merge branch 'node-20-2' into upgrade-packages
Browse files Browse the repository at this point in the history
  • Loading branch information
rcantin-w committed Oct 3, 2024
2 parents 6d232d6 + d02da81 commit 2070def
Show file tree
Hide file tree
Showing 154 changed files with 4,538 additions and 9,455 deletions.
76 changes: 38 additions & 38 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
env:
LIVE_PIPELINE: "2023-03-24"
LIVE_PIPELINE: '2023-03-24'
steps:
- label: "autoformat"
command: ".buildkite/scripts/autoformat.sh"
- label: 'autoformat'
command: '.buildkite/scripts/autoformat.sh'
plugins:
- docker-compose#v4.11.0:
run: tooling
mount-ssh-agent: true
mount-buildkite-agent: true
propagate-environment: true

- label: "test: API"
- label: 'test: API'
plugins:
- docker-compose#v4.11.0:
run: api
command: ["yarn", "test"]
command: ['yarn', 'test']

- label: "test: ETL pipeline"
- label: 'test: ETL pipeline'
plugins:
- docker-compose#v4.11.0:
run: pipeline
command: ["yarn", "test"]
command: ['yarn', 'test']

- label: "test: webhook"
- label: 'test: webhook'
plugins:
- docker-compose#v4.11.0:
run: webhook
command: ["yarn", "test"]
command: ['yarn', 'test']

- label: "test: unpublisher"
- label: 'test: unpublisher'
plugins:
- docker-compose#v4.11.0:
run: unpublisher
command: ["yarn", "test"]
command: ['yarn', 'test']

- wait

- label: "publish: API"
branches: "main"
- label: 'publish: API'
branches: 'main'
plugins:
- wellcomecollection/aws-assume-role#v0.2.2:
role: "arn:aws:iam::756629837203:role/catalogue-ci"
role: 'arn:aws:iam::756629837203:role/catalogue-ci'
- ecr#v2.1.1:
login: true
- docker-compose#v4.11.0:
Expand All @@ -49,8 +49,8 @@ steps:
- api:756629837203.dkr.ecr.eu-west-1.amazonaws.com/weco/content-api:ref.${BUILDKITE_COMMIT}
- api:756629837203.dkr.ecr.eu-west-1.amazonaws.com/weco/content-api:latest

- label: "publish: pipeline & unpublisher ($LIVE_PIPELINE)"
branches: "main"
- label: 'publish: pipeline & unpublisher ($LIVE_PIPELINE)'
branches: 'main'
command: |
yarn install --frozen-lockfile
yarn workspace @weco/content-pipeline run package
Expand All @@ -59,7 +59,7 @@ steps:
.buildkite/scripts/upload_lambda_package.sh content-unpublisher-$LIVE_PIPELINE ./unpublisher/package.zip
plugins:
- wellcomecollection/aws-assume-role#v0.2.2:
role: "arn:aws:iam::756629837203:role/catalogue-ci"
role: 'arn:aws:iam::756629837203:role/catalogue-ci'
- docker-compose#v4.11.0:
run: tooling
mount-ssh-agent: true
Expand All @@ -70,15 +70,15 @@ steps:
- AWS_SECRET_ACCESS_KEY
- AWS_SESSION_TOKEN

- label: "publish: webhook"
branches: "main"
- label: 'publish: webhook'
branches: 'main'
command: |
yarn install --frozen-lockfile
yarn workspace @weco/prismic-webhook run package
.buildkite/scripts/upload_lambda_package.sh content-prismic-webhook ./webhook/package.zip
plugins:
- wellcomecollection/aws-assume-role#v0.2.2:
role: "arn:aws:iam::756629837203:role/catalogue-ci"
role: 'arn:aws:iam::756629837203:role/catalogue-ci'
- docker-compose#v4.11.0:
run: tooling
mount-ssh-agent: true
Expand All @@ -91,52 +91,52 @@ steps:

- wait

- label: "deploy: live pipeline & unpublisher"
branches: "main"
- label: 'deploy: live pipeline & unpublisher'
branches: 'main'
concurrency: 1
concurrency_group: "content-pipeline/deploy-stage"
concurrency_group: 'content-pipeline/deploy-stage'
command: |
.buildkite/scripts/deploy_lambda.sh content-unpublisher-$LIVE_PIPELINE ref.$BUILDKITE_COMMIT
.buildkite/scripts/deploy_lambda.sh content-pipeline-$LIVE_PIPELINE ref.$BUILDKITE_COMMIT
plugins:
- wellcomecollection/aws-assume-role#v0.2.2:
role: "arn:aws:iam::756629837203:role/catalogue-ci"
role: 'arn:aws:iam::756629837203:role/catalogue-ci'

- label: "deploy: webhook"
branches: "main"
- label: 'deploy: webhook'
branches: 'main'
concurrency: 1
concurrency_group: "content-webhook/deploy"
concurrency_group: 'content-webhook/deploy'
command: |
.buildkite/scripts/deploy_lambda.sh content-prismic-webhook ref.$BUILDKITE_COMMIT
plugins:
- wellcomecollection/aws-assume-role#v0.2.2:
role: "arn:aws:iam::756629837203:role/catalogue-ci"
role: 'arn:aws:iam::756629837203:role/catalogue-ci'

- label: "deploy: API stage"
branches: "main"
- label: 'deploy: API stage'
branches: 'main'
concurrency: 1
concurrency_group: "content-api/deploy-stage"
concurrency_group: 'content-api/deploy-stage'
command: |
ENV_TAG="env.stage" ./builds/update_ecr_image_tag.sh weco/content-api
CLUSTER="content-api" ./builds/deploy_ecs_services.sh content-api-stage
agents:
queue: nano
plugins:
- wellcomecollection/aws-assume-role#v0.2.2:
role: "arn:aws:iam::756629837203:role/catalogue-ci"
role: 'arn:aws:iam::756629837203:role/catalogue-ci'

- block: ":rocket: deploy to prod"
branches: "main"
- block: ':rocket: deploy to prod'
branches: 'main'

- label: "deploy: API prod"
branches: "main"
- label: 'deploy: API prod'
branches: 'main'
concurrency: 1
concurrency_group: "content-api/deploy-prod"
concurrency_group: 'content-api/deploy-prod'
command: |
ENV_TAG="env.prod" ./builds/update_ecr_image_tag.sh weco/content-api
CLUSTER="content-api" ./builds/deploy_ecs_services.sh content-api-prod
agents:
queue: nano
plugins:
- wellcomecollection/aws-assume-role#v0.2.2:
role: "arn:aws:iam::756629837203:role/catalogue-ci"
role: 'arn:aws:iam::756629837203:role/catalogue-ci'
2 changes: 0 additions & 2 deletions .editorconfig

This file was deleted.

118 changes: 118 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
const sharedPlugins = ['import', 'jest', 'prettier', 'standard'];

const sharedExtends = [
'standard',
'prettier',
'plugin:prettier/recommended', // Should be the last extension https://github.com/prettier/eslint-plugin-prettier#recommended-configuration
];

const sharedRules = {
'eol-last': 'error',
'import/order': [
'warn',
{
groups: [
['builtin', 'external'],
['internal', 'sibling', 'parent', 'index'],
],
pathGroups: [
{
pattern: '@weco/**',
group: 'external',
position: 'after',
},
],
pathGroupsExcludedImportTypes: ['builtin', 'object'],
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
'newlines-between': 'always',
},
],
'no-mixed-operators': 'warn',
'no-multi-spaces': 'warn',
'no-multi-str': 'off',
'no-restricted-imports': [
'error',
{ patterns: ['../*'] }, // Should only import relatively from same directory
],
'no-restricted-syntax': [
'error',
"JSXElement.children > [expression.callee.property.name='stringify']",
],
'no-return-assign': 'off',
'prettier/prettier': 'error',
'sort-imports': [
'error',
{
ignoreCase: true,
ignoreDeclarationSort: true,
},
],
};

const ignorePatterns = [
'/**/node_modules/',
'/**/libs/',
'/**/lib/',
'/**/_next/',
'/**/dist/',
];

module.exports = {
parser: '@babel/eslint-parser',
plugins: sharedPlugins,
env: {
'jest/globals': true,
},
extends: sharedExtends,
ignorePatterns,
rules: sharedRules,
reportUnusedDisableDirectives: true,
parserOptions: {
ecmaFeatures: {
jsx: true,
},
requireConfigFile: false,
},
overrides: [
{
// we have non-test files in the pipeline/test directory
// this ensures the jest rules only apply to test files
files: ['*test.ts'],
extends: ['plugin:jest/recommended'],
},
{
files: ['*.ts'],
parser: '@typescript-eslint/parser',
plugins: [...sharedPlugins, '@typescript-eslint'],
extends: [...sharedExtends, 'plugin:@typescript-eslint/recommended'],
rules: {
...sharedRules,
'no-use-before-define': 'off',
'@typescript-eslint/array-type': ['error'],
'@typescript-eslint/no-use-before-define': [
'error',
{ functions: false },
],
'@typescript-eslint/no-unused-vars': [
'error',
{ ignoreRestSiblings: true },
],
'jest/no-standalone-expect': [
'error',
{ additionalTestBlockFunctions: ['each.test'] },
],
},
},
// Some directories don't have an absolute import equivalent so ignoring
// import rules for them.
{
files: ['webhook/**'],
rules: {
'no-restricted-imports': 'off',
},
},
],
};
4 changes: 2 additions & 2 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# then close them 3 days later if there is still no activity.
#
# Shamelessly copied from https://github.com/guardian/.github/blob/main/workflow-templates/stale.yml
name: "Stale PR Handler"
name: 'Stale PR Handler'

on:
schedule:
# Check for Stale PRs every Monday to Thursday morning
# Don't check on Fridays as it wouldn't be very nice to have a bot mark your PR as Stale on Friday and then close it on Monday morning!
- cron: "0 6 * * MON-THU"
- cron: '0 6 * * MON-THU'

permissions:
pull-requests: write
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/tsc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Typescript'
on:
push:

jobs:
tsc:
name: tsc
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: install Node
# https://github.com/actions/setup-node?tab=readme-ov-file#usage
# The node-version input is optional. If not supplied, the node version from PATH will be used.
# However, it is recommended to always specify Node.js version and don't rely on the system one.
uses: actions/setup-node@v4
with:
node-version: 20
- name: yarn tsc
run: yarn install && yarn tsc
6 changes: 6 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
arrowParens: 'avoid',
endOfLine: 'auto',
singleQuote: true,
trailingComma: 'es5',
};
1 change: 0 additions & 1 deletion .prettierrc.json

This file was deleted.

11 changes: 10 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
{
"editor.formatOnSave": true
// We add this to avoid having linting commits in CI
"editor.tabSize": 2,
"files.encoding": "utf8",
"editor.codeActionsOnSave": {
"editor.insertSpaces": "explicit",
"source.fixAll.eslint": "explicit",
"source.fixAll.stylelint": "explicit",
"files.trimTrailingWhitespace": "explicit"
},
"stylelint.validate": ["typescriptreact"]
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ These are the services that back our [Content API](https://developers.wellcomeco

![Architecture diagram](https://github.com/wellcomecollection/content-api/assets/4429247/b29a6bf5-f5af-426c-b827-550b84c5541c)

### Services
## Services

- `/pipeline`: runs on a schedule, queries for updated content, transforms it and puts it into an index in the content ES cluster.
- `/api`: queries the Elasticsearch index
- `/webhook`: a Lambda handler exposed via a function URL for handling Prismic webhook events and publishing them to a EventBridge bus
- `/unpublisher`: receives events published by the webhook, extracts document IDs from them and removes them from the ES index.

### Developing
## Developing

- Deployment is all done in CI, see `.buildkite/pipeline.yml`
- `husky` will set up a pre-commit hook for autoformatting when you first install dependencies
3 changes: 1 addition & 2 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Build this with the repo root as the build context
# TODO use node:20 and test
FROM public.ecr.aws/docker/library/node:18
FROM public.ecr.aws/docker/library/node:20

WORKDIR /app

Expand Down
Loading

0 comments on commit 2070def

Please sign in to comment.