Skip to content

Commit cc9b857

Browse files
authored
add ci (#16)
1 parent 2afcf79 commit cc9b857

File tree

5 files changed

+1811
-2333
lines changed

5 files changed

+1811
-2333
lines changed

.github/workflows/ci.yml

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
release:
8+
types: [ published ]
9+
pull_request:
10+
branches:
11+
- '**'
12+
13+
env:
14+
PRIMARY_NODE_VERSION: 16.x
15+
PRIMARY_OS: ubuntu-latest
16+
REGISTRY: https://registry.npmjs.org/
17+
18+
jobs:
19+
test:
20+
name: CI
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
matrix:
24+
os: [ ubuntu-latest ]
25+
node-version: [ 6.x, 8.x, 10.x, 12.x, 14.x, 16.x, 18.x ]
26+
27+
steps:
28+
29+
- name: Echo env variables
30+
run: |
31+
echo ref: ${{ github.event.client_payload.ref || github.ref }}
32+
echo sha: ${{ github.event.client_payload.sha || github.sha }}
33+
echo head ref: ${{ github.event.client_payload.head_ref || github.head_ref }}
34+
echo base ref: ${{ github.event.client_payload.base_ref || github.base_ref }}
35+
echo action: ${{ github.action }}
36+
echo event: ${{ github.event_name }}
37+
38+
- uses: actions/checkout@v2
39+
name: Checkout
40+
with:
41+
ref: ${{ github.event.client_payload.ref || github.ref }}
42+
43+
- name: Use Node.js ${{ matrix.node-version }}
44+
uses: actions/setup-node@v2
45+
with:
46+
node-version: ${{ matrix.node-version }}
47+
48+
- name: Get yarn cache directory
49+
id: yarn-cache-dir
50+
run: |
51+
echo "::set-output name=dir::$(yarn cache dir)"
52+
53+
- uses: actions/cache@v2
54+
id: yarn-cache
55+
with:
56+
path: ${{ steps.yarn-cache-dir.outputs.dir }}
57+
key: ${{ matrix.os }}-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}
58+
restore-keys: |
59+
${{ matrix.os }}-${{ matrix.node-version }}-yarn-
60+
61+
- name: Install dependencies and build
62+
run: |
63+
yarn install
64+
yarn build
65+
66+
- name: Snyk security check
67+
if: matrix.node-version == env.PRIMARY_NODE_VERSION && matrix.os == env.PRIMARY_OS
68+
uses: snyk/actions/node@master
69+
env:
70+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
71+
72+
- name: Run unit tests with coverage
73+
if: matrix.node-version == env.PRIMARY_NODE_VERSION && matrix.os == env.PRIMARY_OS
74+
uses: paambaati/codeclimate-action@v2.7.5
75+
env:
76+
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
77+
with:
78+
coverageCommand: yarn test:cover
79+
80+
- name: Run unit tests
81+
if: "!(matrix.node-version == env.PRIMARY_NODE_VERSION && matrix.os == env.PRIMARY_OS)"
82+
run: yarn test:unit
83+
84+
publish_version:
85+
name: Publish
86+
runs-on: ${{ matrix.os }}
87+
strategy:
88+
matrix:
89+
os: [ ubuntu-latest ]
90+
node-version: [ 6.x ]
91+
needs: [ test ]
92+
if: github.event_name == 'release' && github.event.action == 'published'
93+
steps:
94+
95+
- name: Checkout
96+
uses: actions/checkout@v2
97+
98+
- name: fetch
99+
run: |
100+
git fetch --prune --unshallow
101+
102+
- name: Use Node.js ${{ matrix.node-version }}
103+
uses: actions/setup-node@v2
104+
with:
105+
node-version: ${{ matrix.node-version }}
106+
registry-url: ${{ env.REGISTRY }}
107+
108+
- name: Get yarn cache directory
109+
id: yarn-cache-dir
110+
run: |
111+
echo "::set-output name=dir::$(yarn cache dir)"
112+
113+
- uses: actions/cache@v2
114+
id: yarn-cache
115+
with:
116+
path: ${{ steps.yarn-cache-dir.outputs.dir }}
117+
key: ${{ matrix.os }}-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}
118+
restore-keys: |
119+
${{ matrix.os }}-${{ matrix.node-version }}-yarn-
120+
121+
- name: Install dependencies and build
122+
run: |
123+
yarn install
124+
yarn build
125+
126+
- name: Publish
127+
uses: JS-DevTools/npm-publish@v1
128+
with:
129+
token: ${{ secrets.NPM_AUTH_TOKEN }}
130+
registry: ${{ env.REGISTRY }}

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
[![Npm Version](https://img.shields.io/npm/v/price-extractor.svg?style=popout)](https://www.npmjs.com/package/price-extractor)
2-
![node](https://img.shields.io/node/v-lts/price-extractor)
3-
[![Build Status](https://travis-ci.org/PruvoNet/price-extractor.svg?branch=master)](https://travis-ci.org/PruvoNet/price-extractor)
2+
[![node](https://img.shields.io/node/v-lts/price-extractor)](https://www.npmjs.com/package/price-extractor)
3+
[![Build status](https://github.com/PruvoNet/price-extractor/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/PruvoNet/price-extractor/actions/workflows/ci.yml)
44
[![Test Coverage](https://api.codeclimate.com/v1/badges/83a4b9446725afb8f6ef/test_coverage)](https://codeclimate.com/github/PruvoNet/price-extractor/test_coverage)
55
[![Maintainability](https://api.codeclimate.com/v1/badges/83a4b9446725afb8f6ef/maintainability)](https://codeclimate.com/github/PruvoNet/price-extractor/maintainability)
66
[![Known Vulnerabilities](https://snyk.io/test/github/PruvoNet/price-extractor/badge.svg?targetFile=package.json)](https://snyk.io/test/github/PruvoNet/price-extractor?targetFile=package.json)
7-
[![dependencies Status](https://david-dm.org/PruvoNet/price-extractor/status.svg)](https://david-dm.org/PruvoNet/price-extractor)
8-
[![devDependencies Status](https://david-dm.org/PruvoNet/price-extractor/dev-status.svg)](https://david-dm.org/PruvoNet/price-extractor?type=dev)
97

108
# price-extractor
119

0 commit comments

Comments
 (0)