Skip to content

Commit

Permalink
chore: add sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
npalm committed Mar 7, 2021
1 parent 07a2acf commit df395d9
Show file tree
Hide file tree
Showing 8 changed files with 463 additions and 12,125 deletions.
28 changes: 21 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
tags:
- '*'
pull_request:

types: [opened, synchronize, reopened]

jobs:
build:
Expand All @@ -17,7 +17,16 @@ jobs:
node-version: ["10", "12", "14"]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Get info
id: info
run: |
echo ::set-output name=version::${GITHUB_REF/refs\/tags\//}
echo ::set-output name=repo_name::$(echo $GITHUB_REPOSITORY| cut -d / -f 2)
echo ::set-output name=repo_owner::$(echo $GITHUB_REPOSITORY| cut -d / -f 1)
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
Expand All @@ -34,17 +43,22 @@ jobs:
- name: Build and package
run: yarn run build

- name: SonarCloud Scan
if: matrix.node-version == 14
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.organization=${{ steps.info.outputs.repo_owner }}
-Dsonar.projectKey=${{ steps.info.outputs.repo_name }}
- name: Get the version
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.node-version == 14 }}
id: get_version
run: echo ::set-output name=version::${GITHUB_REF/refs\/tags\//}

- name: Publish
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.node-version == 14 }}
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
VERSION: ${{ steps.get_version.outputs.version }}
VERSION: ${{ steps.info.outputs.version }}
run: |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
yarn version --new-version ${VERSION} --no-git-tag-version
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pids
lib-cov

# Coverage directory used by tools like istanbul
coverage
coverage**
*.lcov

# nyc test coverage
Expand Down Expand Up @@ -96,3 +96,4 @@ Thumbs.db

.npmrc
lib
.scannerwork/
2 changes: 1 addition & 1 deletion __tests__/linebreak.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import * as lb from "../src/linebreak";

describe("Verify line break utils.", () => {
test("Test line break string to type conversion.", () => {
expect(lb.getLineBreakType("CR")).toEqual("CR");
expect(lb.getLineBreakType("CRLF")).toEqual("CRLF");
expect(lb.getLineBreakType("LF")).toEqual("LF");
expect(lb.getLineBreakType("CR")).toEqual("CR");
expect(lb.getLineBreakType("unknown")).toEqual("LF");
});

Expand Down
5 changes: 2 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
module.exports = {
collectCoverage: true,
clearMocks: true,
moduleFileExtensions: ['js', 'ts'],
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
testRunner: 'jest-circus/runner',
transform: {
'^.+\\.ts$': 'ts-jest'
},
Expand All @@ -16,4 +15,4 @@ module.exports = {
"statements": -10
}
}
}
}
Loading

0 comments on commit df395d9

Please sign in to comment.