-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6736d7c
Showing
129 changed files
with
7,001 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
write: true, | ||
prefix: '^', | ||
plugin: 'autod-egg', | ||
test: [ | ||
'test', | ||
'benchmark', | ||
], | ||
dep: [ | ||
'egg', | ||
'egg-scripts', | ||
], | ||
devdep: [ | ||
'egg-ci', | ||
'egg-bin', | ||
'egg-mock', | ||
'autod', | ||
'autod-egg', | ||
'eslint', | ||
'eslint-config-egg', | ||
'webstorm-disable-index', | ||
], | ||
exclude: [ | ||
'./test/fixtures', | ||
'./dist', | ||
], | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
node_modules | ||
test | ||
run | ||
docker | ||
logs | ||
.idea | ||
.npmignore | ||
.travis.yml | ||
.gitignore | ||
.git | ||
.eslintrc | ||
.eslintignore | ||
.autod.conf.js | ||
*.md | ||
*.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "eslint-config-egg", | ||
"parserOptions": { | ||
"ecmaFeatures": { | ||
"experimentalObjectRestSpread": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
logs/ | ||
npm-debug.log | ||
yarn-error.log | ||
node_modules/ | ||
package-lock.json | ||
yarn.lock | ||
coverage/ | ||
.nyc_output | ||
.idea/ | ||
.vscode/ | ||
run/ | ||
.DS_Store | ||
*.sw* | ||
*.un~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
|
||
module.exports = { | ||
config: path.join(__dirname, 'database/config.js'), | ||
'migrations-path': path.join(__dirname, 'database/migrations'), | ||
'seeders-path': path.join(__dirname, 'database/seeders'), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
sudo: false | ||
|
||
language: node_js | ||
|
||
services: | ||
- docker | ||
|
||
node_js: | ||
- '8' | ||
|
||
before_install: | ||
- docker pull macacajs/reliable-mysql | ||
- docker run --rm --name reliable-mysql -p 13306:3306 -d macacajs/reliable-mysql | ||
- docker ps -a | ||
|
||
install: | ||
- npm i npminstall && npminstall | ||
|
||
script: | ||
- MYSQL_PORT=13306 npm run ci | ||
|
||
after_script: | ||
- npminstall codecov && codecov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
FROM centos:centos7 | ||
|
||
RUN yum -y install curl \ | ||
&& mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup \ | ||
&& curl http://mirrors.163.com/.help/CentOS7-Base-163.repo -o /etc/yum.repos.d/CentOS7-Base-163.repo \ | ||
&& yum clean all \ | ||
&& yum makecache \ | ||
&& yum install -y make \ | ||
bzip2 \ | ||
gcc-c++ \ | ||
ca-certificates \ | ||
xorg-x11-server-Xvfb \ | ||
gtk2 \ | ||
vim \ | ||
git \ | ||
gtk2-devel \ | ||
libXScrnSaver \ | ||
GConf2 \ | ||
libXtst.i686 \ | ||
alsa-lib-devel \ | ||
libXScrnSaver* \ | ||
epel-release \ | ||
libappindicator-gtk3 \ | ||
libnss3.so \ | ||
glibc-common \ | ||
xorg-x11-fonts-Type1 \ | ||
wqy-microhei-fonts \ | ||
wqy-zenhei-fonts \ | ||
thai-scalable-garuda-fonts \ | ||
cjkuni-ukai-fonts \ | ||
cjkuni-uming-fonts | ||
|
||
# Variable Layer: Node.js etc. | ||
ENV NODE_VERSION=8.12.0 \ | ||
NODE_REGISTRY=https://npm.taobao.org/mirrors/node \ | ||
CHROMEDRIVER_CDNURL=http://npm.taobao.org/mirrors/chromedriver/ \ | ||
ELECTRON_MIRROR=https://npm.taobao.org/mirrors/electron/ \ | ||
DISPLAY=':99.0' \ | ||
NODE_IN_DOCKER=1 | ||
|
||
RUN curl -SLO "$NODE_REGISTRY/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz" \ | ||
&& tar -xzf "node-v$NODE_VERSION-linux-x64.tar.gz" -C /usr/local --strip-components=1 \ | ||
&& rm "node-v$NODE_VERSION-linux-x64.tar.gz" | ||
|
||
COPY . /root/reliable-web | ||
|
||
WORKDIR /root/reliable-web | ||
|
||
ENV MYSQL_HOST=mysql-host | ||
|
||
RUN npm install --production --verbose && ln -s /root/logs . | ||
|
||
HEALTHCHECK --interval=10s --retries=6 \ | ||
CMD wget -O /dev/null localhost:9900 || echo 1 | ||
|
||
ENTRYPOINT ["./entrypoint.sh"] | ||
|
||
EXPOSE 9900 | ||
|
||
CMD ["npm", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MIT LICENSE | ||
|
||
Copyright (c) 2018 Alibaba Group Holding Limited and other contributors. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Reliable | ||
|
||
[中文版](README.zh-CN.md) | ||
|
||
<p align="center"> | ||
<a href="//macacajs.github.io/reliable"> | ||
<img | ||
alt="Macaca" | ||
src="https://macacajs.github.io/reliable-logo/svg/logo-2.svg" | ||
width="200" | ||
/> | ||
</a> | ||
</p> | ||
|
||
--- | ||
|
||
[![build status][travis-image]][travis-url] | ||
[![Test coverage][codecov-image]][codecov-url] | ||
[![node version][node-image]][node-url] | ||
[![docker pull][docker-pull-image]][docker-url] | ||
[![docker layers][docker-layers-image]][docker-url] | ||
[![docker-size][docker-size-image]][docker-url] | ||
|
||
[travis-image]: https://img.shields.io/travis/macacajs/reliable/master.svg?style=flat-square&logo=travis | ||
[travis-url]: https://travis-ci.org/macacajs/reliable | ||
[codecov-image]: https://img.shields.io/codecov/c/github/macacajs/reliable/master.svg?style=flat-square | ||
[codecov-url]: https://codecov.io/gh/macacajs/reliable | ||
[node-image]: https://img.shields.io/badge/node.js-%3E=_8-green.svg?style=flat-square | ||
[node-url]: http://nodejs.org/download/ | ||
[docker-pull-image]: https://img.shields.io/docker/pulls/macacajs/reliable-web.svg?style=flat-square&logo=dockbit | ||
[docker-layers-image]: https://img.shields.io/microbadger/layers/macacajs/reliable-web.svg?style=flat-square&logo=dockbit | ||
[docker-size-image]: https://img.shields.io/microbadger/image-size/macacajs/reliable-web.svg?style=flat-square&logo=dockbit | ||
[docker-url]: https://hub.docker.com/r/macacajs/reliable-web/ | ||
|
||
> Testing management suite with continuous delivery support. | ||
## Docs | ||
|
||
- [CLI Usage](//github.com/macacajs/reliable-cli) | ||
- [Development](./docker/reliable-web#development) | ||
|
||
## License | ||
|
||
The MIT License (MIT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Reliable | ||
|
||
--- | ||
|
||
> 持续交付测试套件 | ||
## 文档 | ||
|
||
- [命令行客户端](//github.com/macacajs/reliable-cli) | ||
- [开发 Reliable](./docker/reliable-web#development) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
// key: error code | ||
// value: error details | ||
// value.message: default error message | ||
module.exports = new Map([ | ||
[ | ||
'ERR_RELIABLE_INTERNAL_SERVER_ERROR', { | ||
message: 'Internal server error.', | ||
}, | ||
], | ||
[ | ||
'ERR_RELIABLE_INVALID_PARAM_ERROR', { | ||
message: 'Invalid parameters.', | ||
}, | ||
], | ||
[ | ||
'ERR_RELIABLE_BUILD_RECORD_NOT_FOUND', { | ||
message: 'Build record not found.', | ||
}, | ||
] | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
'use strict'; | ||
|
||
const querystring = require('querystring'); | ||
const debug = require('debug')('reliable:common:dingtalkAuth'); | ||
|
||
module.exports = class DingtalkAuth { | ||
constructor({ ctx, appid, appsecret }) { | ||
this.ctx = ctx; | ||
this.appid = appid; | ||
this.appsecret = appsecret; | ||
} | ||
|
||
async getAuthData({ tmpAuthCode }) { | ||
const accessTokenInfo = await this._getAccessToken(); | ||
debug(accessTokenInfo); | ||
const persistentCodeInfo = await this._getPersistentCode({ | ||
accessToken: accessTokenInfo.access_token, | ||
tmpAuthCode, | ||
}); | ||
debug(persistentCodeInfo); | ||
const snsTokenInfo = await this._getSnsToken({ | ||
accessToken: accessTokenInfo.access_token, | ||
openid: persistentCodeInfo.openid, | ||
persistentCode: persistentCodeInfo.persistent_code, | ||
}); | ||
debug(snsTokenInfo); | ||
const userInfo = await this._getUserInfo({ | ||
snsToken: snsTokenInfo.sns_token, | ||
}); | ||
debug(userInfo); | ||
const { | ||
nick, | ||
unionid, | ||
openid, | ||
} = userInfo.user_info || {}; | ||
return { | ||
nick, | ||
unionid, | ||
openid, | ||
}; | ||
} | ||
|
||
async _getAccessToken() { | ||
const query = querystring.stringify({ | ||
appid: this.appid, | ||
appsecret: this.appsecret, | ||
}); | ||
debug(query); | ||
const requestAccessToken = await this.ctx.curl(`https://oapi.dingtalk.com/sns/gettoken?${query}`, { | ||
dataType: 'json', | ||
}); | ||
return requestAccessToken.data; | ||
} | ||
|
||
async _getPersistentCode({ accessToken, tmpAuthCode }) { | ||
const query = querystring.stringify({ | ||
access_token: accessToken, | ||
}); | ||
debug(query); | ||
const requestPersistentCode = await this.ctx.curl(`https://oapi.dingtalk.com/sns/get_persistent_code?${query}`, { | ||
method: 'POST', | ||
dataType: 'json', | ||
contentType: 'json', | ||
data: { | ||
tmp_auth_code: tmpAuthCode, | ||
}, | ||
}); | ||
return requestPersistentCode.data; | ||
} | ||
|
||
async _getSnsToken({ accessToken, openid, persistentCode }) { | ||
const query = querystring.stringify({ | ||
access_token: accessToken, | ||
}); | ||
debug(query); | ||
const requestSnsToken = await this.ctx.curl(`https://oapi.dingtalk.com/sns/get_sns_token?${query}`, { | ||
method: 'POST', | ||
dataType: 'json', | ||
contentType: 'json', | ||
data: { | ||
openid, | ||
persistent_code: persistentCode, | ||
}, | ||
}); | ||
return requestSnsToken.data; | ||
} | ||
|
||
async _getUserInfo({ snsToken }) { | ||
const query = querystring.stringify({ | ||
sns_token: snsToken, | ||
}); | ||
debug(query); | ||
const requestUserInfo = await this.ctx.curl(`https://oapi.dingtalk.com/sns/getuserinfo?${query}`, { | ||
dataType: 'json', | ||
contentType: 'json', | ||
}); | ||
return requestUserInfo.data; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
BUILD_STATE_INIT: 'INIT', | ||
BUILD_STATE_SUCCESS: 'SUCCESS', | ||
}; |
Oops, something went wrong.