From 059d630f7d16a7a38845c30e0227a875e39813db Mon Sep 17 00:00:00 2001 From: korelstar Date: Thu, 13 Feb 2020 12:34:02 +0100 Subject: [PATCH] create xmllint-problem-matcher --- .github/workflows/lint.yml | 22 ++ README.md | 11 + action.yml | 9 + index.js | 2 + test/error.xml | 12 + test/info.xml | 12 + test/info.xsd | 717 +++++++++++++++++++++++++++++++++++++ xmllint-matcher.json | 16 + 8 files changed, 801 insertions(+) create mode 100644 .github/workflows/lint.yml create mode 100644 README.md create mode 100644 action.yml create mode 100755 index.js create mode 100644 test/error.xml create mode 100644 test/info.xml create mode 100644 test/info.xsd create mode 100644 xmllint-matcher.json diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..1eb283f --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,22 @@ +name: Test +on: + push: + branches: + - master + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@master + - name: Setup xmllint + run: sudo apt-get install --no-install-recommends -y libxml2-utils + - name: add problem matcher for xmllint + run: ./index.js + - name: lint XML file with syntax error + run: xmllint test/error.xml --schema test/info.xsd --noout || true + - name: lint XML file with schema error + run: xmllint test/info.xml --schema test/info.xsd --noout || true + diff --git a/README.md b/README.md new file mode 100644 index 0000000..7e26e3e --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# xmllint-problem-matcher + +This problem matcher lets you show errors from `xmllint` as annotation in GitHub Actions. + +## Usage + +Add the step to your workflow, before PHPUnit is called. + +```yaml + - uses: korelstar/xmllint-problem-matcher@v1 +``` diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..7d03b90 --- /dev/null +++ b/action.yml @@ -0,0 +1,9 @@ +name: 'xmllint problem matcher' +author: 'Kristof Hamann' +description: 'Shows xmllint errors as annotation (with file and code line) in GitHub Actions' +runs: + using: 'node12' + main: 'index.js' +branding: + icon: 'check-square' + color: 'green' diff --git a/index.js b/index.js new file mode 100755 index 0000000..de9f08b --- /dev/null +++ b/index.js @@ -0,0 +1,2 @@ +#!/usr/bin/env node +console.log(`::add-matcher::${__dirname}/xmllint-matcher.json`); diff --git a/test/error.xml b/test/error.xml new file mode 100644 index 0000000..7487ef4 --- /dev/null +++ b/test/error.xml @@ -0,0 +1,12 @@ + + + uniqueid + App name + This is for test + + agpl + 1.4 + diff --git a/test/info.xml b/test/info.xml new file mode 100644 index 0000000..4d7e92b --- /dev/null +++ b/test/info.xml @@ -0,0 +1,12 @@ + + + testid + App + This is a summary + + agpl + 1.4 + diff --git a/test/info.xsd b/test/info.xsd new file mode 100644 index 0000000..a9b373d --- /dev/null +++ b/test/info.xsd @@ -0,0 +1,717 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xmllint-matcher.json b/xmllint-matcher.json new file mode 100644 index 0000000..af8fed8 --- /dev/null +++ b/xmllint-matcher.json @@ -0,0 +1,16 @@ +{ + "problemMatcher": [ + { + "owner": "xmllint-matcher", + "pattern": [ + { + "regexp": "^(.+):(\\d+):\\s+(.+)\\s+:\\s+(.+)$", + "file": 1, + "line": 2, + "code": 3, + "message": 4 + } + ] + } + ] +}