Skip to content

Dev #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .github/workflows/spellcheck.yaml → .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Continuos Integration
name: Continuous Integration
on: # rebuild any PRs and main branch changes
pull_request:

@@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: streetsidesoftware/cspell-action@v1.0.1
- uses: streetsidesoftware/cspell-action@v1.6.2
lint-format: # run the action
runs-on: ubuntu-latest
steps:
@@ -18,3 +18,16 @@ jobs:
- name: Check Format
run: |
npm run check:format
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
npm ci
- name: Prep container
run: |
npm run build:test-container
- name: Test
run: |
npm run test
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ Example:

[cfn-lint]: https://github.com/aws-cloudformation/cfn-python-lint

![An example of the CLI output](https://github.com/Graham42/cfn-lint-to-codeframe/blob/main/error-ouput.jpg?raw=true)
![An example of the CLI output](https://github.com/Graham42/cfn-lint-to-codeframe/blob/main/error-output.jpg?raw=true)

## Installation

8 changes: 6 additions & 2 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"version": "0.1",
"allowCompoundWords": true
"version": "0.2",
"allowCompoundWords": true,
"words": [
//
"McGregor"
]
}
File renamed without changes
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -6,7 +6,9 @@
"prettier": "prettier --ignore-path .gitignore \"**/*.{js,jsx,ts,tsx,html,vue,css,less,scss,graphql,yaml,yml,json,json5,md,mdx}\"",
"check:format": "npm run prettier -- --check",
"fix:format": "npm run prettier -- --write",
"test": "echo \"Error: no test specified\" && exit 1"
"build:test-container": "docker build --progress=plain -f ./test/test.Dockerfile -t test-container .",
"test": "npm run build:test-container && docker run --rm -t -v $(pwd):/work -w /work test-container ./test/test.sh",
"test:debug": "npm run build:test-container && docker run --rm -t -v $(pwd):/work -w /work -e DEBUG=true test-container ./test/test.sh"
},
"main": "src/index.js",
"bin": "src/index.js",
7 changes: 1 addition & 6 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -36,11 +36,6 @@ async function main() {
try {
err = parse(line);
} catch (err) {
if (process.env.DEBUG) {
errorLog(
`Caught ${err}, assuming that the line should be part of the previous error message`,
);
}
// if there's no previous error then this seems like a real error
if (result.length < 1) {
errorLog(`Error parsing line: ${line}`);
@@ -63,7 +58,7 @@ async function main() {
const result = codeFrameColumns(contents, location, {
highlightCode: true,
});
console.log(chalk.bgGray(err.fileName));
console.log(chalk.gray(err.fileName));
console.log(" " + chalk.red.bold(err.message));
if (err.fileName.endsWith(".json")) {
let path = getJsonPathFromRawLocation(contents, err.start);
16 changes: 0 additions & 16 deletions test.sh

This file was deleted.

5 changes: 0 additions & 5 deletions test/python-err.sh

This file was deleted.

9 changes: 9 additions & 0 deletions test/test-python-err.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -e

./test/python-err.py 2>&1 | ./src/index.js > /dev/null
if [ $? -ne 0 ]; then
echo "Error with handling python error" >&2
exit 1
fi
17 changes: 17 additions & 0 deletions test/test-template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

template="$1"
if [ -z "$template" ]; then
echo "Missing template parameter" >&2
exit 1
fi

parseable_output=$(cfn-lint -t "${template}" -f parseable)
if [ -n "$DEBUG" ]; then
echo "$parseable_output" | ./src/index.js
fi
echo "$parseable_output" | ./src/index.js >/dev/null
if [ $? -ne 0 ]; then
echo "Error with $template"
exit 1
fi
14 changes: 14 additions & 0 deletions test/test.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:16-slim

RUN apt-get update && \
apt-get install -y \
python3 \
python3-pip \
&& \
ln -s /usr/bin/python3 /usr/bin/python && \
ln -s /usr/bin/pip3 /usr/bin/pip && \
python --version

RUN pip install cfn-lint

ENTRYPOINT ["bash"]
11 changes: 11 additions & 0 deletions test/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -e -o pipefail

find test/ -name '*.yaml' -o -name '*.json' -print0 | xargs -0 -L1 -I{} ./test/test-template.sh {}

if [ -n "$DEBUG" ]; then
./test/test-python-err.sh
fi

echo "Test complete!"