25 Commits

Author SHA1 Message Date
Ole Morud
6d0c0875e2 append "(deprecated)" to action name 2023-06-29 10:25:56 +02:00
Ole Morud
4f4ec21ba1 Add warning about new upstream in README 2023-06-29 10:12:40 +02:00
Ole Morud
545126f0e8 Update README.md 2023-03-24 10:04:52 +01:00
Ole Morud
0005e194cc Update README.md 2023-03-24 10:02:25 +01:00
Ole Morud
17624185be [docs] Update image in README.md 2023-03-17 13:44:04 +01:00
Ole Morud
bf055241d4 Update README.md 2023-03-17 13:42:31 +01:00
Ole Morud
a9f3482630 [docs] Update README.md 2023-03-16 14:04:34 +01:00
Ole Morud
04fba30579 [docs] Update README.md 2023-03-16 14:03:13 +01:00
olemorud
bb3b327c51 [docs] Update README 2023-03-16 11:20:50 +01:00
olemorud
60e141d668 [feat] Remove fromPath in matcher template 2023-03-16 11:15:15 +01:00
Ole Morud
08515e67e1 [docs] Update README.md 2023-03-16 11:15:15 +01:00
Ole Morud
8509223bc7 [feat] Change action name, update options 2023-03-16 11:15:15 +01:00
olemorud
ae82e15273 [feat] Make regex eat trailing '/' in group 1 2023-03-16 11:15:15 +01:00
olemorud
dd72791927 [feat] Add more bad code to generate_warnings.c 2023-03-16 11:15:15 +01:00
olemorud
0de4817981 [feat] Add fromPath to matcher template 2023-03-16 11:15:15 +01:00
olemorud
b651f721c4 [feat] Remove artifacts used for testing action 2023-03-16 11:14:29 +01:00
olemorud
d87815601a [test] skip broken test 2023-03-16 11:14:29 +01:00
olemorud
6bc12485dd [ci] add CI 2023-03-16 11:14:25 +01:00
olemorud
fb9ac95d1a [chore] .gitignore: add .vscode 2023-03-16 11:14:25 +01:00
olemorud
c312ae7971 [feat] Update action.yml to use dist/ 2023-03-16 11:14:20 +01:00
olemorud
15a0ef1a78 [build] package.json: Add npm build command 2023-03-16 11:09:29 +01:00
olemorud
bb243c024a [feat] index.js: use async read/write 2023-03-16 11:08:12 +01:00
olemorud
850281ad51 [chore] .gitignore: add */gcc_matcher.json 2023-03-16 11:06:23 +01:00
olemorud
9a4355f8e1 [docs] Update README 2023-03-16 11:06:15 +01:00
olemorud
52b5d16c14 [build] npm init 2023-03-16 11:05:29 +01:00
12 changed files with 3136 additions and 27 deletions

33
.github/workflows/CI.yml vendored Normal file
View 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 Normal file
View File

@@ -0,0 +1,4 @@
node_modules/
*/gcc_matcher.json
*/a.out
.vscode/

View File

