Skip to content

Commit

Permalink
break json schema
Browse files Browse the repository at this point in the history
  • Loading branch information
albertmink committed Dec 11, 2023
1 parent 9a544ab commit 90e739b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 23 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/generate.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: Validate JSON schema
name: Generate JSON Schema

on:
pull_request:

jobs:
validate:
name: Compare generated against provided
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
Expand All @@ -20,6 +21,7 @@ jobs:
cd generate
npm run generate
- name: Upload generated schemas
if: always()
uses: actions/upload-artifact@v3
with:
name: schemas
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/markdown-link-check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check Markdown links
name: Check Markdown Links

on:
pull_request:
Expand All @@ -7,7 +7,8 @@ permissions:
contents: read

jobs:
markdown-link-check:
check-links:
name: Check links
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/py-validation.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Validate JSON examples
name: Validate JSON Examples

on:
pull_request:
Expand All @@ -9,7 +9,7 @@ permissions:
jobs:
build:
# Name the Job
name: Validate JSON examples against their schema
name: Validate examples against schema

runs-on: ubuntu-latest

Expand Down
2 changes: 1 addition & 1 deletion file-formats/intf/intf-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/SAP/abap-file-formats/blob/main/file-formats/intf/intf-v1.json",
"title": "Interface Properties",
"description": "My Interface properties",
"description": "Interface properties",
"type": "object",
"properties": {
"formatVersion": {
Expand Down
33 changes: 16 additions & 17 deletions generate/aff.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as fs from 'node:fs';
import * as path from 'node:path';
import * as child_process from 'node:child_process';
import {initializeABAP} from "./output/init.mjs";
import { initializeABAP } from "./output/init.mjs";
await initializeABAP();
import * as core from '@actions/core';

Expand All @@ -14,21 +14,18 @@ async function run() {
let lines = diff.split('\n');

let lineNumber;
for (let i = 0; i < lines.length; i++) {
const regExp = /^[0-9]/;
const regExp = /^[0-9]/;

lines.forEach(line => {

let line = lines[i];
if (line.startsWith('>')) {
let text = line.split(' ').slice(1).join(' ');
console.log(`::warning file=${file},line=${lineNumber}::${text}`);
++lineNumber;
let text = line.split(' ').slice(1).join(' ');
console.log(`::error file=${file},line=${lineNumber}::${text}`);
++lineNumber;
} else if (regExp.test(line)) {
lineNumber = parseInt(line.split("c")[0].split(",")[0]); // 16
//core.info(lineNumber);
} else if (line.startsWith("<")) {

}
}
});

}

Expand All @@ -45,23 +42,25 @@ async function run() {
let error = false;
for (const type of types) {
if (type === "ENHO") {
core.notice(type+" skipped, https://github.com/SAP/abap-file-formats/issues/409");
core.notice(type + " skipped, https://github.com/SAP/abap-file-formats/issues/409");
continue;
}

const result = await abap.Classes["CL_RUN"].run({object_type: new abap.types.String().set(type)});
const result = await abap.Classes["CL_RUN"].run({ object_type: new abap.types.String().set(type) });
const filename = "generated" + path.sep + type.toLowerCase() + "-v1.json";
const filename_aff = `../file-formats/${type.toLowerCase()}/${type.toLowerCase()}-v1.json`;
fs.writeFileSync(filename, result.get());


const command = `diff ${filename} ${filename_aff}`;
const command = `diff ${filename_aff} ${filename}`;
const output = child_process.execSync(`${command} || true`);
if (output.toString().length > 0) {
core.setFailed(type+": Provided and generated JSON Schema differ")
core.info(command);
core.info(output.toString());
core.setFailed(type + ": Provided and generated JSON Schema differ")
createAnnotations(output.toString(), path.resolve(filename_aff));
//core.info(command);
//core.info(output.toString());
} else {
core.notice(type + " success");
}

}
Expand Down

0 comments on commit 90e739b

Please sign in to comment.