forked from SAP/abap-file-formats
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
442 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Compatability Check | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
compatible: | ||
name: Is change compatible | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-node@v4 | ||
- name: Run script | ||
run: | | ||
cd compatibility-check | ||
npm ci | ||
npm run check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
const jsonSchemaDiff = require('json-schema-diff') | ||
const exec = require('@actions/exec'); | ||
const core = require('@actions/core'); | ||
const {readFileSync} = require('node:fs'); | ||
|
||
|
||
|
||
|
||
|
||
async function run() { | ||
|
||
let stdout = ''; | ||
const options = { | ||
listeners: { | ||
stdout: (data) => { | ||
stdout += data.toString(); | ||
}, | ||
stderr: (data) => { | ||
core.error(data.toString()); | ||
} | ||
} | ||
}; | ||
|
||
await exec.exec('git diff --name-only remotes/origin/main..HEAD', [], options); | ||
|
||
const pattern = new RegExp('file-formats/[a-z]{4}/[a-z]+-v[0-9]+\.json$', 'i'); | ||
const lines = stdout.split("\n"); | ||
|
||
const changedSchema = lines.filter(line => pattern.test(line)); | ||
|
||
|
||
for (const schema of changedSchema) { | ||
|
||
const dataNew = readFileSync(`../${schema}`, 'utf8'); | ||
const schemaNew = JSON.parse(dataNew); | ||
|
||
try { | ||
await exec.exec(`git checkout remotes/origin/main -- `, [schema], { cwd: `../`} ); | ||
} catch (error) { | ||
core.info(`File ${schema} is not known to main branch.`); | ||
continue; | ||
} | ||
|
||
const dataOld = readFileSync(`../${schema}`, 'utf8'); | ||
const schemaOld = JSON.parse(dataOld); | ||
|
||
delete schemaOld['$schema']; | ||
delete schemaNew['$schema']; | ||
|
||
const result = await jsonSchemaDiff.diffSchemas( {sourceSchema: schemaOld, destinationSchema: schemaNew}); | ||
if (result.removalsFound) { | ||
core.setFailed('Something was removed'); | ||
} | ||
|
||
if (result.additionsFound) { | ||
core.setFailed('Something was added'); | ||
}; | ||
} | ||
} | ||
|
||
run(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "json-schema-compatible", | ||
"version": "1.0.0", | ||
"description": "checks for incompatible changes in JSON Schema", | ||
"main": "json-schema-diff.js", | ||
"scripts": { | ||
"check": "node json-schema-diff" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@actions/core": "^1.10.1", | ||
"@actions/exec": "^1.1.1", | ||
"json-schema-diff": "^0.18.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.