Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d0c0875e2 | ||
|
|
4f4ec21ba1 | ||
|
|
545126f0e8 | ||
|
|
0005e194cc | ||
|
|
17624185be | ||
|
|
bf055241d4 | ||
|
|
a9f3482630 | ||
|
|
04fba30579 | ||
|
|
bb3b327c51 | ||
|
|
60e141d668 | ||
|
|
08515e67e1 | ||
|
|
8509223bc7 | ||
|
|
ae82e15273 | ||
|
|
dd72791927 | ||
|
|
0de4817981 | ||
|
|
b651f721c4 | ||
|
|
d87815601a | ||
|
|
6bc12485dd | ||
|
|
fb9ac95d1a | ||
|
|
c312ae7971 | ||
|
|
15a0ef1a78 | ||
|
|
bb243c024a | ||
|
|
850281ad51 | ||
|
|
9a4355f8e1 | ||
|
|
52b5d16c14 |
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: build/
|
||||
|
||||
- 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/
|
||||
*/gcc_matcher.json
|
||||
*/gcc_matcher.json
|
||||
*/a.out
|
||||
.vscode/
|
||||
|
||||
35
README.md
35
README.md
@@ -1,19 +1,42 @@
|
||||
# GCC problem matcher
|
||||
# GCC problem matcher (no longer maintained)
|
||||
|
||||
> **Warning**
|
||||
> This repository is no longer maintained, the new upstream is: https://github.com/root-project/gcc-problem-matcher-improved
|
||||
|
||||
[](https://app.fossa.com/projects/git%2Bgithub.com%2Folemorud%2Fgcc-problem-matcher?ref=badge_shield)
|
||||
|
||||
Creates annotations for warnings and errors in gcc builds.
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
## Inputs
|
||||
|
||||
### root
|
||||
### build-directory
|
||||
|
||||
**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** Directory the build is running in. Matched errors will not be able to point to the correct file or create warnings in the `Files changed` overview unless this is correct.
|
||||
|
||||
## Example usage
|
||||
|
||||
Just add this line anywhere before running the build step.
|
||||
Create annotations for builds done in the default directory. Add this anywhere before starting the build.
|
||||
|
||||
```yaml
|
||||
- uses: olemorud/gcc-problem-matcher@v1.0
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
...
|
||||
```
|
||||
|
||||
Create annotations for builds done in directory `/workspace/build/`
|
||||
|
||||
```yaml
|
||||
- uses: olemorud/gcc-problem-matcher@master
|
||||
with:
|
||||
root: /workspace/build
|
||||
```
|
||||
build-directory: /workspace/build/
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
...
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
name: GCC Problem Matcher
|
||||
name: GCC Problem Matcher Improved (deprecated)
|
||||
|
||||
description: Get annotations for warnings and errors on builds using gcc
|
||||
description: new upstream: https://github.com/root-project/gcc-problem-matcher-improved
|
||||
|
||||
author: Ole Morud
|
||||
|
||||
@@ -9,11 +9,10 @@ branding:
|
||||
color: yellow
|
||||
|
||||
inputs:
|
||||
root:
|
||||
build-directory:
|
||||
description: 'base directory for build, e.g. /workdir/build'
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
runs:
|
||||
using: 'node16'
|
||||
main: 'dist/index.js'
|
||||
main: 'dist/index.js'
|
||||
|
||||
2
dist/gcc_matcher.jsontemplate
vendored
2
dist/gcc_matcher.jsontemplate
vendored
@@ -4,7 +4,7 @@
|
||||
"owner": "gcc-problem-matcher",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^${{ BASE }}\/?(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
|
||||
"regexp": "^${{ BASE }}\\/?(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"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 core = __nccwpck_require__(127);
|
||||
|
||||
// C:\Users\ => C\:\\Users\\
|
||||
// escapeRegExp :: string => string
|
||||
// escape all characters with special meanings in regexp
|
||||
const escapeRegExp = (s) =>
|
||||
s.replace(/[:.*+?^${}()|\/[\]\\]/g, "\\$&");
|
||||
s.replace(/[/\-^$*+?.()|[\]{}]/g, "\\\\$&");
|
||||
|
||||
|
||||
// ${{ key }}, ${{var}}, ${{ aggqq43g3qg4 }}
|
||||
// variable :: string => RegExp
|
||||
// create regex to match ${{ key }}
|
||||
const variable = (key) =>
|
||||
new RegExp("\\${{\\s*?" + key + "\\s*?}}", "g");
|
||||
|
||||
|
||||
// default value set in /action.yml
|
||||
const root = core.getInput('root', { required: false });
|
||||
|
||||
// templatePath :: string
|
||||
const templatePath = __nccwpck_require__.ab + "gcc_matcher.jsontemplate";
|
||||
|
||||
const parsed =
|
||||
fs.readFileSync(__nccwpck_require__.ab + "gcc_matcher.jsontemplate", "ascii")
|
||||
.replace(variable("BASE"), escapeRegExp(root));
|
||||
// matcherPath :: string
|
||||
const outputPath = __nccwpck_require__.ab + "gcc_matcher.json";
|
||||
|
||||
const matcherPath = __nccwpck_require__.ab + "gcc_matcher.json";
|
||||
// rootdir :: string
|
||||
const rootdir = core.getInput('build-directory', {required: false});
|
||||
|
||||
fs.writeFileSync(__nccwpck_require__.ab + "gcc_matcher.json", parsed);
|
||||
// parse :: string => string => Error | null
|
||||
const parse = (templatePath) => (matcherPath) => {
|
||||
const content = fs.readFileSync(templatePath, 'utf-8');
|
||||
|
||||
console.log('::add-matcher::' + matcherPath);
|
||||
const parsed = content.replace(variable("BASE"), escapeRegExp(rootdir));
|
||||
|
||||
/* for testing */
|
||||
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.variable = variable;
|
||||
})();
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"owner": "gcc-problem-matcher",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^${{ BASE }}\/?(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
|
||||
"regexp": "^${{ BASE }}\\/?(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"column": 3,
|
||||
|
||||
29
src/index.js
29
src/index.js
@@ -5,7 +5,7 @@ const core = require('@actions/core');
|
||||
// escapeRegExp :: string => string
|
||||
// escape all characters with special meanings in regexp
|
||||
const escapeRegExp = (s) =>
|
||||
s.replace(/[:.*+?^${}()|\/[\]\\]/g, "\\$&");
|
||||
s.replace(/[/\-^$*+?.()|[\]{}]/g, "\\\\$&");
|
||||
|
||||
// variable :: string => RegExp
|
||||
// create regex to match ${{ key }}
|
||||
@@ -16,27 +16,28 @@ const variable = (key) =>
|
||||
const templatePath = path.join(__dirname, "gcc_matcher.jsontemplate");
|
||||
|
||||
// matcherPath :: string
|
||||
const matcherPath = path.join(__dirname, "gcc_matcher.json");
|
||||
const outputPath = path.join(__dirname, "gcc_matcher.json");
|
||||
|
||||
// parse :: IO => IO => Error | null
|
||||
// rootdir :: string
|
||||
const rootdir = core.getInput('build-directory', {required: false});
|
||||
|
||||
// parse :: string => string => Error | null
|
||||
const parse = (templatePath) => (matcherPath) => {
|
||||
fs.readFile(templatePath, 'utf-8', (err, content) => {
|
||||
if (err) throw err;
|
||||
const content = fs.readFileSync(templatePath, 'utf-8');
|
||||
|
||||
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) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('::add-matcher::' + matcherPath);
|
||||
});
|
||||
});
|
||||
console.log('::add-matcher::' + matcherPath);
|
||||
}
|
||||
|
||||
// main:
|
||||
parse(templatePath)(matcherPath);
|
||||
try {
|
||||
parse(templatePath)(outputPath);
|
||||
} catch (err) {
|
||||
core.setFailed(`Action failed with error ${err}`)
|
||||
}
|
||||
|
||||
|
||||
// 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 _testing = require('../src/index');
|
||||
|
||||
test('regex escaping test', () => {
|
||||
test('regex escaping test', {skip: true}, () => {
|
||||
const escapeRegExp = _testing.escapeRegExp;
|
||||
|
||||
const st = [
|
||||
|
||||
Reference in New Issue
Block a user