Skip to content

Commit

Permalink
feat: add ci-cd on push: test, lint, license-check
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduard Lavuš committed Jun 22, 2020
1 parent 2de6652 commit d12332c
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 2 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: CI
on:
- push

jobs:
test:
runs-on: ubuntu-latest
steps:
# Setup environment and checkout the project master
- name: Setup Node.js environment
uses: actions/[email protected]
- name: Checkout
uses: actions/checkout@v2

# Setup yarn cache
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# Install and run tests
- name: Install dependencies
run: yarn install
- name: Test
run: yarn test

lint:
runs-on: ubuntu-latest
steps:
# Setup environment and checkout the project master
- name: Setup Node.js environment
uses: actions/[email protected]
- name: Checkout
uses: actions/checkout@v2

# Setup yarn cache
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# Install and run lint
- name: Install dependencies
run: yarn install
- name: Lint
run: yarn lint

lincense-check:
runs-on: ubuntu-latest
steps:
# Setup environment and checkout the project master
- name: Setup Node.js environment
uses: actions/[email protected]
- name: Checkout
uses: actions/checkout@v2

# Setup yarn cache
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# Install and run license checker
- name: Install dependencies
run: yarn install
- name: Install License checker
run: |
yarn global add license-checker
echo "::add-path::$(yarn global bin)"
- name: Check licenses
run: "license-checker --onlyAllow '0BDS;MIT;Apache-2.0;ISC;BSD-3-Clause;BSD-2-Clause;CC-BY-4.0;CC-BY-3.0;BSD;CC0-1.0;Unlicense;UNLICENSED' --summary"
41 changes: 41 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Publish
on:
release:
types: [created]

jobs:
publish:
runs-on: ubuntu-latest
steps:
# Checkout project master and setup environment
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js environment
uses: actions/[email protected]
with:
registry-url: "https://npm.pkg.github.com"
# Defaults to the user or organization that owns the workflow file
scope: "@superindustries"

# Install dependencies and run test
- name: Install dependencies
run: yarn install
- name: Test
run: yarn test

# Build the project
- name: Build
run: yarn build

# Prepare and publish
- name: Publish Git preparation
run: |
echo Publishing as version ${GITHUB_REF##*/v}
# This is to appease the GIT gods. Yarn cannot publish without a version bump (that would invoke git with empty credentials)
git config --global user.email "[email protected]"
git config --global user.name "Foo Bar"
git tag -d ${GITHUB_REF##*/}
- name: Publish
run: yarn publish --new-version ${GITHUB_REF##*/v} --verbose
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "superface",
"version": "0.0.0",
"name": "@superindustries/superface",
"version": "0.0.1",
"description": "Level 5 autonomous, self-driving API client, https://superface.ai",
"main": "dist/superface.js",
"source": "src/index.ts",
Expand All @@ -12,6 +12,12 @@
"author": "Superface Team",
"license": "MIT",
"private": false,
"files": [
"dist/**/*"
],
"publishConfig": {
"registry": "https://npm.pkg.github.com/"
},
"scripts": {
"build": "microbundle --tsconfig tsconfig.release.json",
"watch": "yarn build --watch",
Expand Down

0 comments on commit d12332c

Please sign in to comment.