@@ -1,12 +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
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Folemorud%2Fgcc-problem-matcher.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Folemorud%2Fgcc-problem-matcher?ref=badge_shield)
Creates annotations for warnings and errors in gcc builds. Creates annotations for warnings and errors in gcc builds.
![image](https://user-images.githubusercontent.com/82065181/225907856-336fa631-6520-44ce-bdf5-cf5780e45e40.png)
## Usage
Just add a single line before running the build step.
## Inputs
### build-directory
**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
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 ```yaml
- uses: olemorud/gcc-problem-matcher@master - uses: olemorud/gcc-problem-matcher@master
with:
build-directory: /workspace/build/
- name: Build
run: |
...
``` ```

View File

@@ -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 author: Ole Morud
@@ -9,11 +9,10 @@ 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: false
default: ''
runs: runs:
using: 'node16' using: 'node16'
main: 'src/index.js' main: 'dist/index.js'

17
dist/gcc_matcher.jsontemplate vendored Normal file
View File

@@ -0,0 +1,17 @@
{
"problemMatcher": [
{
"owner": "gcc-problem-matcher",
"pattern": [
{
"regexp": "^${{ BASE }}\\/?(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
]
}
]
}

2893
dist/index.js vendored Normal file

File diff suppressed because it is too large Load Diff

77
package-lock.json generated Normal file
View File

@@ -0,0 +1,77 @@
{
"name": "gcc-problem-matcher",
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "gcc-problem-matcher",
"version": "1.0.0",
"dependencies": {
"@actions/core": "^1.10.0"
}
},
"node_modules/@actions/core": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz",
"integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==",
"dependencies": {
"@actions/http-client": "^2.0.1",
"uuid": "^8.3.2"
}
},
"node_modules/@actions/http-client": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.1.0.tgz",
"integrity": "sha512-BonhODnXr3amchh4qkmjPMUO8mFi/zLaaCeCAJZqch8iQqyDnVIkySjB38VHAC8IJ+bnlgfOqlhpyCUZHlQsqw==",
"dependencies": {
"tunnel": "^0.0.6"
}
},
"node_modules/tunnel": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==",
"engines": {
"node": ">=0.6.11 <=0.7.0 || >=0.7.3"
}
},
"node_modules/uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"bin": {
"uuid": "dist/bin/uuid"
}
}
},
"dependencies": {
"@actions/core": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz",
"integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==",
"requires": {
"@actions/http-client": "^2.0.1",
"uuid": "^8.3.2"
}
},
"@actions/http-client": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.1.0.tgz",
"integrity": "sha512-BonhODnXr3amchh4qkmjPMUO8mFi/zLaaCeCAJZqch8iQqyDnVIkySjB38VHAC8IJ+bnlgfOqlhpyCUZHlQsqw==",
"requires": {
"tunnel": "^0.0.6"
}
},
"tunnel": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg=="
},
"uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
}
}
}

26
package.json Normal file
View File

@@ -0,0 +1,26 @@
{
"name": "gcc-problem-matcher",
"version": "1.0.0",
"description": "Creates annotations for warnings and errors in gcc builds.",
"main": "index.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "node --test",
"build": "ncc build src/index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/olemorud/gcc-problem-matcher.git"
},
"keywords": [],
"author": "",
"bugs": {
"url": "https://github.com/olemorud/gcc-problem-matcher/issues"
},
"homepage": "https://github.com/olemorud/gcc-problem-matcher#readme",
"dependencies": {
"@actions/core": "^1.10.0"
}
}

View File

@@ -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,

View File

@@ -1,33 +1,45 @@
const path = require('path'); const path = require('path');
const fs = require('node:fs'); const fs = require('node:fs');
//const core = require('@actions/core'); const core = require('@actions/core');
// 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 });
root = '/tmp/workspace';
const templatePath = path.join(__dirname, "gcc_matcher.jsontemplate"); const templatePath = path.join(__dirname, "gcc_matcher.jsontemplate");
const parsed = // matcherPath :: string
fs.readFileSync(templatePath, "ascii") const outputPath = path.join(__dirname, "gcc_matcher.json");
.replace(variable("BASE"), escapeRegExp(root));
const matcherPath = path.join(__dirname, "gcc_matcher.json"); // rootdir :: string
const rootdir = core.getInput('build-directory', {required: false});
fs.writeFileSync(matcherPath, 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(templatePath)(outputPath);
} catch (err) {
core.setFailed(`Action failed with error ${err}`)
}
// for testing
exports.escapeRegExp = escapeRegExp exports.escapeRegExp = escapeRegExp
exports.variable = variable; exports.variable = variable;

18
test/generate_warnings.c Normal file
View 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));
}

View File

@@ -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 = [