Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b67cd9fb3 | ||
|
|
5938cacd96 | ||
|
|
389f0126c9 | ||
|
|
bbe92b8e4f | ||
|
|
6d3cafd749 | ||
|
|
9a33ec6b8a | ||
|
|
47a6b397d9 |
33
.github/workflows/CI.yml
vendored
33
.github/workflows/CI.yml
vendored
@@ -1,33 +0,0 @@
|
|||||||
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: build/
|
|
||||||
|
|
||||||
- name: Test problem matcher
|
|
||||||
run: |
|
|
||||||
ls
|
|
||||||
cat dist/gcc_matcher.json
|
|
||||||
cp -r test build
|
|
||||||
gcc -Wall -Wextra -O0 build/generate_warnings.c
|
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,4 +1,2 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
*/gcc_matcher.json
|
*/gcc_matcher.json
|
||||||
*/a.out
|
|
||||||
.vscode/
|
|
||||||
|
|||||||
12
README.md
12
README.md
@@ -4,22 +4,16 @@ Creates annotations for warnings and errors in gcc builds.
|
|||||||
|
|
||||||
## Inputs
|
## Inputs
|
||||||
|
|
||||||
### build-directory
|
### root
|
||||||
|
|
||||||
**Optional** Base directory for build. For builds done in a subdirectory, this should match that directory, otherwise the pattern match will not be able to point to the correct file.
|
**Optional** Base directory for build. For builds done in a subdirectory, this should match that directory, otherwise the pattern match will not be able to point to the correct file.
|
||||||
|
|
||||||
## Example usage
|
## Example usage
|
||||||
|
|
||||||
Create annotations for builds done in the root directory
|
Just add this line anywhere before running the build step.
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: olemorud/gcc-problem-matcher@v1.0
|
|
||||||
```
|
|
||||||
|
|
||||||
Create annotations for builds done in directory `/workspace/build/`
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: olemorud/gcc-problem-matcher@master
|
- uses: olemorud/gcc-problem-matcher@master
|
||||||
with:
|
with:
|
||||||
build-directory: /workspace/build/
|
root: /workspace/build
|
||||||
```
|
```
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
name: GCC Problem Matcher Improved
|
name: GCC Problem Matcher
|
||||||
|
|
||||||
description: Get annotations for warnings and errors on builds using gcc
|
description: Get annotations for warnings and errors on builds using gcc
|
||||||
|
|
||||||
@@ -9,9 +9,10 @@ branding:
|
|||||||
color: yellow
|
color: yellow
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
build-directory:
|
root:
|
||||||
description: 'base directory for build, e.g. /workdir/build'
|
description: 'base directory for build, e.g. /workdir/build'
|
||||||
required: false
|
required: false
|
||||||
|
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": "^${{ BASE }}\/?(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
|
||||||
"file": 1,
|
"file": 1,
|
||||||
"line": 2,
|
"line": 2,
|
||||||
"column": 3,
|
"column": 3,
|
||||||
|
|||||||
41
dist/index.js
vendored
41
dist/index.js
vendored
@@ -2845,45 +2845,32 @@ 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);
|
||||||
|
|
||||||
// escapeRegExp :: string => string
|
// C:\Users\ => C\:\\Users\\
|
||||||
// escape all characters with special meanings in regexp
|
|
||||||
const escapeRegExp = (s) =>
|
const escapeRegExp = (s) =>
|
||||||
s.replace(/[/\-^$*+?.()|[\]{}]/g, "\\\\$&");
|
s.replace(/[:.*+?^${}()|\/[\]\\]/g, "\\$&");
|
||||||
|
|
||||||
// variable :: string => RegExp
|
|
||||||
// create regex to match ${{ key }}
|
// ${{ key }}, ${{var}}, ${{ aggqq43g3qg4 }}
|
||||||
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";
|
||||||
|
|
||||||
// matcherPath :: string
|
const parsed =
|
||||||
const outputPath = __nccwpck_require__.ab + "gcc_matcher.json";
|
fs.readFileSync(__nccwpck_require__.ab + "gcc_matcher.jsontemplate", "ascii")
|
||||||
|
.replace(variable("BASE"), escapeRegExp(root));
|
||||||
|
|
||||||
// rootdir :: string
|
const matcherPath = __nccwpck_require__.ab + "gcc_matcher.json";
|
||||||
const rootdir = core.getInput('build-directory', {required: false});
|
|
||||||
|
|
||||||
// parse :: string => string => Error | null
|
fs.writeFileSync(__nccwpck_require__.ab + "gcc_matcher.json", parsed);
|
||||||
const parse = (templatePath) => (matcherPath) => {
|
|
||||||
const content = fs.readFileSync(templatePath, 'utf-8');
|
|
||||||
|
|
||||||
const parsed = content.replace(variable("BASE"), escapeRegExp(rootdir));
|
|
||||||
|
|
||||||
fs.writeFileSync(matcherPath, parsed);
|
|
||||||
|
|
||||||
console.log('::add-matcher::' + matcherPath);
|
console.log('::add-matcher::' + matcherPath);
|
||||||
}
|
|
||||||
|
|
||||||
// main:
|
/* for testing */
|
||||||
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": "^${{ BASE }}\/?(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
|
||||||
"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 }}
|
||||||
@@ -16,28 +16,27 @@ const variable = (key) =>
|
|||||||
const templatePath = path.join(__dirname, "gcc_matcher.jsontemplate");
|
const templatePath = path.join(__dirname, "gcc_matcher.jsontemplate");
|
||||||
|
|
||||||
// matcherPath :: string
|
// matcherPath :: string
|
||||||
const outputPath = path.join(__dirname, "gcc_matcher.json");
|
const matcherPath = path.join(__dirname, "gcc_matcher.json");
|
||||||
|
|
||||||
// rootdir :: string
|
// parse :: IO => IO => Error | null
|
||||||
const rootdir = core.getInput('build-directory', {required: false});
|
|
||||||
|
|
||||||
// parse :: string => string => Error | null
|
|
||||||
const parse = (templatePath) => (matcherPath) => {
|
const parse = (templatePath) => (matcherPath) => {
|
||||||
const content = fs.readFileSync(templatePath, 'utf-8');
|
fs.readFile(templatePath, 'utf-8', (err, content) => {
|
||||||
|
if (err) throw err;
|
||||||
|
|
||||||
const parsed = content.replace(variable("BASE"), escapeRegExp(rootdir));
|
const root = core.getInput('root', { required: false });
|
||||||
|
|
||||||
fs.writeFileSync(matcherPath, parsed);
|
const parsed = content.replace(variable("BASE"), escapeRegExp(root));
|
||||||
|
|
||||||
|
fs.writeFile(matcherPath, parsed, (err) => {
|
||||||
|
if (err) throw err;
|
||||||
|
|
||||||
console.log('::add-matcher::' + matcherPath);
|
console.log('::add-matcher::' + matcherPath);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// main:
|
// main:
|
||||||
try {
|
parse(templatePath)(matcherPath);
|
||||||
parse(templatePath)(outputPath);
|
|
||||||
} catch (err) {
|
|
||||||
core.setFailed(`Action failed with error ${err}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// for testing
|
// for testing
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
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', {skip: true}, () => {
|
test('regex escaping test', () => {
|
||||||
const escapeRegExp = _testing.escapeRegExp;
|
const escapeRegExp = _testing.escapeRegExp;
|
||||||
|
|
||||||
const st = [
|
const st = [
|
||||||
|
|||||||
Reference in New Issue
Block a user