Skip to content

Commit

Permalink
ci: Configure GitHub Actions
Browse files Browse the repository at this point in the history
Closes #202.
  • Loading branch information
luczsoma committed Mar 29, 2020
1 parent e022a12 commit 57de3b4
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 30 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: CI

on: [push, pull_request]

jobs:
lint-build-test-scan:
name: Lint, build, test, scan
runs-on: ubuntu-latest

strategy:
matrix:
node: [13, 12, 11, 10]
fail-fast: false

steps:
- name: Checkout push or pull request HEAD
uses: actions/checkout@v2
- name: Convert the shallow clone to an unshallow one
run: git fetch --unshallow
- name: Request the number of commits on the pull request
id: number_of_commits_on_pr_request
if: github.event_name == 'pull_request'
uses: octokit/[email protected]
with:
query: |
query NumberOfCommitsOnPR($repositoryowner: String!, $repositoryname: String!, $prnumber: Int!) {
repository(owner: $repositoryowner, name: $repositoryname) {
pullRequest(number: $prnumber) {
commits {
totalCount
}
}
}
}
repositoryowner: ${{ github.event.repository.owner.login }}
repositoryname: ${{ github.event.repository.name }}
prnumber: ${{ github.event.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get the number of commits on the pull request from the response
id: number_of_commits_on_pr_result
if: github.event_name == 'pull_request'
uses: gr2m/[email protected]
with:
json: ${{ steps.number_of_commits_on_pr_request.outputs.data }}
commits_count: 'repository.pullRequest.commits.totalCount'
- name: Check if the number of commits on the pull request is equal to one
if: github.event_name == 'pull_request'
run: |
if [ "${{ steps.number_of_commits_on_pr_result.outputs.commits_count }}" -ne 1 ]; then
echo "The pull request must consist of exactly one commit. Please squash your commits into one."
exit 1
fi
- name: Set up Node.js version
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
run: npm ci
- name: Lint the commit message of the pull request
if: github.event_name == 'pull_request'
run: npx commitlint --from HEAD^ --to HEAD --config .commitlintrc.json
- name: Lint the code
run: npm run lint
- name: Build the code
run: npm run build
- name: Test the code
run: npm run test
- name: Scan the code with SonarCloud
if: github.event_name == 'push' && matrix.node == 13
uses: sonarsource/[email protected]
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# resily

Resily is a TypeScript resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback. Inspired by [App-vNext/Polly](https://github.com/App-vNext/Polly).
Resily is a TypeScript resilience and transient-fault-handling library that allows developers to express policies such as Retry, Fallback, Circuit Breaker, Timeout, Bulkhead Isolation, and Cache. Inspired by [App-vNext/Polly](https://github.com/App-vNext/Polly).

<p>
<a href="https://travis-ci.org/Diplomatiq/resily" target="_blank" style="text-decoration: none;">
<img src="https://img.shields.io/travis/Diplomatiq/resily.svg" alt="build status">
<a href="https://github.com/Diplomatiq/resily/actions?query=workflow%3ACI" target="_blank" style="text-decoration: none;">
<img src="https://github.com/Diplomatiq/resily/workflows/CI/badge.svg" alt="build status">
</a>

<a href="https://github.com/Diplomatiq/resily" target="_blank" style="text-decoration: none;">
Expand Down
11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
{
"name": "@diplomatiq/resily",
"version": "0.0.0",
"description": "Resily is a TypeScript resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback. Inspired by App-vNext/Polly.",
"description": "Resily is a TypeScript resilience and transient-fault-handling library that allows developers to express policies such as Retry, Fallback, Circuit Breaker, Timeout, Bulkhead Isolation, and Cache. Inspired by App-vNext/Polly.",
"main": "dist/main.js",
"module": "dist/main.js",
"types": "dist/main.d.ts",
"engines": {
"node": ">=9.0.0"
"node": ">=10.0.0"
},
"scripts": {
"build": "tsc",
"build-and-test-everything": "npm run lint && npm run build && npm run test",
"check-release-tag": "node --experimental-modules scripts/check-release-tag.mjs",
"clean": "rm -r ./dist/",
"lint": "eslint ./src/ ./test/ --ext .ts",
"prepare": "npm run build-and-test-everything",
"prepublishOnly": "npm run check-release-tag",
"prepublishOnly": "npm run check-release-tag && npm run lint && npm run build && npm run test",
"test": "cross-env-shell TS_NODE_PROJECT=tsconfig.test.json nyc --reporter=lcov --reporter=text mocha --require ts-node/register --require source-map-support/register --require esm --recursive test/specs/**/*.test.ts",
"version": "node --experimental-modules scripts/sync-sonar-version.mjs && conventional-changelog -p angular -i CHANGELOG.md -s && git add sonar-project.properties CHANGELOG.md"
},
Expand All @@ -40,7 +38,6 @@
"homepage": "https://github.com/Diplomatiq/resily#readme",
"devDependencies": {
"@commitlint/cli": "^8.3.5",
"@commitlint/travis-cli": "^8.3.5",
"@diplomatiq/eslint-config-tslib": "^3.0.0",
"@types/chai": "^4.2.11",
"@types/mocha": "^7.0.2",
Expand All @@ -65,7 +62,7 @@
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-push": "npm run build-and-test-everything"
"pre-push": "npm run lint && npm run build && npm run test"
}
},
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Standard properties
sonar.organization=diplomatiq
sonar.projectKey=Diplomatiq_resily
sonar.projectName=resily
sonar.projectVersion=0.0.0
Expand Down

0 comments on commit 57de3b4

Please sign in to comment.