Skip to content

Commit

Permalink
chore: support github action (#206)
Browse files Browse the repository at this point in the history
* test: lerna run test

* feat(action): test workflow

* feat: github action publish

* feat(actions): add feflowbot account

* feat: on tag push

* feat(lerna): add lerna build workflow

* feat(lerna): lerna run build

Co-authored-by: bethonxyfu <bethonxyfu@tencent.com>
  • Loading branch information
fXy-during and bethonxyfu committed Apr 9, 2020
1 parent 1a16c7f commit 2e1fdd9
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 46 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/publish.yml
@@ -0,0 +1,46 @@
name: Publish with Lerna

on:
push:
tags:
- "*"

jobs:
Publish_Workflow:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v1.0.0
- name: Git Identity
run: |
git config --global user.name 'feflowbot'
git config --global user.email 'feflowbot@gmail.com'
git remote set-url origin https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare repository
run: git checkout "${GITHUB_REF:11}"
- name: Pulling
run: git pull
- name: Install dependencies
run: npm i
- name: Authenticate with Registry
run: |
yarn logout
echo "Tencent/feflow:registry=http://registry.npmjs.org/" > .npmrc
echo "registry=http://registry.npmjs.org/" >> .npmrc
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
npm whoami
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Lerna bootstrap
run: npx lerna bootstrap
- name: Lerna build
run: npx lerna run build
- name: Publish with Lerna
run: npx lerna publish --yes --message 'chore(release)' --cd-version=patch
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,34 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Test

on:
push:
branches:
- master
- release
- feat_*
tags:
- "*"

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install lerna -g
- run: lerna bootstrap
- run: lerna run test
env:
CI: true
10 changes: 4 additions & 6 deletions packages/feflow-cli/__tests__/core/commander/index.test.ts
@@ -1,20 +1,18 @@
import chai from 'chai';
import Commander from '../../../src/core/commander';
const should = chai.should();
const expect = chai.expect;

describe('@feflow/core - Commander Unit Test', () => {

it('register(name, desc, fn) - Register a command', () => {
const command = new Commander();
command.register('test', 'test description', () => {});
command.get('test').should.exist;
expect(command.get('test')).to.not.an('undefined');
});

it('get(name) - Get a command', () => {
const command = new Commander();
command.register('test', 'test description', () => {});
command.get('test').should.exist;
expect(command.get('test')).to.not.an('undefined');
});

it('get(name) - Get a command not a string', () => {
Expand All @@ -26,6 +24,6 @@ describe('@feflow/core - Commander Unit Test', () => {
it('list() - List all command', () => {
const command = new Commander();
command.register('test', 'test description', () => {});
command.list().should.have.keys(['test']);
expect(command.list()).to.haveOwnProperty('test');
});
});
});
2 changes: 0 additions & 2 deletions packages/feflow-cli/__tests__/core/logger/index.test.ts
@@ -1,6 +1,4 @@
import chai from 'chai';
import logger from '../../../src/core/logger';
const should = chai.should();

const captureStream = (stream: any) => {
const oldWrite = stream.write;
Expand Down
52 changes: 15 additions & 37 deletions packages/feflow-cli/__tests__/core/plugin/compose.test.ts
@@ -1,63 +1,41 @@
import chai from 'chai';
import compose from '../../../src/core/plugin/compose';
const should = chai.should();
import chai from 'chai';
const expect = chai.expect;

describe('@feflow/core - Plugin compose', () => {
it('Composes from right to left', () => {
const double = (x: number) => x * 2;
const square = (x: number) => x * x;

compose(square)(5).should.eql(25);
expect(compose(square)(5)).to.be.eql(25);

compose(
square,
double
)(5).should.eql(100);
expect(compose(square, double)(5)).to.eql(100);

compose(
double,
square,
double
)(5).should.eql(200);
expect(compose(double, square, double)(5)).to.be.eql(200);
});

it('Composes functions from right to left', () => {
const a = (next: any) => (x: string) => next(x + 'a');
const b = (next: any) => (x: string) => next(x + 'b');
const c = (next: any) => (x: string) => next(x + 'c');
const final = (x: any) => x;
compose(
a,
b,
c
)(final)('').should.eql('abc');

compose(
b,
c,
a
)(final)('').should.eql('bca');

compose(
c,
a,
b
)(final)('').should.eql('cab');
expect(compose(a, b, c)(final)('')).to.be.eql('abc');

expect(compose(b, c, a)(final)('')).to.be.eql('bca');

expect(compose(c, a, b)(final)('')).to.be.eql('cab');
});

it('Can be seeded with multiple arguments', () => {
const square = (x: number) => x * x
const add = (x: number, y: number) => x + y
const square = (x: number) => x * x;
const add = (x: number, y: number) => x + y;

compose(
square,
add
)(1, 2).should.eql(9);
expect(compose(square, add)(1, 2)).to.be.eql(9);
});

it('Returns the first function if given only one', () => {
const fn = () => {};

compose(fn).should.eql(fn);
expect(compose(fn)).to.be.eql(fn);
});
});
});
1 change: 0 additions & 1 deletion packages/feflow-plugin-devtool/package.json
Expand Up @@ -19,7 +19,6 @@
"scripts": {
"start": "npm run build:live",
"build": "rm -rf lib && tsc",
"test": "nyc mocha -r ts-node/register __tests__/**/*.test.ts",
"build:live": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0"
},
Expand Down

0 comments on commit 2e1fdd9

Please sign in to comment.