Skip to content

Commit

Permalink
Merge pull request #204 from Financial-Times/tool-kit
Browse files Browse the repository at this point in the history
CPP-1641 Migrate to Tool Kit
  • Loading branch information
ivomurrell authored Feb 1, 2024
2 parents 2da4f1a + 0e612a1 commit c7a2d6a
Show file tree
Hide file tree
Showing 10 changed files with 5,915 additions and 8,463 deletions.
230 changes: 73 additions & 157 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,176 +1,81 @@
# generator: n-circle2-cli
# template: component

references:

container_config_node: &container_config_node
working_directory: ~/project/build
docker:
- image: cimg/node:<< parameters.node-version >>-browsers
parameters:
node-version:
default: "18.16"
type: string

workspace_root: &workspace_root ~/project

attach_workspace: &attach_workspace
attach_workspace:
at: *workspace_root

npm_cache_keys: &npm_cache_keys
keys:
- v6-dependency-npm-{{ checksum "package.json" }}-
- v6-dependency-npm-{{ checksum "package.json" }}
- v6-dependency-npm-

cache_npm_cache: &cache_npm_cache
save_cache:
key: v3-dependency-npm-{{ checksum "package.json" }}-{{ epoch }}
paths:
- ./node_modules/

restore_npm_cache: &restore_npm_cache
restore_cache:
<<: *npm_cache_keys

filters_only_main: &filters_only_main
branches:
only: main

filters_ignore_main: &filters_ignore_main
branches:
ignore: main

filters_ignore_tags: &filters_ignore_tags
tags:
ignore: /.*/

filters_version_tag: &filters_version_tag
tags:
only:
- /^v?\d+\.\d+\.\d+(?:-beta\.\d+)?$/
branches:
ignore: /.*/

# CONFIG GENERATED BY DOTCOM-TOOL-KIT, DO NOT EDIT BY HAND
version: 2.1

orbs:
node: circleci/[email protected]

tool-kit: financial-times/dotcom-tool-kit@4
executors:
node:
docker:
- image: cimg/node:18.16-browsers
jobs:

build:
<<: *container_config_node
checkout:
docker:
- image: cimg/base:stable
steps:
- checkout
- run:
name: Checkout next-ci-shared-helpers
command: git clone --depth 1
[email protected]:Financial-Times/next-ci-shared-helpers.git --branch
unpin-heroku .circleci/shared-helpers
- *restore_npm_cache
- run:
name: Install project dependencies
command: make install
- run:
name: shared-helper / generate-build-state-artifacts
command: .circleci/shared-helpers/helper-generate-build-state-artifacts
when: always
- *cache_npm_cache
- store_artifacts:
path: build-state
destination: build-state
- persist_to_workspace:
root: *workspace_root
paths:
- build

test:
<<: *container_config_node
steps:
- *attach_workspace
- run:
name: Run tests
command: make test
environment:
JEST_JUNIT_OUTPUT: test-results/jest/results.xml
MOCHA_FILE: test-results/mocha/results.xml
- store_test_results:
path: test-results
- store_artifacts:
path: test-results
destination: test-results

publish:
<<: *container_config_node
steps:
- *attach_workspace
- run:
name: shared-helper / npm-store-auth-token
command: .circleci/shared-helpers/helper-npm-store-auth-token
- run: npx snyk monitor --org=customer-products
--project-name=Financial-Times/n-test
- run:
name: shared-helper / npm-version-and-publish-public
command: .circleci/shared-helpers/helper-npm-version-and-publish-public

- tool-kit/persist-workspace:
path: .
workflows:

version: 2

