diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 591fc722..ad142721 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,14 +16,14 @@ jobs: strategy: matrix: - node: [12, 14, 16] + node: [20] steps: - name: Check out repo uses: actions/checkout@v4.0.0 - name: Install Node - uses: actions/setup-node@v3.8.1 + uses: actions/setup-node@v4.0.2 with: node-version: ${{ matrix.node }} diff --git a/README.md b/README.md index 56065763..abb2b2e0 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,10 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-dotnet@v1 with: - dotnet-version: 3.1.101 + dotnet-version: 7.0.x - uses: xt0rted/dotnet-format-problem-matcher@v1 - run: dotnet tool install -g dotnet-format - - run: dotnet-format --dry-run + - run: dotnet format --no-restore --verify-no-changes ``` ![Example of inline annotations](docs/annotations.png) @@ -36,3 +36,4 @@ Name | Allowed values | Description ## License The scripts and documentation in this project are released under the [MIT License](LICENSE) + \ No newline at end of file diff --git a/__tests__/problemMatcher.test.ts b/__tests__/problemMatcher.test.ts index c8600312..ddcb7612 100644 --- a/__tests__/problemMatcher.test.ts +++ b/__tests__/problemMatcher.test.ts @@ -15,11 +15,9 @@ describe("problemMatcher", () => { describe("pattern", () => { const reportOutput = [ - " Formatting code files in workspace 'C:\\dev\\application\\application.sln'.", - " src\\ConsoleApp\\Program.cs(5,18): Fix whitespace formatting 1.", - " src\\ConsoleApp\\Program.cs(8,30): Fix whitespace formatting 2.", - " Formatted code file 'Program.cs'.", - " Format complete in 4451ms.", + "/path/file.cs(15,2): error WHITESPACE: Fix whitespace formatting. Insert '\t'. [/path/project.csproj]", + "/path/file.cs(15,3): error WHITESPACE: Fix whitespace formatting. Replace 4 characters with '\n\t\t\t'. [/path/project.csproj]", + "/path/file.cs(16,84): error WHITESPACE: Fix whitespace formatting. Replace 4 characters with '\n\t\t\t'. [/path/project.csproj]", ]; let pattern: ProblemPattern; @@ -34,19 +32,26 @@ describe("problemMatcher", () => { }); it("matches violations", () => { - expect(results.length).toEqual(2); + expect(results.length).toEqual(3); }); it("matches violation details", () => { - expect(results[0][pattern.file]).toEqual("src\\ConsoleApp\\Program.cs"); - expect(results[0][pattern.line]).toEqual("5"); - expect(results[0][pattern.column]).toEqual("18"); - expect(results[0][pattern.message]).toEqual("Fix whitespace formatting 1."); - - expect(results[1][pattern.file]).toEqual("src\\ConsoleApp\\Program.cs"); - expect(results[1][pattern.line]).toEqual("8"); - expect(results[1][pattern.column]).toEqual("30"); - expect(results[1][pattern.message]).toEqual("Fix whitespace formatting 2."); + expect(results[0][pattern.file]).toEqual("/path/file.cs"); + expect(results[0][pattern.line]).toEqual("15"); + expect(results[0][pattern.column]).toEqual("2"); + expect(results[0][pattern.message]).toEqual("Fix whitespace formatting. Insert '\t'."); + expect(results[0][pattern.severity]).toEqual("error"); + expect(results[0][pattern.code]).toEqual("WHITESPACE"); + + expect(results[1][pattern.file]).toEqual("/path/file.cs"); + expect(results[1][pattern.line]).toEqual("15"); + expect(results[1][pattern.column]).toEqual("3"); + expect(results[1][pattern.message]).toEqual("Fix whitespace formatting. Replace 4 characters with '\n\t\t\t'."); + + expect(results[2][pattern.file]).toEqual("/path/file.cs"); + expect(results[2][pattern.line]).toEqual("16"); + expect(results[2][pattern.column]).toEqual("84"); + expect(results[2][pattern.message]).toEqual("Fix whitespace formatting. Replace 4 characters with '\n\t\t\t'."); }); }); }); diff --git a/action.yml b/action.yml index ba0807f1..9a829104 100644 --- a/action.yml +++ b/action.yml @@ -15,5 +15,5 @@ inputs: default: add runs: - using: "node12" + using: "node20" main: "dist/index.js" diff --git a/package.json b/package.json index 92f54a2c..83d74d0d 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "scripts": { "build": "tsc", "lint": "tsc --noEmit", - "package": "ncc build src/main.ts", + "package": "ncc build src/main.ts && cp src/*.json dist/", "release": "npm run package && git add -f dist/", "test": "jest" }, diff --git a/src/problem-matcher.json b/src/problem-matcher.json index 83875a33..2f7ef4ef 100644 --- a/src/problem-matcher.json +++ b/src/problem-matcher.json @@ -4,11 +4,14 @@ "owner": "dotnet-format", "pattern": [ { - "regexp": "^\\s+(.*)\\((\\d+),(\\d+)\\):\\s+(.*)$", + "regexp": "^\\s*(.*)\\((\\d+),(\\d+)\\): (\\w+) ([^:]+): ([^\\[]+) \\[(.*)\\]", "file": 1, "line": 2, "column": 3, - "message": 4 + "severity": 4, + "code": 5, + "message": 6, + "fromPath": 7 } ] }