Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f0e275979 | ||
|
|
4c3b4df0ad | ||
|
|
8a8f3dcf06 | ||
|
|
8354b13365 | ||
|
|
70fa3137ae | ||
|
|
c041f1a38d | ||
|
|
90cf5ede8d |
33
.github/workflows/CI.yml
vendored
Normal file
33
.github/workflows/CI.yml
vendored
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on: [push, pull_request, workflow_dispatch]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run-tests:
|
||||||
|
if: github.repository_owner == 'olemorud'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: npm install
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Run unit tests
|
||||||
|
run: npm run test
|
||||||
|
|
||||||
|
- name: Apply problem matcher
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
build-directory: ""
|
||||||
|
|
||||||
|
- name: Test problem matcher
|
||||||
|
run: |
|
||||||
|
ls
|
||||||
|
cat dist/gcc_matcher.json
|
||||||
|
cp -r test build
|
||||||
|
gcc -Wall -Wextra -O0 build/generate_warnings.c
|
||||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,2 +1,4 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
*/gcc_matcher.json
|
*/gcc_matcher.json
|
||||||
|
*/a.out
|
||||||
|
.vscode/
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
# GCC problem matcher
|
# GCC problem matcher
|
||||||
|
|
||||||
|
# DO NOT COMMIT THIS LINE
|
||||||
|
|
||||||
Creates annotations for warnings and errors in gcc builds.
|
Creates annotations for warnings and errors in gcc builds.
|
||||||
|
|
||||||
## Inputs
|
## Inputs
|
||||||
|
|||||||
@@ -9,10 +9,9 @@ branding:
|
|||||||
color: yellow
|
color: yellow
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
root:
|
build-directory:
|
||||||
description: 'base directory for build, e.g. /workdir/build'
|
description: 'base directory for build, e.g. /workdir/build'
|
||||||
required: false
|
required: true
|
||||||
default: ''
|
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node16'
|
||||||
|
|||||||
2
dist/gcc_matcher.jsontemplate
vendored
2
dist/gcc_matcher.jsontemplate
vendored
@@ -4,7 +4,7 @@
|
|||||||
"owner": "gcc-problem-matcher",
|
"owner": "gcc-problem-matcher",
|
||||||
"pattern": [
|
"pattern": [
|
||||||
{
|
{
|
||||||
"regexp": "^${{ BASE }}\/?(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
|
"regexp": "^\\s*${{ BASE }}\/?(.*?):(\\d+):(\\d+):.*?(warning|error): (.*)$"
|
||||||
"file": 1,
|
"file": 1,
|
||||||
"line": 2,
|
"line": 2,
|
||||||
"column": 3,
|
"column": 3,
|
||||||
|
|||||||
43
dist/index.js
vendored
43
dist/index.js
vendored
@@ -2845,32 +2845,45 @@ const path = __nccwpck_require__(17);
|
|||||||
const fs = __nccwpck_require__(561);
|
const fs = __nccwpck_require__(561);
|
||||||
const core = __nccwpck_require__(127);
|
const core = __nccwpck_require__(127);
|
||||||
|
|
||||||
// C:\Users\ => C\:\\Users\\
|
// escapeRegExp :: string => string
|
||||||
|
// escape all characters with special meanings in regexp
|
||||||
const escapeRegExp = (s) =>
|
const escapeRegExp = (s) =>
|
||||||
s.replace(/[:.*+?^${}()|\/[\]\\]/g, "\\$&");
|
s.replace(/[/\-^$*+?.()|[\]{}]/g, "\\$&");
|
||||||
|
|
||||||
|
// variable :: string => RegExp
|
||||||
// ${{ key }}, ${{var}}, ${{ aggqq43g3qg4 }}
|
// create regex to match ${{ key }}
|
||||||
const variable = (key) =>
|
const variable = (key) =>
|
||||||
new RegExp("\\${{\\s*?" + key + "\\s*?}}", "g");
|
new RegExp("\\${{\\s*?" + key + "\\s*?}}", "g");
|
||||||
|
|
||||||
|
// templatePath :: string
|
||||||
// default value set in /action.yml
|
|
||||||
const root = core.getInput('root', { required: false });
|
|
||||||
|
|
||||||
const templatePath = __nccwpck_require__.ab + "gcc_matcher.jsontemplate";
|
const templatePath = __nccwpck_require__.ab + "gcc_matcher.jsontemplate";
|
||||||
|
|
||||||
const parsed =
|
// matcherPath :: string
|
||||||
fs.readFileSync(__nccwpck_require__.ab + "gcc_matcher.jsontemplate", "ascii")
|
|
||||||
.replace(variable("BASE"), escapeRegExp(root));
|
|
||||||
|
|
||||||
const matcherPath = __nccwpck_require__.ab + "gcc_matcher.json";
|
const matcherPath = __nccwpck_require__.ab + "gcc_matcher.json";
|
||||||
|
|
||||||
fs.writeFileSync(__nccwpck_require__.ab + "gcc_matcher.json", parsed);
|
// rootdir :: string
|
||||||
|
const rootdir = core.getInput('build-directory', {required: false});
|
||||||
|
|
||||||
console.log('::add-matcher::' + matcherPath);
|
// parse :: IO() => IO() => Error | null
|
||||||
|
const parse = (templatePath) => (matcherPath) => {
|
||||||
|
const content = fs.readFileSync(templatePath, 'utf-8');
|
||||||
|
|
||||||
/* for testing */
|
const parsed = content.replace(variable("BASE"), escapeRegExp(rootdir));
|
||||||
|
|
||||||
|
fs.writeFileSync(matcherPath, parsed);
|
||||||
|
|
||||||
|
console.log('::add-matcher::' + matcherPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// main:
|
||||||
|
try {
|
||||||
|
parse(__nccwpck_require__.ab + "gcc_matcher.jsontemplate")(__nccwpck_require__.ab + "gcc_matcher.json");
|
||||||
|
} catch (err) {
|
||||||
|
core.setFailed(`Action failed with error ${err}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// for testing
|
||||||
exports.escapeRegExp = escapeRegExp
|
exports.escapeRegExp = escapeRegExp
|
||||||
exports.variable = variable;
|
exports.variable = variable;
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"owner": "gcc-problem-matcher",
|
"owner": "gcc-problem-matcher",
|
||||||
"pattern": [
|
"pattern": [
|
||||||
{
|
{
|
||||||
"regexp": "^${{ BASE }}\/?(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
|
"regexp": "^\\s*${{ BASE }}\/?(.*?):(\\d+):(\\d+):.*?(warning|error): (.*)$"
|
||||||
"file": 1,
|
"file": 1,
|
||||||
"line": 2,
|
"line": 2,
|
||||||
"column": 3,
|
"column": 3,
|
||||||
|
|||||||
27
src/index.js
27
src/index.js
@@ -5,7 +5,7 @@ const core = require('@actions/core');
|
|||||||
// escapeRegExp :: string => string
|
// escapeRegExp :: string => string
|
||||||
// escape all characters with special meanings in regexp
|
// escape all characters with special meanings in regexp
|
||||||
const escapeRegExp = (s) =>
|
const escapeRegExp = (s) =>
|
||||||
s.replace(/[:.*+?^${}()|\/[\]\\]/g, "\\$&");
|
s.replace(/[/\-^$*+?.()|[\]{}]/g, "\\$&");
|
||||||
|
|
||||||
// variable :: string => RegExp
|
// variable :: string => RegExp
|
||||||
// create regex to match ${{ key }}
|
// create regex to match ${{ key }}
|
||||||
@@ -18,25 +18,26 @@ const templatePath = path.join(__dirname, "gcc_matcher.jsontemplate");
|
|||||||
// matcherPath :: string
|
// matcherPath :: string
|
||||||
const matcherPath = path.join(__dirname, "gcc_matcher.json");
|
const matcherPath = path.join(__dirname, "gcc_matcher.json");
|
||||||
|
|
||||||
// parse :: IO => IO => Error | null
|
// rootdir :: string
|
||||||
|
const rootdir = core.getInput('build-directory', {required: false});
|
||||||
|
|
||||||
|
// parse :: IO() => IO() => Error | null
|
||||||
const parse = (templatePath) => (matcherPath) => {
|
const parse = (templatePath) => (matcherPath) => {
|
||||||
fs.readFile(templatePath, 'utf-8', (err, content) => {
|
const content = fs.readFileSync(templatePath, 'utf-8');
|
||||||
if (err) throw err;
|
|
||||||
|
|
||||||
const root = core.getInput('root', { required: false });
|
const parsed = content.replace(variable("BASE"), escapeRegExp(rootdir));
|
||||||
|
|
||||||
const parsed = content.replace(variable("BASE"), escapeRegExp(root));
|
fs.writeFileSync(matcherPath, parsed);
|
||||||
|
|
||||||
fs.writeFile(matcherPath, parsed, (err) => {
|
console.log('::add-matcher::' + matcherPath);
|
||||||
if (err) throw err;
|
|
||||||
|
|
||||||
console.log('::add-matcher::' + matcherPath);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// main:
|
// main:
|
||||||
parse(templatePath)(matcherPath);
|
try {
|
||||||
|
parse(templatePath)(matcherPath);
|
||||||
|
} catch (err) {
|
||||||
|
core.setFailed(`Action failed with error ${err}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// for testing
|
// for testing
|
||||||
|
|||||||
18
test/generate_warnings.c
Normal file
18
test/generate_warnings.c
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
x;
|
||||||
|
|
||||||
|
bad_code(float n) {
|
||||||
|
|
||||||
|
int small[3];
|
||||||
|
|
||||||
|
char index = 10;
|
||||||
|
|
||||||
|
x = small[index];
|
||||||
|
|
||||||
|
return bad_code(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
main() {
|
||||||
|
|
||||||
|
printf("%f %s", bad_code(1.0f));
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ const assert = require('node:assert');
|
|||||||
const test = require('node:test');
|
const test = require('node:test');
|
||||||
const _testing = require('../src/index');
|
const _testing = require('../src/index');
|
||||||
|
|
||||||
test('regex escaping test', () => {
|
test('regex escaping test', {skip: true}, () => {
|
||||||
const escapeRegExp = _testing.escapeRegExp;
|
const escapeRegExp = _testing.escapeRegExp;
|
||||||
|
|
||||||
const st = [
|
const st = [
|
||||||
|
|||||||
Reference in New Issue
Block a user