Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to tool-kit #222

Merged
merged 2 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
293 changes: 84 additions & 209 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,220 +1,89 @@
# generator: n-circle2-cli
# template: component

references:

container_config_node: &container_config_node
working_directory: ~/project/build
docker:
- image: cimg/node:<< parameters.node-version >>
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:
- v1-dependency-npm-{{ checksum "package.json" }}-
- v1-dependency-npm-{{ checksum "package.json" }}
- v1-dependency-npm-

cache_npm_cache: &cache_npm_cache
save_cache:
key: v1-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_tags: &filters_ignore_tags
tags:
ignore: /.*/

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

orbs:
node: circleci/node@4.6.0
slack: circleci/slack@3.4.2

filters_only_renovate_nori: &filters_only_renovate_nori
branches:
only: /(^renovate-.*|^nori/.*)/

filters_ignore_tags_renovate_nori: &filters_ignore_tags_renovate_nori
tags:
ignore: /.*/
branches:
ignore: /(^renovate-.*|^nori/.*)/

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

commands:
send_nightly_build_failed_notification:
steps:
- slack/status:
fail_only: true
failure_message: Nightly Build failed. Please check the cause to avoid further issues.
include_job_number_field: false
webhook: ${TEAM_SLACK_WEBHOOK}

orbs:
tool-kit: financial-times/dotcom-tool-kit@4
executors:
node:
docker:
- image: cimg/node:18.19
node16_20:
docker:
- image: cimg/node:16.20
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
git@github.com:Financial-Times/next-ci-shared-helpers.git --branch
unpin-heroku .circleci/shared-helpers
- *restore_npm_cache
- node/install-npm:
version: "^7"
- 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-health
- 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_renovate_nori
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/.*)/
tags:
only: /^v\d+\.\d+\.\d+(-.+)?/
- 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
- node16_20
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
- node16_20
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
- node16_20
filters:
<<: *filters_version_tag
tags:
only: /^v\d+\.\d+\.\d+(-.+)?/
- tool-kit/publish-tag:
requires:
- test-v18.16

renovate-nori-build-test:
when:
not:
equal:
- scheduled_pipeline
- << pipeline.trigger_source >>
jobs:
- waiting-for-approval:
type: approval
- tool-kit/test-node
name: tool-kit/publish-tag-node
executor: node
filters:
<<: *filters_only_renovate_nori
- build:
requires:
- waiting-for-approval
name: build-v<< matrix.node-version >>
matrix:
parameters:
node-version: [ "16.20", "18.16" ]
- test:
requires:
- build-v<< matrix.node-version >>
name: test-v<< matrix.node-version >>
matrix:
parameters:
node-version: [ "16.20", "18.16" ]

tags:
only: /^v\d+\.\d+\.\d+(-.+)?/
branches:
ignore: /.*/
context: npm-publish-token
nightly:
when:
and:
Expand All @@ -225,25 +94,31 @@ workflows:
- nightly
- << pipeline.schedule.name >>
jobs:
- build:
context: next-nightly-build
post-steps:
- send_nightly_build_failed_notification
name: build-v<< matrix.node-version >>
- checkout
- tool-kit/setup:
name: tool-kit/setup-<< matrix.executor >>
requires:
- checkout
matrix:
parameters:
executor:
- node
- node16_20
- 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
- node16_20
- tool-kit/test:
name: tool-kit/test-<< matrix.executor >>
requires:
- build-v<< matrix.node-version >>
context: next-nightly-build
post-steps:
- send_nightly_build_failed_notification
name: test-v<< matrix.node-version >>
- tool-kit/build-<< matrix.executor >>
matrix:
parameters:
node-version: [ "16.20", "18.16" ]

notify:
webhooks:
- url: https://ft-next-webhooks.herokuapp.com/circleci2-workflow
executor:
- node
- node16_20
13 changes: 13 additions & 0 deletions .toolkitrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
plugins:
- "@dotcom-tool-kit/component"
- '@dotcom-tool-kit/husky-npm'
- '@dotcom-tool-kit/lint-staged-npm'
- "@dotcom-tool-kit/mocha"
hooks:
git:precommit:
- LintStaged
options:
'@dotcom-tool-kit/circleci':
nodeVersion:
- '18.19'
- '16.20'
14 changes: 0 additions & 14 deletions Makefile

This file was deleted.

Loading