Skip to content

Commit

Permalink
Switch to GitHub Actions and CodeCov
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Nov 29, 2020
1 parent 09e64cb commit b633fda
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 10 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: CI
on: [push, pull_request]
jobs:
lint:
name: Lint source files
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v1

- name: Cache Node.js modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
- name: Install Dependencies
run: npm ci

- name: Lint ESLint
run: npm run lint

- name: Lint Prettier
run: npm run prettier:check

coverage:
name: Measure test coverage
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v1

- name: Cache Node.js modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
- name: Install Dependencies
run: npm ci

- name: Run tests and measure code coverage
run: npm run testonly:cover

- name: Upload coverage to Codecov
if: ${{ always() }}
uses: codecov/codecov-action@v1
with:
file: ./coverage/coverage-final.json
fail_ci_if_error: true

test:
name: Run tests on Node v${{ matrix.node_version_to_setup }}
runs-on: ubuntu-latest
strategy:
matrix:
node_version_to_setup: [10, 12, 14, 15]
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Setup Node.js v${{ matrix.node_version_to_setup }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node_version_to_setup }}

- name: Cache Node.js modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
- name: Install Dependencies
run: npm ci

- name: Run Tests
run: npm run testonly
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Swagger Converter

[![NPM version][npm-image]][npm-link]
[![Build status][travis-image]][travis-link]
[![Coverage Status][coveralls-image]][coveralls-link]
[![Build status][actions-image]][actions-link]
[![Coverage Status][codecov-image]][codecov-link]
[![Dependency status][deps-image]][deps-link]
[![devDependency status][devdeps-image]][devdeps-link]

Expand Down Expand Up @@ -99,10 +99,10 @@ MIT. See [LICENSE](./LICENSE)

[npm-image]: https://img.shields.io/npm/v/swagger-converter.svg?style=flat
[npm-link]: https://npmjs.org/package/swagger-converter
[travis-image]: https://img.shields.io/travis/apigee-127/swagger-converter.svg?style=flat
[travis-link]: https://travis-ci.org/apigee-127/swagger-converter
[coveralls-image]: https://coveralls.io/repos/apigee-127/swagger-converter/badge.svg?branch=master&service=github
[coveralls-link]: https://coveralls.io/github/apigee-127/swagger-converter?branch=master
[actions-image]: https://github.com/apigee-127/swagger-converter/workflows/CI/badge.svg?branch=master
[actions-link]: https://github.com/apigee-127/swagger-converter/actions?query=branch%3Amaster
[codecov-image]: https://codecov.io/gh/apigee-127/swagger-converter/branch/master/graph/badge.svg
[codecov-link]: https://codecov.io/gh/apigee-127/swagger-converter
[deps-image]: https://img.shields.io/david/apigee-127/swagger-converter.svg?style=flat
[deps-link]: https://david-dm.org/apigee-127/swagger-converter
[devdeps-image]: https://img.shields.io/david/dev/apigee-127/swagger-converter.svg?style=flat
Expand Down
14 changes: 14 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
codecov:
notify:
require_ci_to_pass: yes

parsers:
javascript:
enable_partials: yes

comment: no
coverage:
status:
project:
default:
target: auto
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"description": "Converts Swagger documents from version 1.x to version 2.0",
"main": "index.js",
"scripts": {
"test": "npm run lint && npm run testonly && npm run prettier:check",
"test": "npm run lint && npm run testonly:cover && npm run prettier:check",
"lint": "eslint .",
"testonly": "nyc mocha",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"testonly": "mocha",
"testonly:cover": "nyc npm run testonly",
"prettier": "prettier --ignore-path .gitignore --write --list-different .",
"prettier:check": "prettier --ignore-path .gitignore --check ."
},
Expand All @@ -30,7 +30,6 @@
"homepage": "https://github.com/apigee-127/swagger-converter",
"devDependencies": {
"chai": "^4.1.2",
"coveralls": "^3.0.1",
"eslint": "^7.14.0",
"mocha": "^5.1.1",
"nyc": "^15.1.0",
Expand Down

0 comments on commit b633fda

Please sign in to comment.