mirror of
https://github.com/actions/setup-dotnet.git
synced 2026-11-28 15:33:08 +00:00
Compare commits
2 Commits
da5e5482f2
...
tool-confi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2432953e24 | ||
|
|
26b0ec14cb |
11
.github/csc.json
vendored
11
.github/csc.json
vendored
@@ -4,13 +4,14 @@
|
|||||||
"owner": "csc",
|
"owner": "csc",
|
||||||
"pattern": [
|
"pattern": [
|
||||||
{
|
{
|
||||||
"regexp": "^([^\\s].*)\\((\\d+)(?:,\\d+|,\\d+,\\d+)?\\):\\s+(error|warning)\\s+([a-zA-Z]+(?<!MSB)\\d+):\\s*(.*?)\\s+\\[(.*?)\\]$",
|
"regexp": "^\\s*(?:\\d+>\\s*)?([^\\s].*)\\((\\d+)(?:,(\\d+))?(?:,\\d+)*\\):\\s+(error|warning)\\s+([a-zA-Z]+(?<!MSB)\\d*):\\s*(.*?)\\s+\\[(.*?)\\]$",
|
||||||
"file": 1,
|
"file": 1,
|
||||||
"line": 2,
|
"line": 2,
|
||||||
"severity": 3,
|
"column": 3,
|
||||||
"code": 4,
|
"severity": 4,
|
||||||
"message": 5,
|
"code": 5,
|
||||||
"fromPath": 6
|
"message": 6,
|
||||||
|
"fromPath": 7
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
10
.prettierrc.json
Normal file
10
.prettierrc.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"printWidth": 80,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"useTabs": false,
|
||||||
|
"semi": true,
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "none",
|
||||||
|
"bracketSpacing": false,
|
||||||
|
"arrowParens": "avoid"
|
||||||
|
}
|
||||||
@@ -1,45 +1,96 @@
|
|||||||
import cscFile from '../.github/csc.json';
|
import cscFile from '../.github/csc.json';
|
||||||
describe('csc tests', () => {
|
describe('csc tests', () => {
|
||||||
test('regular expression in csc.json is valid', async () => {
|
const regexPattern = cscFile['problemMatcher'][0]['pattern'][0]['regexp'];
|
||||||
const regexPattern = cscFile['problemMatcher'][0]['pattern'][0]['regexp'];
|
const regexResultsMap = cscFile['problemMatcher'][0]['pattern'][0];
|
||||||
const regexResultsMap = cscFile['problemMatcher'][0]['pattern'][0];
|
const regex = new RegExp(regexPattern);
|
||||||
|
|
||||||
const regex = new RegExp(regexPattern);
|
const testCases: Array<{input: string; results: Record<string, string>}> = [
|
||||||
|
{
|
||||||
const stringsToMatch = [
|
input:
|
||||||
'Program.cs(10,79): error CS1002: ; expected [/Users/zacharyeisinger/Documents/repo/setup-dotnet/__tests__/sample-broken-csproj/sample.csproj]',
|
'Program.cs(10,79): error CS1002: ; expected [/Users/zacharyeisinger/Documents/repo/setup-dotnet/__tests__/sample-broken-csproj/sample.csproj]',
|
||||||
"S:\\Msbuild\\src\\Build\\Evaluation\\ExpressionShredder.cs(33,7): error CS1003: Syntax error, ',' expected [S:\\msbuild\\src\\Build\\Microsoft.Build.csproj > Properties:prop]"
|
results: {
|
||||||
];
|
|
||||||
// Expected results are calculated according to the csc matcher located in csc.json file
|
|
||||||
const expectedResults = [
|
|
||||||
{
|
|
||||||
file: 'Program.cs',
|
file: 'Program.cs',
|
||||||
line: '10',
|
line: '10',
|
||||||
|
column: '79',
|
||||||
severity: 'error',
|
severity: 'error',
|
||||||
code: 'CS1002',
|
code: 'CS1002',
|
||||||
message: '; expected',
|
message: '; expected',
|
||||||
fromPath:
|
fromPath:
|
||||||
'/Users/zacharyeisinger/Documents/repo/setup-dotnet/__tests__/sample-broken-csproj/sample.csproj'
|
'/Users/zacharyeisinger/Documents/repo/setup-dotnet/__tests__/sample-broken-csproj/sample.csproj'
|
||||||
},
|
}
|
||||||
{
|
},
|
||||||
|
{
|
||||||
|
input:
|
||||||
|
"S:\\Msbuild\\src\\Build\\Evaluation\\ExpressionShredder.cs(33,7): error CS1003: Syntax error, ',' expected [S:\\msbuild\\src\\Build\\Microsoft.Build.csproj > Properties:prop]",
|
||||||
|
results: {
|
||||||
file: 'S:\\Msbuild\\src\\Build\\Evaluation\\ExpressionShredder.cs',
|
file: 'S:\\Msbuild\\src\\Build\\Evaluation\\ExpressionShredder.cs',
|
||||||
line: '33',
|
line: '33',
|
||||||
|
column: '7',
|
||||||
severity: 'error',
|
severity: 'error',
|
||||||
code: 'CS1003',
|
code: 'CS1003',
|
||||||
message: "Syntax error, ',' expected",
|
message: "Syntax error, ',' expected",
|
||||||
fromPath:
|
fromPath:
|
||||||
'S:\\msbuild\\src\\Build\\Microsoft.Build.csproj > Properties:prop'
|
'S:\\msbuild\\src\\Build\\Microsoft.Build.csproj > Properties:prop'
|
||||||
}
|
}
|
||||||
];
|
},
|
||||||
|
{
|
||||||
|
// `dotnet format` style error
|
||||||
|
input:
|
||||||
|
'C:\\actions-runner\\_work\\Some\\Folder\\SomeFile.cs(222,8): error WHITESPACE: Fix whitespace formatting. Delete 1 characters. [C:\\actions-runner\\_work\\Some\\Folder\\SomeProject.csproj]',
|
||||||
|
results: {
|
||||||
|
file: 'C:\\actions-runner\\_work\\Some\\Folder\\SomeFile.cs',
|
||||||
|
line: '222',
|
||||||
|
column: '8',
|
||||||
|
severity: 'error',
|
||||||
|
code: 'WHITESPACE',
|
||||||
|
message: 'Fix whitespace formatting. Delete 1 characters.',
|
||||||
|
fromPath: 'C:\\actions-runner\\_work\\Some\\Folder\\SomeProject.csproj'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// CSC error with whitespace prefix
|
||||||
|
input:
|
||||||
|
' /Volumes/Code/ghe_actions-2.301.1/Some/Folder/SomeFile.cs(10,8): error CS1014: A get or set accessor expected [/Volumes/Code/ghe_actions-2.301.1/Some/Folder/SomeProject.csproj]',
|
||||||
|
results: {
|
||||||
|
file: '/Volumes/Code/ghe_actions-2.301.1/Some/Folder/SomeFile.cs',
|
||||||
|
line: '10',
|
||||||
|
column: '8',
|
||||||
|
severity: 'error',
|
||||||
|
code: 'CS1014',
|
||||||
|
message: 'A get or set accessor expected',
|
||||||
|
fromPath:
|
||||||
|
'/Volumes/Code/ghe_actions-2.301.1/Some/Folder/SomeProject.csproj'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// CSC error with MSBuild prefix
|
||||||
|
input:
|
||||||
|
' 20>C:\\actions-runner\\_work\\Some\\Folder\\SomeFile.cs(8,2): error CS1014: A get or set accessor expected [C:\\actions-runner\\_work\\Some\\Folder\\SomeProject.csproj]',
|
||||||
|
results: {
|
||||||
|
file: 'C:\\actions-runner\\_work\\Some\\Folder\\SomeFile.cs',
|
||||||
|
line: '8',
|
||||||
|
column: '2',
|
||||||
|
severity: 'error',
|
||||||
|
code: 'CS1014',
|
||||||
|
message: 'A get or set accessor expected',
|
||||||
|
fromPath: 'C:\\actions-runner\\_work\\Some\\Folder\\SomeProject.csproj'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
stringsToMatch.map((string, index) => {
|
test.each(testCases)(
|
||||||
const matchedResultsArray = string.match(regex);
|
'regex matches and parses: $input',
|
||||||
for (const propName in expectedResults[index]) {
|
({input, results}: {input: string; results: Record<string, string>}) => {
|
||||||
|
const matchedResultsArray = input.match(regex);
|
||||||
|
expect(matchedResultsArray).not.toBeNull();
|
||||||
|
|
||||||
|
for (const propName in results) {
|
||||||
const propertyIndex = regexResultsMap[propName];
|
const propertyIndex = regexResultsMap[propName];
|
||||||
const expectedPropValue = expectedResults[index][propName];
|
const expectedPropValue = results[propName];
|
||||||
const matchedPropValue = matchedResultsArray![propertyIndex];
|
const matchedPropValue = matchedResultsArray![propertyIndex];
|
||||||
expect(matchedPropValue).toEqual(expectedPropValue);
|
expect(matchedPropValue).toEqual(expectedPropValue);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
}, 10000);
|
10000
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
74
eslint.config.mjs
Normal file
74
eslint.config.mjs
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
// This is a reusable configuration file copied from https://github.com/actions/reusable-workflows/tree/main/reusable-configurations. Please don't make changes to this file as it's the subject of an automatic update.
|
||||||
|
import js from '@eslint/js';
|
||||||
|
import tsParser from '@typescript-eslint/parser';
|
||||||
|
import tsPlugin from '@typescript-eslint/eslint-plugin';
|
||||||
|
import jest from 'eslint-plugin-jest';
|
||||||
|
import n from 'eslint-plugin-n';
|
||||||
|
import prettier from 'eslint-config-prettier';
|
||||||
|
import globals from 'globals';
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
ignores: ['**/*', '!src/**', '!__tests__/**']
|
||||||
|
},
|
||||||
|
js.configs.recommended,
|
||||||
|
{
|
||||||
|
files: ['**/*.ts'],
|
||||||
|
languageOptions: {
|
||||||
|
parser: tsParser,
|
||||||
|
ecmaVersion: 2022,
|
||||||
|
sourceType: 'module',
|
||||||
|
globals: {
|
||||||
|
...globals.node,
|
||||||
|
...globals.es2015
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plugins: {
|
||||||
|
'@typescript-eslint': tsPlugin,
|
||||||
|
n
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
...tsPlugin.configs.recommended.rules,
|
||||||
|
'@typescript-eslint/no-require-imports': 'error',
|
||||||
|
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||||
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
|
'@typescript-eslint/no-empty-function': 'off',
|
||||||
|
'@typescript-eslint/ban-ts-comment': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'ts-ignore': 'allow-with-description'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'no-console': 'error',
|
||||||
|
yoda: 'error',
|
||||||
|
'prefer-const': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
destructuring: 'all'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'no-control-regex': 'off',
|
||||||
|
'no-constant-condition': ['error', {checkLoops: false}],
|
||||||
|
'no-undef': 'off',
|
||||||
|
'no-useless-assignment': 'off',
|
||||||
|
'n/no-extraneous-import': 'error'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['**/*{test,spec}.ts'],
|
||||||
|
plugins: {jest},
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.jest
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
...jest.configs['flat/recommended'].rules,
|
||||||
|
'@typescript-eslint/no-unused-vars': 'off',
|
||||||
|
'jest/no-standalone-expect': 'off',
|
||||||
|
'jest/no-conditional-expect': 'off',
|
||||||
|
'no-console': 'off'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
prettier
|
||||||
|
];
|
||||||
Reference in New Issue
Block a user