Skip to content

Commit df395d9

Browse files
committed
chore: add sonar
1 parent 07a2acf commit df395d9

File tree

8 files changed

+463
-12125
lines changed

8 files changed

+463
-12125
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
tags:
88
- '*'
99
pull_request:
10-
10+
types: [opened, synchronize, reopened]
1111

1212
jobs:
1313
build:
@@ -17,7 +17,16 @@ jobs:
1717
node-version: ["10", "12", "14"]
1818
steps:
1919
- uses: actions/checkout@v2
20+
with:
21+
fetch-depth: 0
2022

23+
- name: Get info
24+
id: info
25+
run: |
26+
echo ::set-output name=version::${GITHUB_REF/refs\/tags\//}
27+
echo ::set-output name=repo_name::$(echo $GITHUB_REPOSITORY| cut -d / -f 2)
28+
echo ::set-output name=repo_owner::$(echo $GITHUB_REPOSITORY| cut -d / -f 1)
29+
2130
- uses: actions/setup-node@v2
2231
with:
2332
node-version: ${{ matrix.node-version }}
@@ -34,17 +43,22 @@ jobs:
3443
- name: Build and package
3544
run: yarn run build
3645

46+
- name: SonarCloud Scan
47+
if: matrix.node-version == 14
48+
uses: sonarsource/sonarcloud-github-action@master
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
52+
with:
53+
args: >
54+
-Dsonar.organization=${{ steps.info.outputs.repo_owner }}
55+
-Dsonar.projectKey=${{ steps.info.outputs.repo_name }}
3756
38-
- name: Get the version
39-
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.node-version == 14 }}
40-
id: get_version
41-
run: echo ::set-output name=version::${GITHUB_REF/refs\/tags\//}
42-
4357
- name: Publish
4458
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.node-version == 14 }}
4559
env:
4660
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
47-
VERSION: ${{ steps.get_version.outputs.version }}
61+
VERSION: ${{ steps.info.outputs.version }}
4862
run: |
4963
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
5064
yarn version --new-version ${VERSION} --no-git-tag-version

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pids
2323
lib-cov
2424

2525
# Coverage directory used by tools like istanbul
26-
coverage
26+
coverage**
2727
*.lcov
2828

2929
# nyc test coverage
@@ -96,3 +96,4 @@ Thumbs.db
9696

9797
.npmrc
9898
lib
99+
.scannerwork/

__tests__/linebreak.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import * as lb from "../src/linebreak";
22

33
describe("Verify line break utils.", () => {
44
test("Test line break string to type conversion.", () => {
5-
expect(lb.getLineBreakType("CR")).toEqual("CR");
65
expect(lb.getLineBreakType("CRLF")).toEqual("CRLF");
76
expect(lb.getLineBreakType("LF")).toEqual("LF");
7+
expect(lb.getLineBreakType("CR")).toEqual("CR");
88
expect(lb.getLineBreakType("unknown")).toEqual("LF");
99
});
1010

jest.config.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
module.exports = {
2+
collectCoverage: true,
23
clearMocks: true,
34
moduleFileExtensions: ['js', 'ts'],
45
testEnvironment: 'node',
5-
testMatch: ['**/*.test.ts'],
6-
testRunner: 'jest-circus/runner',
76
transform: {
87
'^.+\\.ts$': 'ts-jest'
98
},
@@ -16,4 +15,4 @@ module.exports = {
1615
"statements": -10
1716
}
1817
}
19-
}
18+
}

0 commit comments

Comments
 (0)