diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..712226d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,76 @@ +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/graphql-action@v2.x + 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/get-json-paths-action@v1.x + 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' + uses: sonarsource/sonarcloud-github-action@v1.1 + with: + projectBaseDir: ${{ github.workspace }} + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ab3e4b5..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -dist: trusty - -language: node_js - -node_js: - - node - - lts/* - -addons: - sonarcloud: - organization: diplomatiq - token: - secure: OuO5PTGVrqinpQk1pj/WoivbcFglhS56Hxddzh6r2zZJ4DfTESWJhFS9b4SD7bwPoNLEDDrjMM5cdNy+S3j0pR1g46iNWDLbhBsYf4+l006QEIajjf3vt5CkkREhLtA4EMiHIgW68sHUKKoq4vdUlOQ+L0hvpScahtNUkP48uUvKJpKnGvaL/hcMzYz2TAv3/jvd8oYNAY0k0G5w3kCxwLZfJkhhSDtZEX5tEQ5ARBu9A24X9Xsza3JegrHESzLIto2XMLfJcy9m34I5OfXnVYEyiydO5bOxW00bCn7o41HNLhlx7vPD+JatYvwEHbVdDb9QOdHTHyXqAO00JbNsHyslVhTLcVFWNGvltDueY/pmjluxR40YCBJbEOz3WE4V+LsSjM71vFWj/xZRVBWGSbPVNDYL+3+4YfSSvdxFtowDFP3PEjXb9GBWWCoiSmyqZjMbkneCS7P8W1oLVJCuqDgVmWSsRSiVpS0zAhcbe+LOV4WLIUuAMrIMUpx091BBLNEA9V4O0ML080enuyrwhNH7/D626GjfTbTEntPF5h6P2gtV3/1yp8bOJXpJQkHjVP8kedFSZJBDdcwvCsc5E9WsTRrYjMs2bpk8MqwV5D54yzVwnkXtrzOjB4jPvF2oQwUIGC1kgIOIKn52IUGUnagDgO4meUPS+Y8bAcpSZiM= - -install: npm ci - -script: - - commitlint-travis - - npm run build-and-test-everything - - sonar-scanner diff --git a/README.md b/README.md index b325d1e..33432e8 100644 --- a/README.md +++ b/README.md @@ -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).

- - build status + + build status diff --git a/package.json b/package.json index 19b860b..48e7082 100644 --- a/package.json +++ b/package.json @@ -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" }, @@ -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", @@ -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": { diff --git a/sonar-project.properties b/sonar-project.properties index 0cc9f53..27220b7 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,4 +1,5 @@ # Standard properties +sonar.organization=diplomatiq sonar.projectKey=Diplomatiq_resily sonar.projectName=resily sonar.projectVersion=0.0.0