From c85bbb31899520f82158bbaf0dcc2b8afd1b09c9 Mon Sep 17 00:00:00 2001 From: Maksim Sadym Date: Fri, 2 Dec 2022 15:34:57 +0100 Subject: [PATCH] Add checks --- .github/workflows/test.yml | 9 +++++++++ scripts/formatter/no_split_var.js | 7 ++----- scripts/test.sh | 3 --- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5a91533e5..b9c66819c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,3 +49,12 @@ jobs: with: name: cddl path: "*.cddl" + no-split-vars: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 14.x + - name: Check no break lines inside blocks + run: node ./scripts/formatter/no_split_var.js diff --git a/scripts/formatter/no_split_var.js b/scripts/formatter/no_split_var.js index 7fbf3ad45..9e7f6f13d 100644 --- a/scripts/formatter/no_split_var.js +++ b/scripts/formatter/no_split_var.js @@ -1,9 +1,7 @@ #!/usr/bin/env node const fs = require('fs') -const path = require('path') -const specPath = path.resolve(__dirname, '..', '..', 'index.bs') -const specLines = fs.readFileSync(specPath, 'utf-8') +const specLines = fs.readFileSync('../../index.bs', 'utf-8') .toString() .split('\n'); @@ -15,8 +13,7 @@ for (let i = 0; i < specLines.length; i++) { for (let pair of openClosePairs) { if (line.lastIndexOf(pair[0]) > line.lastIndexOf(pair[1])) { failed.push( - `Unclosed ${line.substring(line.lastIndexOf(pair[0]))} at line ${i - + 1}`) + `Unclosed ${line.substring(line.lastIndexOf(pair[0]))} at line ${i+ 1}`) } } diff --git a/scripts/test.sh b/scripts/test.sh index 776912ffb..e5d837291 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -19,6 +19,3 @@ $ROOT/scripts/cddl/generate.js cddl compile-cddl --cddl local.cddl cddl compile-cddl --cddl remote.cddl - -# Check break lines inside blocks. -$ROOT/scripts/formatter/no_split_var.js