Skip to content

Commit

Permalink
Merge pull request #619 from particle-iot/feature/sc-102023/migrate-p…
Browse files Browse the repository at this point in the history
…article-cli-to-circleci

Migrate particle-cli to CircleCI
  • Loading branch information
DebbieGillespie authored May 5, 2022
2 parents aa860e6 + c01d363 commit 555debd
Show file tree
Hide file tree
Showing 20 changed files with 418 additions and 232 deletions.
186 changes: 186 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
version: 2.1

executors:
linux:
docker:
- image: cimg/base:2022.04
auth:
username: $DOCKERHUB_USERNAME
password: $DOCKERHUB_PASSWORD
macos:
macos:
xcode: 13

orbs:
node: circleci/node@5.0.2
win: circleci/windows@4.1.1

commands:
configure-npm-token:
description: "A command to configure NPM Token"
steps:
- run:
name: Configure NPM Token
command: npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN
install-node:
description: "A command to install node"
parameters:
node-version:
type: string
steps:
- checkout
- node/install:
node-version: << parameters.node-version >>
- configure-npm-token
- node/install-packages:
cache-path: node_modules
run-tests:
description: "A command to install node and run tests"
parameters:
node-version:
type: string
test-command:
type: string
steps:
- install-node:
node-version: << parameters.node-version >>
- run:
name: Run Tests
command: npm run << parameters.test-command >>

jobs:
test-unix:
parameters:
os:
type: executor
node-version:
type: string
executor: << parameters.os >>
steps:
- run-tests:
node-version: << parameters.node-version >>
test-command: test:ci
test-windows:
parameters:
node-version:
type: string
executor: win/default
steps:
- checkout
- run:
name: Install Node
command: |
nvm install --lts << parameters.node-version >>
nvm use << parameters.node-version >>
- configure-npm-token
- run:
name: Install packages
command: npm ci
- run:
name: Run Tests
command: npm run test:ci
test-e2e:
parameters:
os:
type: executor
node-version:
type: string
executor: << parameters.os >>
steps:
- run-tests:
node-version: << parameters.node-version >>
test-command: test:e2e:ci
test-coverage:
parameters:
os:
type: executor
node-version:
type: string
executor: << parameters.os >>
steps:
- install-node:
node-version: << parameters.node-version >>
- run:
name: Generate Coverage Report
command: npm run coverage
- store_artifacts:
path: coverage
# Copied from following repos
# https://github.com/particle-iot-inc/cache-aside/blob/2ee9e2d77138f1a9d22a7d604e7f8cc0d45f016e/.circleci/config.yml
# https://github.com/particle-iot-inc/app-metrics/blob/034e6dd5d77ce3b0683310c81e6f6994be2d1c80/.circleci/config.yml
# https://github.com/particle-iot-inc/device-service-discovery/blob/d1f4dbcdcab1efba7ba92794670c6e4e973e6265/.circleci/config.yml
publish-npm:
working_directory: ~/repo
docker:
- image: cimg/node:12.22 # Primary execution image
auth:
username: $DOCKERHUB_USERNAME
password: $DOCKERHUB_PASSWORD
steps:
- attach_workspace:
at: ~/repo
- configure-npm-token
- run:
name: Publish package
command: |
# Publish as beta for pre-release tags like v1.2.3-pre.1
[[ $CIRCLE_TAG =~ ^v.*- ]] && NPM_TAG=--tag=beta
npm publish $NPM_TAG
workflows:
version: 2
test-and-publish:
jobs:
- test-unix:
context:
- particle-ci-private
matrix:
parameters:
os: [linux, macos]
node-version: ["10", "12", "14", "16"]
- test-windows:
context:
- particle-ci-private
matrix:
parameters:
node-version: ["10", "12", "14", "16"]
- test-e2e:
name: test-e2e-linux
context:
- particle-ci-private
matrix:
parameters:
os: [linux]
node-version: ["12"]
- test-e2e:
name: test-e2e-macos
requires:
- test-e2e-linux
context:
- particle-ci-private
matrix:
parameters:
os: [macos]
node-version: ["12"]
- test-coverage:
context:
- particle-ci-private
matrix:
parameters:
os: [linux]
node-version: ["12"]
- publish-npm:
requires:
- test-unix
- test-windows
- test-e2e-linux
- test-e2e-macos
context:
- particle-ci-private
# publish for tags only
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/

2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
As you are working on your changes, be aware of the following:
- Development Guide: https://github.com/particle-iot/particle-cli#development
- CI (travis) Reports: https://travis-ci.org/particle-iot/particle-cli
- CI (CircleCI) Reports: https://app.circleci.com/pipelines/github/particle-iot/particle-cli
- Helpful commands:
> list available commands: `npm run`
> run the CI tests locally: `npm run test:ci`
Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ es6
.nvmrc
appveyor.yml
development.md
.circleci
45 changes: 0 additions & 45 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![npm](https://img.shields.io/npm/v/particle-cli.svg?style=flat-square)](https://www.npmjs.com/package/particle-cli)[![Build Status](https://travis-ci.org/particle-iot/particle-cli.svg?branch=master)](https://travis-ci.org/particle-iot/particle-cli)[![License](https://img.shields.io/badge/license-Apache_2.0-blue.svg?style=flat-square)](https://github.com/particle-iot/particle-cli/blob/master/LICENSE)
[![npm](https://img.shields.io/npm/v/particle-cli.svg?style=flat-square)](https://www.npmjs.com/package/particle-cli) [![Build Status](https://circleci.com/gh/particle-iot/particle-cli/tree/master.svg?style=svg)](https://circleci.com/gh/particle-iot/particle-cli/tree/master) [![License](https://img.shields.io/badge/license-Apache_2.0-blue.svg?style=flat-square)](https://github.com/particle-iot/particle-cli/blob/master/LICENSE)

Particle's full-stack Internet of Things (IoT) device platform
gives you everything you need to securely and reliably connect
Expand Down Expand Up @@ -148,7 +148,7 @@ The Particle CLI has a number of automated test suites and related commands. The

All tests use [mocha](https://mochajs.org), [chai](https://www.chaijs.com), and [sinon](https://sinonjs.org/) with coverage handled by [nyc](https://github.com/istanbuljs/nyc).

We recommend running locally if you can as it greatly shortens your feedback loop. However, CI also runs against every PR and [error reporting is publicly available](https://travis-ci.org/particle-iot/particle-cli).
We recommend running locally if you can as it greatly shortens your feedback loop. However, CI also runs against every PR and [error reporting is publicly available](https://app.circleci.com/pipelines/github/particle-iot/particle-cli).


## Updating system firmware
Expand Down
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

- This will push the commits and tag created in the previous steps.

- Travis will publish to npm when the build succeeds.
- CircleCI will publish to npm when the build succeeds.

- Create a release on GitHub with the notes from the `CHANGELOG.md`

Expand Down
Loading

0 comments on commit 555debd

Please sign in to comment.