build-test:
tool-kit:
when:
not:
equal:
- scheduled_pipeline
- << pipeline.trigger_source >>
jobs:
- build:
- checkout:
filters:
<<: *filters_ignore_tags
name: build-v<< matrix.node-version >>
matrix:
parameters:
node-version: [ "16.20", "18.16" ]
- test:
tags:
only: /^v\d+\.\d+\.\d+(-.+)?/
- waiting-for-approval:
type: approval
filters:
branches:
only: /(^renovate-.*|^nori/.*)/
- tool-kit/setup:
name: tool-kit/setup-<< matrix.executor >>
requires:
- build-v<< matrix.node-version >>
name: test-v<< matrix.node-version >>
- checkout
- waiting-for-approval
matrix:
parameters:
node-version: [ "16.20", "18.16" ]

build-test-publish:
when:
not:
equal:
- scheduled_pipeline
- << pipeline.trigger_source >>
jobs:
- build:
executor:
- node
filters:
<<: *filters_version_tag
name: build-v<< matrix.node-version >>
tags:
only: /^v\d+\.\d+\.\d+(-.+)?/
- tool-kit/build:
name: tool-kit/build-<< matrix.executor >>
requires:
- tool-kit/setup-<< matrix.executor >>
matrix:
parameters:
node-version: [ "16.20", "18.16" ]
- test:
executor:
- node
filters:
<<: *filters_version_tag
tags:
only: /^v\d+\.\d+\.\d+(-.+)?/
- tool-kit/test:
name: tool-kit/test-<< matrix.executor >>
requires:
- build-v<< matrix.node-version >>
name: test-v<< matrix.node-version >>
- tool-kit/build-<< matrix.executor >>
matrix:
parameters:
node-version: [ "16.20", "18.16" ]
- publish:
context: npm-publish-token
executor:
- node
filters:
<<: *filters_version_tag
tags:
only: /^v\d+\.\d+\.\d+(-.+)?/
- tool-kit/publish-tag:
requires:
- test-v18.16

- tool-kit/test-node
name: tool-kit/publish-tag-node
executor: node
filters:
tags:
only: /^v\d+\.\d+\.\d+(-.+)?/
branches:
ignore: /.*/
context: npm-publish-token
nightly:
when:
and:
Expand All @@ -181,17 +86,28 @@ workflows:
- nightly
- << pipeline.schedule.name >>
jobs:
- build:
context: next-nightly-build
name: build-v<< matrix.node-version >>
- checkout
- tool-kit/setup:
name: tool-kit/setup-<< matrix.executor >>
requires:
- checkout
matrix:
parameters:
executor:
- node
- tool-kit/build:
name: tool-kit/build-<< matrix.executor >>
requires:
- tool-kit/setup-<< matrix.executor >>
matrix:
parameters:
node-version: [ "16.20", "18.16" ]
- test:
executor:
- node
- tool-kit/test:
name: tool-kit/test-<< matrix.executor >>
requires:
- build-v<< matrix.node-version >>
context: next-nightly-build
name: test-v<< matrix.node-version >>
- tool-kit/build-<< matrix.executor >>
matrix:
parameters:
node-version: [ "16.20", "18.16" ]
executor:
- node
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
.idea/n
.pa11yci.js
npm-debug.log
.eslintrc.js
.editorconfig
/.toolkitstate
7 changes: 7 additions & 0 deletions .toolkitrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins:
- "@dotcom-tool-kit/component"
- "@dotcom-tool-kit/jest"
hooks: {}
options:
"@dotcom-tool-kit/circleci":
nodeVersion: "18.16-browsers"
14 changes: 0 additions & 14 deletions Makefile

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ Run next-article and next-router locally:

```sh
$ cd ~/next-article
$ make run
$ npm start
$ cd ~/next-router
4 make run
$ npm start
```

Run ngrok on next-article's local port:
Expand All @@ -202,7 +202,7 @@ $ ./ngrok http 3002
Run the test against the ngrok address provided (can be either http or https):

```
make smoke TEST_URL=https://05bd2344ebca.ngrok.io
n-test smoke -H https://05bd2344ebca.ngrok.io
```

*Remarks*
Expand Down
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = async () => {
return process.env.CI ? { reporters: ["default", "jest-junit"] } : {};
};
Loading

0 comments on commit c7a2d6a

Please sign in to comment.