-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): use circleci for controls and releasing
- Loading branch information
1 parent
8fade9e
commit 09cfd01
Showing
10 changed files
with
3,188 additions
and
39 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,84 @@ | ||
version: 2.1 | ||
|
||
executors: | ||
node-standalone: | ||
docker: | ||
- image: circleci/node:14.16.0 | ||
|
||
jobs: | ||
deps-install: | ||
executor: node-standalone | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
keys: | ||
- yarn-cache-node14-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }} | ||
- yarn-cache-node14-{{ checksum "package.json" }} | ||
- yarn-cache-node14 | ||
- run: | ||
name: Install depdencies | ||
command: yarn install --frozen-lockfile --cache-folder ~/.cache/yarn | ||
- save_cache: | ||
key: yarn-cache-node14-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }} | ||
paths: | ||
- ~/.cache/yarn | ||
- persist_to_workspace: | ||
root: ~/project | ||
paths: | ||
- node_modules | ||
|
||
validate-project: | ||
executor: node-standalone | ||
steps: | ||
- checkout | ||
- attach_workspace: | ||
at: ~/project | ||
- run: | ||
name: Lint source code | ||
command: yarn lint --format junit -o ./junit/js-lint-results.xml | ||
- run: | ||
name: Build | ||
command: yarn build | ||
environment: | ||
NODE_ENV: production | ||
- persist_to_workspace: | ||
root: ~/project | ||
paths: | ||
- build | ||
- store_artifacts: | ||
path: ~/project/build | ||
destination: build | ||
- run: | ||
name: Lint commit messages | ||
command: node ./lint-commits.js | ||
- store_test_results: | ||
path: ~/project/junit/ | ||
|
||
release: | ||
executor: node-standalone | ||
steps: | ||
- checkout | ||
- attach_workspace: | ||
at: ~/project | ||
- run: | ||
name: semantic-release | ||
command: yarn semantic-release | ||
|
||
workflows: | ||
version: 2 | ||
|
||
main: | ||
jobs: | ||
- deps-install | ||
- validate-project: | ||
requires: | ||
- deps-install | ||
- release: | ||
context: | ||
- html2pdf-release | ||
filters: | ||
branches: | ||
only: | ||
- master | ||
requires: | ||
- validate-project |
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 @@ | ||
version: 2 | ||
|
||
updates: | ||
- package-ecosystem: "npm" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
day: "sunday" | ||
time: "22:00" |
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 |
---|---|---|
|
@@ -4,6 +4,8 @@ on: | |
push: | ||
branches: | ||
- master | ||
tags: | ||
- v* | ||
|
||
env: | ||
IMAGE_NAME: api | ||
|
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 @@ | ||
_ |
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,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn commitlint --edit $1 |
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 @@ | ||
module.exports = { | ||
extends: ['@commitlint/config-conventional'], | ||
rules: { | ||
'body-max-line-length': [2, 'always', Infinity], | ||
}, | ||
}; |
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,80 @@ | ||
const { Octokit } = require('@octokit/rest'); | ||
const execa = require('execa'); | ||
|
||
const git = async (...args) => { | ||
const { stdout } = await execa('git', args); | ||
|
||
return stdout; | ||
}; | ||
|
||
const checkCommit = async (...refs) => Promise.all(refs.map(ref => git('cat-file', '-e', ref))); | ||
|
||
const matchGithub = (url, prop) => { | ||
if (!url) { | ||
throw new Error(); | ||
} | ||
|
||
const match = url.match(new RegExp(`github\\.com/(.+)/(.+)/${prop}/(.+)`)); | ||
|
||
if (!match) { | ||
throw new Error(); | ||
} | ||
|
||
const [, owner, repo, data] = match; | ||
|
||
return { owner, repo, data }; | ||
}; | ||
|
||
const getRangeFromPr = async () => { | ||
const { owner, repo, data: pull } = matchGithub(process.env.CIRCLE_PULL_REQUEST, 'pull'); | ||
const github = new Octokit({ auth: process.env.GH_TOKEN }); | ||
|
||
console.info('📡 Looking up PR #%s...', pull); | ||
|
||
const { | ||
data: { base, head }, | ||
} = await github.pulls.get({ owner, repo, pull_number: +pull }); | ||
|
||
await checkCommit(base.sha, head.sha); | ||
console.info('🔀 Linting PR #%s', pull); | ||
|
||
return [base.sha, head.sha]; | ||
}; | ||
|
||
const getRangeFromCompare = async () => { | ||
const [from, to] = matchGithub(process.env.CIRCLE_COMPARE_URL, 'compare').data.split('...'); | ||
|
||
await checkCommit(from, to); | ||
console.info('🎏 Linting using comparison URL %s...%s', from, to); | ||
|
||
return [from, to]; | ||
}; | ||
|
||
const getRangeFromSha = async () => { | ||
const sha = process.env.CIRCLE_SHA1; | ||
|
||
if (!sha) { | ||
throw new Error('Cannot find CIRCLE_SHA1 environment variable'); | ||
} | ||
|
||
await checkCommit(sha); | ||
console.info('⚙️ Linting using CIRCLE_SHA1 (%s)', sha); | ||
|
||
return [`${sha}^1`, sha]; | ||
}; | ||
|
||
const runLint = ([from, to]) => execa('yarn', ['commitlint', '--from', from, '--to', to, '-V'], { stdio: 'inherit' }); | ||
|
||
const run = () => | ||
getRangeFromPr() | ||
.catch(getRangeFromCompare) | ||
.catch(getRangeFromSha) | ||
.then(runLint, error => { | ||
console.error(error); | ||
process.exit(1); | ||
}) | ||
.catch(() => { | ||
process.exit(1); | ||
}); | ||
|
||
run(); |
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
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,13 @@ | ||
module.exports = { | ||
branches: [ | ||
{ | ||
name: 'master', | ||
channel: false, | ||
}, | ||
], | ||
plugins: [ | ||
'@semantic-release/commit-analyzer', | ||
'@semantic-release/release-notes-generator', | ||
'@semantic-release/github', | ||
], | ||
}; |
Oops, something went wrong.