Skip to content

Commit

Permalink
feat(ci): implement github actions, semantic release (#5)
Browse files Browse the repository at this point in the history
* feat(ci): implement github actions, semantic release

Also fix lint errors, upgrade deps

* fix(ci): skip code climate, sauce labs until we add tests

Signed-off-by: Patrik Kullman <[email protected]>
  • Loading branch information
Patrik Kullman authored and dotpointer committed Oct 11, 2019
1 parent 78dbe4a commit 2320ccd
Show file tree
Hide file tree
Showing 5 changed files with 9,210 additions and 943 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Github CI
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master

- name: Use Node.js 10.x
uses: actions/setup-node@v1
with:
node-version: 10.x

- name: Install
run: npm ci

- name: Lint commit messages
run: npx commitlint --from origin/master --to HEAD

- name: ESLint
run: node index.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Test and report
env:
CC_TEST_REPORTER_ID: 7b59d48d068bcdb14ae1b91f5290389a98328823eefc7f2ff657ae512b040909
GIT_BRANCH: ${{ github.ref }}
GIT_COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
NEO_CC_URL: https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
NEO_CC: ./cc-test-reporter
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
run: |
# ([[ -e $NEO_CC ]] || curl -L $NEO_CC_URL > $NEO_CC) && chmod +x $NEO_CC
# $NEO_CC before-build
# npm run test $([ -z "$SAUCE_ACCESS_KEY"] && echo "-- --skip-plugin sauce")
# $NEO_CC after-build --exit-code $?
npm test
- name: Semantic release
run: npx semantic-release
if: success()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
.eslintcache
52 changes: 26 additions & 26 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,45 +86,45 @@ const headers = {
return data.id;
},
getChangedFiles = async targetBranch => {
const util = require("util");
const exec = util.promisify(require("child_process").exec);
const { stdout, stderr } = await exec(
`git diff origin/${targetBranch}... --name-only --diff-filter=d`
);
return stdout.trim().split("\n");
},
eslint = async () => {
const util = require('util'),
exec = util.promisify(require('child_process').exec),
{ stdout } = await exec(
`git diff origin/${targetBranch}... --name-only --diff-filter=d`
);
return stdout.trim().split('\n');
},
eslint = async () => {
const partialLinting = process.env.PARTIAL_LINTING; //false
let files = ['.'];
if (partialLinting && event.pull_request) {
const branch = event.pull_request.base.ref;
files = await getChangedFiles(branch);
};
}
const eslint = require('eslint'),
cli = new eslint.CLIEngine(),
report = cli.executeOnFiles(files),
// fixableErrorCount, fixableWarningCount are available too
levels = ['notice', 'warning', 'failure'];

const annotations = report.results.reduce((annoList, result) => {
const path = result.filePath.substring(GITHUB_WORKSPACE.length + 1);
return annoList.concat(result.messages.map(m => {
const singleLine = m.line === m.endLine;
return {
path,
start_column: singleLine && m.column,
end_column: singleLine && m.endColumn,
start_line: m.line,
end_line: m.endLine,
annotation_level: levels[m.severity],
// title: `${ path }#L${ m.line }`,
// raw_details: 'Nothing much',
message: `${ m.ruleId }: ${ m.message }`
};
}));
}, []);
const path = result.filePath.substring(GITHUB_WORKSPACE.length + 1);
return annoList.concat(result.messages.map(m => {
const singleLine = m.line === m.endLine;
return {
path,
start_column: singleLine && m.column,
end_column: singleLine && m.endColumn,
start_line: m.line,
end_line: m.endLine,
annotation_level: levels[m.severity],
// title: `${ path }#L${ m.line }`,
// raw_details: 'Nothing much',
message: `${ m.ruleId }: ${ m.message }`
};
}));
}, []),

const { errorCount, warningCount } = report;
{ errorCount, warningCount } = report;

return {
conclusion: errorCount > 0 ? 'failure' : 'success',
Expand Down
Loading

0 comments on commit 2320ccd

Please sign in to comment.