Workflow to publish schemas - #4139

Closed
ralfhandl wants to merge 13 commits into
OAI:mainfrom
ralfhandl:publish-schemas
Closed

Workflow to publish schemas#4139
ralfhandl wants to merge 13 commits into
OAI:mainfrom
ralfhandl:publish-schemas

Conversation

@ralfhandl

@ralfhandlralfhandl commented Oct 16, 2024

Copy link
Copy Markdown
Contributor
  • GitHub workflow
  • bash script called from workflow
  • JS script to convert YAML to JSON and patch iteration date
  • unit tests for JS script
  • Align with outcome of
  • Dependencies between schema files:
    • if meta changes, republish all four files
    • if dialect changes, republish it, schema, and schema_base
    • if schema changes, republish it and schema_base
    • if schema_base changes, republish it
    • new date stamp is maximum date of last commit in the dependency chain
flowchart LR
schema_base
schema
dialect
meta
schema --> |default| dialect
schema_base --> |$ref| schema
schema_base --> |$ref| dialect
dialect --> |$ref| meta
Loading

Example PR created by this workflow

@handrewshandrews added Schema changes related to the schema(s) script Pull requests that update Bash or JavaScript code labels Oct 16, 2024
@ralfhandl
ralfhandl marked this pull request as ready for review October 17, 2024 10:00
@ralfhandl
ralfhandl requested review from a team as code ownersOctober 17, 2024 10:00
@karenetheridge

karenetheridge commented Oct 17, 2024

Copy link
Copy Markdown
Member

to confirm, these are both edited in the files?

  • dates in the $id keywords
  • $comment links in each definition, that currently go to the 3.1.0 spec and should go to 3.1.1

@ralfhandl

Copy link
Copy Markdown
ContributorAuthor
  • What about the dates in the $ids?

Those are replaced when converting from YAML to JSON, see example PR https://github.com/ralfhandl/OpenAPI-Specification/pull/26/files

@ralfhandl

ralfhandl commented Oct 17, 2024

Copy link
Copy Markdown
ContributorAuthor
  • What about the description links in each definition, that currently go to the 3.1.0 spec and should go to 3.1.1?

These need to be adjusted manually. Changing them in main will then trigger the schema-publish workflow.

@handrewshandrews left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this work! To the extend that I understand current JavaScript, this looks great.

However, I'd like to merge #4146 and update this PR accordingly before publishing any new schemas. Let's make sure that when we resume publication after such a long gap, the first newly-published schemas are what we want.

Unfortunately, this does introduce a complexity, which is that the various 3.1 schema resources (of which there are four) can change independently. Ideally, we would only re-publish and update the $id for each when it changes, although it would not be the end of the world to just publish all four at once with the same updated data whenever any of them change. For the first publication, we'll need to do that anyway, so perhaps supporting independent updating can be something for later to keep the immediate work manageable?

I believe that the search-and-replace could just become a global grep for WORK-IN-PROGRESS once #4146 is merged, rather than worrying about parsing anything. We'd have to know not to put "WORK-IN-PROGRESS" anywhere else in the schemas, but that shouldn't be too hard to document.

It's worth noting that there are more places than id, $id, and $ref where the replacement needs to be done, so a global grep for a unique token would be more robust anyway.

@handrews

handrews commented Oct 22, 2024

Copy link
Copy Markdown
Member

@ralfhandl I realize I am asking for a substantially more complex workflow, so I took a pass at it. I was going to use the "suggest" feature on this PR but... my JavaScript skills are very poor and my bash skills are atrocious.

So here's something that I got working locally that you can use as a proof-of-concept (it doesn't update the markdown but I'm not quite sure what's going on there and I think this should get the point across). Or if you'd prefer, I can try to clean this up and submit it myself. I'm also happy to help with updates to the spec site for the date-using vocabulary and dialect schemas.

In local testing it handled various combinations of only certain schemas being updated correctly, including all updated, only the schema updated (but for both versions) and having the vocab and/or dialect schema changes cause further updates.

thisCommit="$GITHUB_SHA"# Note that for 3.0, "noDialectSchema" is the only schema
noDialectWIP="schema/WORK-IN-PROGRESS"
vocabWIP="meta/WORK-IN-PROGRESS"
dialectWIP="dialect/WORK-IN-PROGRESS"
strictDialectWIP="schema-base/WORK-IN-PROGRESS"forschemaDirin schemas/v3*;do
version=$(basename "$schemaDir")
noDialectSchema="$schemaDir/schema.yaml"
vocabSchema="$schemaDir/meta/base.schema.yaml"
dialectSchema="$schemaDir/dialect/base.schema.yaml"
strictDialectSchema="$schemaDir/schema-base.yaml"echo$noDialectSchemaecho$vocabSchemaecho$dialectSchemaecho$strictDialectSchemaecho""if [ -f"$noDialectSchema" ];then
noDialectCommit=$(git log -1 --format="%H" -- "$noDialectSchema")
noDialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$noDialectSchema")if [ "$noDialectCommit"="$thisCommit" ];then
updateNoDialect="1"fifiif [ -f"$vocabSchema" ];then
vocabCommit=$(git log -1 --format="%H" -- "$vocabSchema")
vocabCommitDate=$(git log -1 --format="%ad" --date=short -- "$vocabSchema")if [ "$vocabCommit"="$thisCommit" ];then
updateVocab="1"fifiif [ -f"$dialectSchema" ];then
dialectCommit=$(git log -1 --format="%H" -- "$dialectSchema")
dialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$dialectSchema")
updateDialect="$updateVocab"if [ "$dialectCommit"="$thisCommit" ];then
updateDialect="1"fifiif [ -f"$strictDialectSchema" ];then
strictDialectCommit=$(git log -1 --format="%H" -- "$strictDialectSchema")
strictDialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$strictDialectSchema")
updateStrictDialect="$updateDialect"if [ -n"$updateNoDialect" ];then
updateStrictDialect="1"fiif [ "$strictDialectCommit"="$thisCommit" ];then
updateStrictDialect="1"fifiecho$thisCommitecho$version$noDialectCommit$noDialectCommitDate$updateNoDialectecho$version$vocabCommit$vocabCommitDate$updateVocabecho$version$dialectCommit$dialectCommitDate$updateDialectecho$version$strictDialectCommit$strictDialectCommitDate$updateStrictDialectecho""
mkdir -p deploy/oas/$version/schema
if [ -f"$vocabSchema" ];then
mkdir -p deploy/oas/$version/meta
mkdir -p deploy/oas/$version/dialect
if [ -n"$updateNoDialect" ];then
node scripts/schema-convert.js "$noDialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/schema/$noDialectCommitDatefiif [ -n"$updateVocab" ];then
node scripts/schema-convert.js "$vocabSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/meta/$vocabCommitDatefiif [ -n"$updateDialect" ];then
node scripts/schema-convert.js "$dialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/dialect/$dialectCommitDatefiif [ -n"$updateStrictDialect" ];then
node scripts/schema-convert.js "$strictDialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/schema-base/$strictDialectCommitDatefielseif [ -n"$updateNoDialect" ];then
node scripts/schema-convert.js "$noDialectSchema"$noDialectCommitDate> deploy/oas/$version/schema/$noDialectCommitDatefifidone
#!/usr/bin/env node
'use strict';constfs=require('fs');constyaml=require('yaml');functionconvert(filename,noDialectDate,vocabDate=false,dialectDate=false,strictDialectDate=false,){try{vars=fs.readFileSync(filename,'utf8');s=s.replace(/schema\/WORK-IN-PROGRESS/g,'schema/'+noDialectDate,);if(vocabDate){s=s.replace(/meta\/WORK-IN-PROGRESS/g,'meta/'+vocabDate,);}if(dialectDate){s=s.replace(/dialect\/WORK-IN-PROGRESS/g,'dialect/'+dialectDate,);}if(strictDialectDate){s=s.replace(/schema-base\/WORK-IN-PROGRESS/g,'schema-base/'+strictDialectDate,);}constobj=yaml.parse(s,{prettyErrors: true});console.log(JSON.stringify(obj,null,2));}catch(ex){console.warn(' ',ex.message);process.exitCode=1;}}if(process.argv.length<4){console.warn('Usage: convert-schema.js file.yaml YYYY-MM-DD [YYYY-MM-DD YYYY-MM-DD YYYY-MM-DD]');}else{if(process.argv.length>4){convert(process.argv[2],process.argv[3],process.argv[4],process.argv[5],process.argv[6]);}else{convert(process.argv[2],process.argv[3]);}}

@ralfhandl

Copy link
Copy Markdown
ContributorAuthor

@handrews Thanks, will look into this once #4146 is merged.

@ralfhandl
ralfhandl deleted the publish-schemas branch October 25, 2024 13:55
@ralfhandl

Copy link
Copy Markdown
ContributorAuthor

Replaced with simpler approach:

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Schemachanges related to the schema(s)scriptPull requests that update Bash or JavaScript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@ralfhandl@karenetheridge@handrews
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Workflow to publish schemas - #4139

Closed
ralfhandl wants to merge 13 commits into
OAI:mainfrom
ralfhandl:publish-schemas
Closed

Workflow to publish schemas#4139
ralfhandl wants to merge 13 commits into
OAI:mainfrom
ralfhandl:publish-schemas

Conversation

@ralfhandl

@ralfhandlralfhandl commented Oct 16, 2024

Copy link
Copy Markdown
Contributor
  • GitHub workflow
  • bash script called from workflow
  • JS script to convert YAML to JSON and patch iteration date
  • unit tests for JS script
  • Align with outcome of
  • Dependencies between schema files:
    • if meta changes, republish all four files
    • if dialect changes, republish it, schema, and schema_base
    • if schema changes, republish it and schema_base
    • if schema_base changes, republish it
    • new date stamp is maximum date of last commit in the dependency chain
flowchart LR
schema_base
schema
dialect
meta
schema --> |default| dialect
schema_base --> |$ref| schema
schema_base --> |$ref| dialect
dialect --> |$ref| meta
Loading

Example PR created by this workflow

@handrewshandrews added Schema changes related to the schema(s) script Pull requests that update Bash or JavaScript code labels Oct 16, 2024
@ralfhandl
ralfhandl marked this pull request as ready for review October 17, 2024 10:00
@ralfhandl
ralfhandl requested review from a team as code ownersOctober 17, 2024 10:00
@karenetheridge

karenetheridge commented Oct 17, 2024

Copy link
Copy Markdown
Member

to confirm, these are both edited in the files?

  • dates in the $id keywords
  • $comment links in each definition, that currently go to the 3.1.0 spec and should go to 3.1.1

@ralfhandl

Copy link
Copy Markdown
ContributorAuthor
  • What about the dates in the $ids?

Those are replaced when converting from YAML to JSON, see example PR https://github.com/ralfhandl/OpenAPI-Specification/pull/26/files

@ralfhandl

ralfhandl commented Oct 17, 2024

Copy link
Copy Markdown
ContributorAuthor
  • What about the description links in each definition, that currently go to the 3.1.0 spec and should go to 3.1.1?

These need to be adjusted manually. Changing them in main will then trigger the schema-publish workflow.

@handrewshandrews left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this work! To the extend that I understand current JavaScript, this looks great.

However, I'd like to merge #4146 and update this PR accordingly before publishing any new schemas. Let's make sure that when we resume publication after such a long gap, the first newly-published schemas are what we want.

Unfortunately, this does introduce a complexity, which is that the various 3.1 schema resources (of which there are four) can change independently. Ideally, we would only re-publish and update the $id for each when it changes, although it would not be the end of the world to just publish all four at once with the same updated data whenever any of them change. For the first publication, we'll need to do that anyway, so perhaps supporting independent updating can be something for later to keep the immediate work manageable?

I believe that the search-and-replace could just become a global grep for WORK-IN-PROGRESS once #4146 is merged, rather than worrying about parsing anything. We'd have to know not to put "WORK-IN-PROGRESS" anywhere else in the schemas, but that shouldn't be too hard to document.

It's worth noting that there are more places than id, $id, and $ref where the replacement needs to be done, so a global grep for a unique token would be more robust anyway.

@handrews

handrews commented Oct 22, 2024

Copy link
Copy Markdown
Member

@ralfhandl I realize I am asking for a substantially more complex workflow, so I took a pass at it. I was going to use the "suggest" feature on this PR but... my JavaScript skills are very poor and my bash skills are atrocious.

So here's something that I got working locally that you can use as a proof-of-concept (it doesn't update the markdown but I'm not quite sure what's going on there and I think this should get the point across). Or if you'd prefer, I can try to clean this up and submit it myself. I'm also happy to help with updates to the spec site for the date-using vocabulary and dialect schemas.

In local testing it handled various combinations of only certain schemas being updated correctly, including all updated, only the schema updated (but for both versions) and having the vocab and/or dialect schema changes cause further updates.

thisCommit="$GITHUB_SHA"# Note that for 3.0, "noDialectSchema" is the only schema
noDialectWIP="schema/WORK-IN-PROGRESS"
vocabWIP="meta/WORK-IN-PROGRESS"
dialectWIP="dialect/WORK-IN-PROGRESS"
strictDialectWIP="schema-base/WORK-IN-PROGRESS"forschemaDirin schemas/v3*;do
version=$(basename "$schemaDir")
noDialectSchema="$schemaDir/schema.yaml"
vocabSchema="$schemaDir/meta/base.schema.yaml"
dialectSchema="$schemaDir/dialect/base.schema.yaml"
strictDialectSchema="$schemaDir/schema-base.yaml"echo$noDialectSchemaecho$vocabSchemaecho$dialectSchemaecho$strictDialectSchemaecho""if [ -f"$noDialectSchema" ];then
noDialectCommit=$(git log -1 --format="%H" -- "$noDialectSchema")
noDialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$noDialectSchema")if [ "$noDialectCommit"="$thisCommit" ];then
updateNoDialect="1"fifiif [ -f"$vocabSchema" ];then
vocabCommit=$(git log -1 --format="%H" -- "$vocabSchema")
vocabCommitDate=$(git log -1 --format="%ad" --date=short -- "$vocabSchema")if [ "$vocabCommit"="$thisCommit" ];then
updateVocab="1"fifiif [ -f"$dialectSchema" ];then
dialectCommit=$(git log -1 --format="%H" -- "$dialectSchema")
dialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$dialectSchema")
updateDialect="$updateVocab"if [ "$dialectCommit"="$thisCommit" ];then
updateDialect="1"fifiif [ -f"$strictDialectSchema" ];then
strictDialectCommit=$(git log -1 --format="%H" -- "$strictDialectSchema")
strictDialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$strictDialectSchema")
updateStrictDialect="$updateDialect"if [ -n"$updateNoDialect" ];then
updateStrictDialect="1"fiif [ "$strictDialectCommit"="$thisCommit" ];then
updateStrictDialect="1"fifiecho$thisCommitecho$version$noDialectCommit$noDialectCommitDate$updateNoDialectecho$version$vocabCommit$vocabCommitDate$updateVocabecho$version$dialectCommit$dialectCommitDate$updateDialectecho$version$strictDialectCommit$strictDialectCommitDate$updateStrictDialectecho""
mkdir -p deploy/oas/$version/schema
if [ -f"$vocabSchema" ];then
mkdir -p deploy/oas/$version/meta
mkdir -p deploy/oas/$version/dialect
if [ -n"$updateNoDialect" ];then
node scripts/schema-convert.js "$noDialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/schema/$noDialectCommitDatefiif [ -n"$updateVocab" ];then
node scripts/schema-convert.js "$vocabSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/meta/$vocabCommitDatefiif [ -n"$updateDialect" ];then
node scripts/schema-convert.js "$dialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/dialect/$dialectCommitDatefiif [ -n"$updateStrictDialect" ];then
node scripts/schema-convert.js "$strictDialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/schema-base/$strictDialectCommitDatefielseif [ -n"$updateNoDialect" ];then
node scripts/schema-convert.js "$noDialectSchema"$noDialectCommitDate> deploy/oas/$version/schema/$noDialectCommitDatefifidone
#!/usr/bin/env node
'use strict';constfs=require('fs');constyaml=require('yaml');functionconvert(filename,noDialectDate,vocabDate=false,dialectDate=false,strictDialectDate=false,){try{vars=fs.readFileSync(filename,'utf8');s=s.replace(/schema\/WORK-IN-PROGRESS/g,'schema/'+noDialectDate,);if(vocabDate){s=s.replace(/meta\/WORK-IN-PROGRESS/g,'meta/'+vocabDate,);}if(dialectDate){s=s.replace(/dialect\/WORK-IN-PROGRESS/g,'dialect/'+dialectDate,);}if(strictDialectDate){s=s.replace(/schema-base\/WORK-IN-PROGRESS/g,'schema-base/'+strictDialectDate,);}constobj=yaml.parse(s,{prettyErrors: true});console.log(JSON.stringify(obj,null,2));}catch(ex){console.warn(' ',ex.message);process.exitCode=1;}}if(process.argv.length<4){console.warn('Usage: convert-schema.js file.yaml YYYY-MM-DD [YYYY-MM-DD YYYY-MM-DD YYYY-MM-DD]');}else{if(process.argv.length>4){convert(process.argv[2],process.argv[3],process.argv[4],process.argv[5],process.argv[6]);}else{convert(process.argv[2],process.argv[3]);}}

@ralfhandl

Copy link
Copy Markdown
ContributorAuthor

@handrews Thanks, will look into this once #4146 is merged.

@ralfhandl
ralfhandl deleted the publish-schemas branch October 25, 2024 13:55
@ralfhandl

Copy link
Copy Markdown
ContributorAuthor

Replaced with simpler approach:

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Schemachanges related to the schema(s)scriptPull requests that update Bash or JavaScript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@ralfhandl@karenetheridge@handrews
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Workflow to publish schemas - #4139

Closed
ralfhandl wants to merge 13 commits into
OAI:mainfrom
ralfhandl:publish-schemas
Closed

Workflow to publish schemas#4139
ralfhandl wants to merge 13 commits into
OAI:mainfrom
ralfhandl:publish-schemas

Conversation

@ralfhandl

@ralfhandlralfhandl commented Oct 16, 2024

Copy link
Copy Markdown
Contributor
  • GitHub workflow
  • bash script called from workflow
  • JS script to convert YAML to JSON and patch iteration date
  • unit tests for JS script
  • Align with outcome of
  • Dependencies between schema files:
    • if meta changes, republish all four files
    • if dialect changes, republish it, schema, and schema_base
    • if schema changes, republish it and schema_base
    • if schema_base changes, republish it
    • new date stamp is maximum date of last commit in the dependency chain
flowchart LR
schema_base
schema
dialect
meta
schema --> |default| dialect
schema_base --> |$ref| schema
schema_base --> |$ref| dialect
dialect --> |$ref| meta
Loading

Example PR created by this workflow

@handrewshandrews added Schema changes related to the schema(s) script Pull requests that update Bash or JavaScript code labels Oct 16, 2024
@ralfhandl
ralfhandl marked this pull request as ready for review October 17, 2024 10:00
@ralfhandl
ralfhandl requested review from a team as code ownersOctober 17, 2024 10:00
@karenetheridge

karenetheridge commented Oct 17, 2024

Copy link
Copy Markdown
Member

to confirm, these are both edited in the files?

  • dates in the $id keywords
  • $comment links in each definition, that currently go to the 3.1.0 spec and should go to 3.1.1

@ralfhandl

Copy link
Copy Markdown
ContributorAuthor
  • What about the dates in the $ids?

Those are replaced when converting from YAML to JSON, see example PR https://github.com/ralfhandl/OpenAPI-Specification/pull/26/files

@ralfhandl

ralfhandl commented Oct 17, 2024

Copy link
Copy Markdown
ContributorAuthor
  • What about the description links in each definition, that currently go to the 3.1.0 spec and should go to 3.1.1?

These need to be adjusted manually. Changing them in main will then trigger the schema-publish workflow.

@handrewshandrews left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this work! To the extend that I understand current JavaScript, this looks great.

However, I'd like to merge #4146 and update this PR accordingly before publishing any new schemas. Let's make sure that when we resume publication after such a long gap, the first newly-published schemas are what we want.

Unfortunately, this does introduce a complexity, which is that the various 3.1 schema resources (of which there are four) can change independently. Ideally, we would only re-publish and update the $id for each when it changes, although it would not be the end of the world to just publish all four at once with the same updated data whenever any of them change. For the first publication, we'll need to do that anyway, so perhaps supporting independent updating can be something for later to keep the immediate work manageable?

I believe that the search-and-replace could just become a global grep for WORK-IN-PROGRESS once #4146 is merged, rather than worrying about parsing anything. We'd have to know not to put "WORK-IN-PROGRESS" anywhere else in the schemas, but that shouldn't be too hard to document.

It's worth noting that there are more places than id, $id, and $ref where the replacement needs to be done, so a global grep for a unique token would be more robust anyway.

@handrews

handrews commented Oct 22, 2024

Copy link
Copy Markdown
Member

@ralfhandl I realize I am asking for a substantially more complex workflow, so I took a pass at it. I was going to use the "suggest" feature on this PR but... my JavaScript skills are very poor and my bash skills are atrocious.

So here's something that I got working locally that you can use as a proof-of-concept (it doesn't update the markdown but I'm not quite sure what's going on there and I think this should get the point across). Or if you'd prefer, I can try to clean this up and submit it myself. I'm also happy to help with updates to the spec site for the date-using vocabulary and dialect schemas.

In local testing it handled various combinations of only certain schemas being updated correctly, including all updated, only the schema updated (but for both versions) and having the vocab and/or dialect schema changes cause further updates.

thisCommit="$GITHUB_SHA"# Note that for 3.0, "noDialectSchema" is the only schema
noDialectWIP="schema/WORK-IN-PROGRESS"
vocabWIP="meta/WORK-IN-PROGRESS"
dialectWIP="dialect/WORK-IN-PROGRESS"
strictDialectWIP="schema-base/WORK-IN-PROGRESS"forschemaDirin schemas/v3*;do
version=$(basename "$schemaDir")
noDialectSchema="$schemaDir/schema.yaml"
vocabSchema="$schemaDir/meta/base.schema.yaml"
dialectSchema="$schemaDir/dialect/base.schema.yaml"
strictDialectSchema="$schemaDir/schema-base.yaml"echo$noDialectSchemaecho$vocabSchemaecho$dialectSchemaecho$strictDialectSchemaecho""if [ -f"$noDialectSchema" ];then
noDialectCommit=$(git log -1 --format="%H" -- "$noDialectSchema")
noDialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$noDialectSchema")if [ "$noDialectCommit"="$thisCommit" ];then
updateNoDialect="1"fifiif [ -f"$vocabSchema" ];then
vocabCommit=$(git log -1 --format="%H" -- "$vocabSchema")
vocabCommitDate=$(git log -1 --format="%ad" --date=short -- "$vocabSchema")if [ "$vocabCommit"="$thisCommit" ];then
updateVocab="1"fifiif [ -f"$dialectSchema" ];then
dialectCommit=$(git log -1 --format="%H" -- "$dialectSchema")
dialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$dialectSchema")
updateDialect="$updateVocab"if [ "$dialectCommit"="$thisCommit" ];then
updateDialect="1"fifiif [ -f"$strictDialectSchema" ];then
strictDialectCommit=$(git log -1 --format="%H" -- "$strictDialectSchema")
strictDialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$strictDialectSchema")
updateStrictDialect="$updateDialect"if [ -n"$updateNoDialect" ];then
updateStrictDialect="1"fiif [ "$strictDialectCommit"="$thisCommit" ];then
updateStrictDialect="1"fifiecho$thisCommitecho$version$noDialectCommit$noDialectCommitDate$updateNoDialectecho$version$vocabCommit$vocabCommitDate$updateVocabecho$version$dialectCommit$dialectCommitDate$updateDialectecho$version$strictDialectCommit$strictDialectCommitDate$updateStrictDialectecho""
mkdir -p deploy/oas/$version/schema
if [ -f"$vocabSchema" ];then
mkdir -p deploy/oas/$version/meta
mkdir -p deploy/oas/$version/dialect
if [ -n"$updateNoDialect" ];then
node scripts/schema-convert.js "$noDialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/schema/$noDialectCommitDatefiif [ -n"$updateVocab" ];then
node scripts/schema-convert.js "$vocabSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/meta/$vocabCommitDatefiif [ -n"$updateDialect" ];then
node scripts/schema-convert.js "$dialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/dialect/$dialectCommitDatefiif [ -n"$updateStrictDialect" ];then
node scripts/schema-convert.js "$strictDialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/schema-base/$strictDialectCommitDatefielseif [ -n"$updateNoDialect" ];then
node scripts/schema-convert.js "$noDialectSchema"$noDialectCommitDate> deploy/oas/$version/schema/$noDialectCommitDatefifidone
#!/usr/bin/env node
'use strict';constfs=require('fs');constyaml=require('yaml');functionconvert(filename,noDialectDate,vocabDate=false,dialectDate=false,strictDialectDate=false,){try{vars=fs.readFileSync(filename,'utf8');s=s.replace(/schema\/WORK-IN-PROGRESS/g,'schema/'+noDialectDate,);if(vocabDate){s=s.replace(/meta\/WORK-IN-PROGRESS/g,'meta/'+vocabDate,);}if(dialectDate){s=s.replace(/dialect\/WORK-IN-PROGRESS/g,'dialect/'+dialectDate,);}if(strictDialectDate){s=s.replace(/schema-base\/WORK-IN-PROGRESS/g,'schema-base/'+strictDialectDate,);}constobj=yaml.parse(s,{prettyErrors: true});console.log(JSON.stringify(obj,null,2));}catch(ex){console.warn(' ',ex.message);process.exitCode=1;}}if(process.argv.length<4){console.warn('Usage: convert-schema.js file.yaml YYYY-MM-DD [YYYY-MM-DD YYYY-MM-DD YYYY-MM-DD]');}else{if(process.argv.length>4){convert(process.argv[2],process.argv[3],process.argv[4],process.argv[5],process.argv[6]);}else{convert(process.argv[2],process.argv[3]);}}

@ralfhandl

Copy link
Copy Markdown
ContributorAuthor

@handrews Thanks, will look into this once #4146 is merged.

@ralfhandl
ralfhandl deleted the publish-schemas branch October 25, 2024 13:55
@ralfhandl

Copy link
Copy Markdown
ContributorAuthor

Replaced with simpler approach:

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Schemachanges related to the schema(s)scriptPull requests that update Bash or JavaScript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@ralfhandl@karenetheridge@handrews
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Workflow to publish schemas - #4139

Closed
ralfhandl wants to merge 13 commits into
OAI:mainfrom
ralfhandl:publish-schemas
Closed

Workflow to publish schemas#4139
ralfhandl wants to merge 13 commits into
OAI:mainfrom
ralfhandl:publish-schemas

Conversation

@ralfhandl

@ralfhandlralfhandl commented Oct 16, 2024

Copy link
Copy Markdown
Contributor
  • GitHub workflow
  • bash script called from workflow
  • JS script to convert YAML to JSON and patch iteration date
  • unit tests for JS script
  • Align with outcome of
  • Dependencies between schema files:
    • if meta changes, republish all four files
    • if dialect changes, republish it, schema, and schema_base
    • if schema changes, republish it and schema_base
    • if schema_base changes, republish it
    • new date stamp is maximum date of last commit in the dependency chain
flowchart LR
schema_base
schema
dialect
meta
schema --> |default| dialect
schema_base --> |$ref| schema
schema_base --> |$ref| dialect
dialect --> |$ref| meta
Loading

Example PR created by this workflow

@handrewshandrews added Schema changes related to the schema(s) script Pull requests that update Bash or JavaScript code labels Oct 16, 2024
@ralfhandl
ralfhandl marked this pull request as ready for review October 17, 2024 10:00
@ralfhandl
ralfhandl requested review from a team as code ownersOctober 17, 2024 10:00
@karenetheridge

karenetheridge commented Oct 17, 2024

Copy link
Copy Markdown
Member

to confirm, these are both edited in the files?

  • dates in the $id keywords
  • $comment links in each definition, that currently go to the 3.1.0 spec and should go to 3.1.1

@ralfhandl

Copy link
Copy Markdown
ContributorAuthor
  • What about the dates in the $ids?

Those are replaced when converting from YAML to JSON, see example PR https://github.com/ralfhandl/OpenAPI-Specification/pull/26/files

@ralfhandl

ralfhandl commented Oct 17, 2024

Copy link
Copy Markdown
ContributorAuthor
  • What about the description links in each definition, that currently go to the 3.1.0 spec and should go to 3.1.1?

These need to be adjusted manually. Changing them in main will then trigger the schema-publish workflow.

@handrewshandrews left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this work! To the extend that I understand current JavaScript, this looks great.

However, I'd like to merge #4146 and update this PR accordingly before publishing any new schemas. Let's make sure that when we resume publication after such a long gap, the first newly-published schemas are what we want.

Unfortunately, this does introduce a complexity, which is that the various 3.1 schema resources (of which there are four) can change independently. Ideally, we would only re-publish and update the $id for each when it changes, although it would not be the end of the world to just publish all four at once with the same updated data whenever any of them change. For the first publication, we'll need to do that anyway, so perhaps supporting independent updating can be something for later to keep the immediate work manageable?

I believe that the search-and-replace could just become a global grep for WORK-IN-PROGRESS once #4146 is merged, rather than worrying about parsing anything. We'd have to know not to put "WORK-IN-PROGRESS" anywhere else in the schemas, but that shouldn't be too hard to document.

It's worth noting that there are more places than id, $id, and $ref where the replacement needs to be done, so a global grep for a unique token would be more robust anyway.

@handrews

handrews commented Oct 22, 2024

Copy link
Copy Markdown
Member

@ralfhandl I realize I am asking for a substantially more complex workflow, so I took a pass at it. I was going to use the "suggest" feature on this PR but... my JavaScript skills are very poor and my bash skills are atrocious.

So here's something that I got working locally that you can use as a proof-of-concept (it doesn't update the markdown but I'm not quite sure what's going on there and I think this should get the point across). Or if you'd prefer, I can try to clean this up and submit it myself. I'm also happy to help with updates to the spec site for the date-using vocabulary and dialect schemas.

In local testing it handled various combinations of only certain schemas being updated correctly, including all updated, only the schema updated (but for both versions) and having the vocab and/or dialect schema changes cause further updates.

thisCommit="$GITHUB_SHA"# Note that for 3.0, "noDialectSchema" is the only schema
noDialectWIP="schema/WORK-IN-PROGRESS"
vocabWIP="meta/WORK-IN-PROGRESS"
dialectWIP="dialect/WORK-IN-PROGRESS"
strictDialectWIP="schema-base/WORK-IN-PROGRESS"forschemaDirin schemas/v3*;do
version=$(basename "$schemaDir")
noDialectSchema="$schemaDir/schema.yaml"
vocabSchema="$schemaDir/meta/base.schema.yaml"
dialectSchema="$schemaDir/dialect/base.schema.yaml"
strictDialectSchema="$schemaDir/schema-base.yaml"echo$noDialectSchemaecho$vocabSchemaecho$dialectSchemaecho$strictDialectSchemaecho""if [ -f"$noDialectSchema" ];then
noDialectCommit=$(git log -1 --format="%H" -- "$noDialectSchema")
noDialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$noDialectSchema")if [ "$noDialectCommit"="$thisCommit" ];then
updateNoDialect="1"fifiif [ -f"$vocabSchema" ];then
vocabCommit=$(git log -1 --format="%H" -- "$vocabSchema")
vocabCommitDate=$(git log -1 --format="%ad" --date=short -- "$vocabSchema")if [ "$vocabCommit"="$thisCommit" ];then
updateVocab="1"fifiif [ -f"$dialectSchema" ];then
dialectCommit=$(git log -1 --format="%H" -- "$dialectSchema")
dialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$dialectSchema")
updateDialect="$updateVocab"if [ "$dialectCommit"="$thisCommit" ];then
updateDialect="1"fifiif [ -f"$strictDialectSchema" ];then
strictDialectCommit=$(git log -1 --format="%H" -- "$strictDialectSchema")
strictDialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$strictDialectSchema")
updateStrictDialect="$updateDialect"if [ -n"$updateNoDialect" ];then
updateStrictDialect="1"fiif [ "$strictDialectCommit"="$thisCommit" ];then
updateStrictDialect="1"fifiecho$thisCommitecho$version$noDialectCommit$noDialectCommitDate$updateNoDialectecho$version$vocabCommit$vocabCommitDate$updateVocabecho$version$dialectCommit$dialectCommitDate$updateDialectecho$version$strictDialectCommit$strictDialectCommitDate$updateStrictDialectecho""
mkdir -p deploy/oas/$version/schema
if [ -f"$vocabSchema" ];then
mkdir -p deploy/oas/$version/meta
mkdir -p deploy/oas/$version/dialect
if [ -n"$updateNoDialect" ];then
node scripts/schema-convert.js "$noDialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/schema/$noDialectCommitDatefiif [ -n"$updateVocab" ];then
node scripts/schema-convert.js "$vocabSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/meta/$vocabCommitDatefiif [ -n"$updateDialect" ];then
node scripts/schema-convert.js "$dialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/dialect/$dialectCommitDatefiif [ -n"$updateStrictDialect" ];then
node scripts/schema-convert.js "$strictDialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/schema-base/$strictDialectCommitDatefielseif [ -n"$updateNoDialect" ];then
node scripts/schema-convert.js "$noDialectSchema"$noDialectCommitDate> deploy/oas/$version/schema/$noDialectCommitDatefifidone
#!/usr/bin/env node
'use strict';constfs=require('fs');constyaml=require('yaml');functionconvert(filename,noDialectDate,vocabDate=false,dialectDate=false,strictDialectDate=false,){try{vars=fs.readFileSync(filename,'utf8');s=s.replace(/schema\/WORK-IN-PROGRESS/g,'schema/'+noDialectDate,);if(vocabDate){s=s.replace(/meta\/WORK-IN-PROGRESS/g,'meta/'+vocabDate,);}if(dialectDate){s=s.replace(/dialect\/WORK-IN-PROGRESS/g,'dialect/'+dialectDate,);}if(strictDialectDate){s=s.replace(/schema-base\/WORK-IN-PROGRESS/g,'schema-base/'+strictDialectDate,);}constobj=yaml.parse(s,{prettyErrors: true});console.log(JSON.stringify(obj,null,2));}catch(ex){console.warn(' ',ex.message);process.exitCode=1;}}if(process.argv.length<4){console.warn('Usage: convert-schema.js file.yaml YYYY-MM-DD [YYYY-MM-DD YYYY-MM-DD YYYY-MM-DD]');}else{if(process.argv.length>4){convert(process.argv[2],process.argv[3],process.argv[4],process.argv[5],process.argv[6]);}else{convert(process.argv[2],process.argv[3]);}}

@ralfhandl

Copy link
Copy Markdown
ContributorAuthor

@handrews Thanks, will look into this once #4146 is merged.

@ralfhandl
ralfhandl deleted the publish-schemas branch October 25, 2024 13:55
@ralfhandl

Copy link
Copy Markdown
ContributorAuthor

Replaced with simpler approach:

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Schemachanges related to the schema(s)scriptPull requests that update Bash or JavaScript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@ralfhandl@karenetheridge@handrews
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Workflow to publish schemas - #4139

Closed
ralfhandl wants to merge 13 commits into
OAI:mainfrom
ralfhandl:publish-schemas
Closed

Workflow to publish schemas#4139
ralfhandl wants to merge 13 commits into
OAI:mainfrom
ralfhandl:publish-schemas

Conversation

@ralfhandl

@ralfhandlralfhandl commented Oct 16, 2024

Copy link
Copy Markdown
Contributor
  • GitHub workflow
  • bash script called from workflow
  • JS script to convert YAML to JSON and patch iteration date
  • unit tests for JS script
  • Align with outcome of
  • Dependencies between schema files:
    • if meta changes, republish all four files
    • if dialect changes, republish it, schema, and schema_base
    • if schema changes, republish it and schema_base
    • if schema_base changes, republish it
    • new date stamp is maximum date of last commit in the dependency chain
flowchart LR
schema_base
schema
dialect
meta
schema --> |default| dialect
schema_base --> |$ref| schema
schema_base --> |$ref| dialect
dialect --> |$ref| meta
Loading

Example PR created by this workflow

@handrewshandrews added Schema changes related to the schema(s) script Pull requests that update Bash or JavaScript code labels Oct 16, 2024
@ralfhandl
ralfhandl marked this pull request as ready for review October 17, 2024 10:00
@ralfhandl
ralfhandl requested review from a team as code ownersOctober 17, 2024 10:00
@karenetheridge

karenetheridge commented Oct 17, 2024

Copy link
Copy Markdown
Member

to confirm, these are both edited in the files?

  • dates in the $id keywords
  • $comment links in each definition, that currently go to the 3.1.0 spec and should go to 3.1.1

@ralfhandl

Copy link
Copy Markdown
ContributorAuthor
  • What about the dates in the $ids?

Those are replaced when converting from YAML to JSON, see example PR https://github.com/ralfhandl/OpenAPI-Specification/pull/26/files

@ralfhandl

ralfhandl commented Oct 17, 2024

Copy link
Copy Markdown
ContributorAuthor
  • What about the description links in each definition, that currently go to the 3.1.0 spec and should go to 3.1.1?

These need to be adjusted manually. Changing them in main will then trigger the schema-publish workflow.

@handrewshandrews left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this work! To the extend that I understand current JavaScript, this looks great.

However, I'd like to merge #4146 and update this PR accordingly before publishing any new schemas. Let's make sure that when we resume publication after such a long gap, the first newly-published schemas are what we want.

Unfortunately, this does introduce a complexity, which is that the various 3.1 schema resources (of which there are four) can change independently. Ideally, we would only re-publish and update the $id for each when it changes, although it would not be the end of the world to just publish all four at once with the same updated data whenever any of them change. For the first publication, we'll need to do that anyway, so perhaps supporting independent updating can be something for later to keep the immediate work manageable?

I believe that the search-and-replace could just become a global grep for WORK-IN-PROGRESS once #4146 is merged, rather than worrying about parsing anything. We'd have to know not to put "WORK-IN-PROGRESS" anywhere else in the schemas, but that shouldn't be too hard to document.

It's worth noting that there are more places than id, $id, and $ref where the replacement needs to be done, so a global grep for a unique token would be more robust anyway.

@handrews

handrews commented Oct 22, 2024

Copy link
Copy Markdown
Member

@ralfhandl I realize I am asking for a substantially more complex workflow, so I took a pass at it. I was going to use the "suggest" feature on this PR but... my JavaScript skills are very poor and my bash skills are atrocious.

So here's something that I got working locally that you can use as a proof-of-concept (it doesn't update the markdown but I'm not quite sure what's going on there and I think this should get the point across). Or if you'd prefer, I can try to clean this up and submit it myself. I'm also happy to help with updates to the spec site for the date-using vocabulary and dialect schemas.

In local testing it handled various combinations of only certain schemas being updated correctly, including all updated, only the schema updated (but for both versions) and having the vocab and/or dialect schema changes cause further updates.

thisCommit="$GITHUB_SHA"# Note that for 3.0, "noDialectSchema" is the only schema
noDialectWIP="schema/WORK-IN-PROGRESS"
vocabWIP="meta/WORK-IN-PROGRESS"
dialectWIP="dialect/WORK-IN-PROGRESS"
strictDialectWIP="schema-base/WORK-IN-PROGRESS"forschemaDirin schemas/v3*;do
version=$(basename "$schemaDir")
noDialectSchema="$schemaDir/schema.yaml"
vocabSchema="$schemaDir/meta/base.schema.yaml"
dialectSchema="$schemaDir/dialect/base.schema.yaml"
strictDialectSchema="$schemaDir/schema-base.yaml"echo$noDialectSchemaecho$vocabSchemaecho$dialectSchemaecho$strictDialectSchemaecho""if [ -f"$noDialectSchema" ];then
noDialectCommit=$(git log -1 --format="%H" -- "$noDialectSchema")
noDialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$noDialectSchema")if [ "$noDialectCommit"="$thisCommit" ];then
updateNoDialect="1"fifiif [ -f"$vocabSchema" ];then
vocabCommit=$(git log -1 --format="%H" -- "$vocabSchema")
vocabCommitDate=$(git log -1 --format="%ad" --date=short -- "$vocabSchema")if [ "$vocabCommit"="$thisCommit" ];then
updateVocab="1"fifiif [ -f"$dialectSchema" ];then
dialectCommit=$(git log -1 --format="%H" -- "$dialectSchema")
dialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$dialectSchema")
updateDialect="$updateVocab"if [ "$dialectCommit"="$thisCommit" ];then
updateDialect="1"fifiif [ -f"$strictDialectSchema" ];then
strictDialectCommit=$(git log -1 --format="%H" -- "$strictDialectSchema")
strictDialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$strictDialectSchema")
updateStrictDialect="$updateDialect"if [ -n"$updateNoDialect" ];then
updateStrictDialect="1"fiif [ "$strictDialectCommit"="$thisCommit" ];then
updateStrictDialect="1"fifiecho$thisCommitecho$version$noDialectCommit$noDialectCommitDate$updateNoDialectecho$version$vocabCommit$vocabCommitDate$updateVocabecho$version$dialectCommit$dialectCommitDate$updateDialectecho$version$strictDialectCommit$strictDialectCommitDate$updateStrictDialectecho""
mkdir -p deploy/oas/$version/schema
if [ -f"$vocabSchema" ];then
mkdir -p deploy/oas/$version/meta
mkdir -p deploy/oas/$version/dialect
if [ -n"$updateNoDialect" ];then
node scripts/schema-convert.js "$noDialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/schema/$noDialectCommitDatefiif [ -n"$updateVocab" ];then
node scripts/schema-convert.js "$vocabSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/meta/$vocabCommitDatefiif [ -n"$updateDialect" ];then
node scripts/schema-convert.js "$dialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/dialect/$dialectCommitDatefiif [ -n"$updateStrictDialect" ];then
node scripts/schema-convert.js "$strictDialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/schema-base/$strictDialectCommitDatefielseif [ -n"$updateNoDialect" ];then
node scripts/schema-convert.js "$noDialectSchema"$noDialectCommitDate> deploy/oas/$version/schema/$noDialectCommitDatefifidone
#!/usr/bin/env node
'use strict';constfs=require('fs');constyaml=require('yaml');functionconvert(filename,noDialectDate,vocabDate=false,dialectDate=false,strictDialectDate=false,){try{vars=fs.readFileSync(filename,'utf8');s=s.replace(/schema\/WORK-IN-PROGRESS/g,'schema/'+noDialectDate,);if(vocabDate){s=s.replace(/meta\/WORK-IN-PROGRESS/g,'meta/'+vocabDate,);}if(dialectDate){s=s.replace(/dialect\/WORK-IN-PROGRESS/g,'dialect/'+dialectDate,);}if(strictDialectDate){s=s.replace(/schema-base\/WORK-IN-PROGRESS/g,'schema-base/'+strictDialectDate,);}constobj=yaml.parse(s,{prettyErrors: true});console.log(JSON.stringify(obj,null,2));}catch(ex){console.warn(' ',ex.message);process.exitCode=1;}}if(process.argv.length<4){console.warn('Usage: convert-schema.js file.yaml YYYY-MM-DD [YYYY-MM-DD YYYY-MM-DD YYYY-MM-DD]');}else{if(process.argv.length>4){convert(process.argv[2],process.argv[3],process.argv[4],process.argv[5],process.argv[6]);}else{convert(process.argv[2],process.argv[3]);}}

@ralfhandl

Copy link
Copy Markdown
ContributorAuthor

@handrews Thanks, will look into this once #4146 is merged.

@ralfhandl
ralfhandl deleted the publish-schemas branch October 25, 2024 13:55
@ralfhandl

Copy link
Copy Markdown
ContributorAuthor

Replaced with simpler approach:

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Schemachanges related to the schema(s)scriptPull requests that update Bash or JavaScript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@ralfhandl@karenetheridge@handrews
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Workflow to publish schemas - #4139

Closed
ralfhandl wants to merge 13 commits into
OAI:mainfrom
ralfhandl:publish-schemas
Closed

Workflow to publish schemas#4139
ralfhandl wants to merge 13 commits into
OAI:mainfrom
ralfhandl:publish-schemas

Conversation

@ralfhandl

@ralfhandlralfhandl commented Oct 16, 2024

Copy link
Copy Markdown
Contributor
  • GitHub workflow
  • bash script called from workflow
  • JS script to convert YAML to JSON and patch iteration date
  • unit tests for JS script
  • Align with outcome of
  • Dependencies between schema files:
    • if meta changes, republish all four files
    • if dialect changes, republish it, schema, and schema_base
    • if schema changes, republish it and schema_base
    • if schema_base changes, republish it
    • new date stamp is maximum date of last commit in the dependency chain
flowchart LR
schema_base
schema
dialect
meta
schema --> |default| dialect
schema_base --> |$ref| schema
schema_base --> |$ref| dialect
dialect --> |$ref| meta
Loading

Example PR created by this workflow

@handrewshandrews added Schema changes related to the schema(s) script Pull requests that update Bash or JavaScript code labels Oct 16, 2024
@ralfhandl
ralfhandl marked this pull request as ready for review October 17, 2024 10:00
@ralfhandl
ralfhandl requested review from a team as code ownersOctober 17, 2024 10:00
@karenetheridge

karenetheridge commented Oct 17, 2024

Copy link
Copy Markdown
Member

to confirm, these are both edited in the files?

  • dates in the $id keywords
  • $comment links in each definition, that currently go to the 3.1.0 spec and should go to 3.1.1

@ralfhandl

Copy link
Copy Markdown
ContributorAuthor
  • What about the dates in the $ids?

Those are replaced when converting from YAML to JSON, see example PR https://github.com/ralfhandl/OpenAPI-Specification/pull/26/files

@ralfhandl

ralfhandl commented Oct 17, 2024

Copy link
Copy Markdown
ContributorAuthor
  • What about the description links in each definition, that currently go to the 3.1.0 spec and should go to 3.1.1?

These need to be adjusted manually. Changing them in main will then trigger the schema-publish workflow.

@handrewshandrews left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this work! To the extend that I understand current JavaScript, this looks great.

However, I'd like to merge #4146 and update this PR accordingly before publishing any new schemas. Let's make sure that when we resume publication after such a long gap, the first newly-published schemas are what we want.

Unfortunately, this does introduce a complexity, which is that the various 3.1 schema resources (of which there are four) can change independently. Ideally, we would only re-publish and update the $id for each when it changes, although it would not be the end of the world to just publish all four at once with the same updated data whenever any of them change. For the first publication, we'll need to do that anyway, so perhaps supporting independent updating can be something for later to keep the immediate work manageable?

I believe that the search-and-replace could just become a global grep for WORK-IN-PROGRESS once #4146 is merged, rather than worrying about parsing anything. We'd have to know not to put "WORK-IN-PROGRESS" anywhere else in the schemas, but that shouldn't be too hard to document.

It's worth noting that there are more places than id, $id, and $ref where the replacement needs to be done, so a global grep for a unique token would be more robust anyway.

@handrews

handrews commented Oct 22, 2024

Copy link
Copy Markdown
Member

@ralfhandl I realize I am asking for a substantially more complex workflow, so I took a pass at it. I was going to use the "suggest" feature on this PR but... my JavaScript skills are very poor and my bash skills are atrocious.

So here's something that I got working locally that you can use as a proof-of-concept (it doesn't update the markdown but I'm not quite sure what's going on there and I think this should get the point across). Or if you'd prefer, I can try to clean this up and submit it myself. I'm also happy to help with updates to the spec site for the date-using vocabulary and dialect schemas.

In local testing it handled various combinations of only certain schemas being updated correctly, including all updated, only the schema updated (but for both versions) and having the vocab and/or dialect schema changes cause further updates.

thisCommit="$GITHUB_SHA"# Note that for 3.0, "noDialectSchema" is the only schema
noDialectWIP="schema/WORK-IN-PROGRESS"
vocabWIP="meta/WORK-IN-PROGRESS"
dialectWIP="dialect/WORK-IN-PROGRESS"
strictDialectWIP="schema-base/WORK-IN-PROGRESS"forschemaDirin schemas/v3*;do
version=$(basename "$schemaDir")
noDialectSchema="$schemaDir/schema.yaml"
vocabSchema="$schemaDir/meta/base.schema.yaml"
dialectSchema="$schemaDir/dialect/base.schema.yaml"
strictDialectSchema="$schemaDir/schema-base.yaml"echo$noDialectSchemaecho$vocabSchemaecho$dialectSchemaecho$strictDialectSchemaecho""if [ -f"$noDialectSchema" ];then
noDialectCommit=$(git log -1 --format="%H" -- "$noDialectSchema")
noDialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$noDialectSchema")if [ "$noDialectCommit"="$thisCommit" ];then
updateNoDialect="1"fifiif [ -f"$vocabSchema" ];then
vocabCommit=$(git log -1 --format="%H" -- "$vocabSchema")
vocabCommitDate=$(git log -1 --format="%ad" --date=short -- "$vocabSchema")if [ "$vocabCommit"="$thisCommit" ];then
updateVocab="1"fifiif [ -f"$dialectSchema" ];then
dialectCommit=$(git log -1 --format="%H" -- "$dialectSchema")
dialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$dialectSchema")
updateDialect="$updateVocab"if [ "$dialectCommit"="$thisCommit" ];then
updateDialect="1"fifiif [ -f"$strictDialectSchema" ];then
strictDialectCommit=$(git log -1 --format="%H" -- "$strictDialectSchema")
strictDialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$strictDialectSchema")
updateStrictDialect="$updateDialect"if [ -n"$updateNoDialect" ];then
updateStrictDialect="1"fiif [ "$strictDialectCommit"="$thisCommit" ];then
updateStrictDialect="1"fifiecho$thisCommitecho$version$noDialectCommit$noDialectCommitDate$updateNoDialectecho$version$vocabCommit$vocabCommitDate$updateVocabecho$version$dialectCommit$dialectCommitDate$updateDialectecho$version$strictDialectCommit$strictDialectCommitDate$updateStrictDialectecho""
mkdir -p deploy/oas/$version/schema
if [ -f"$vocabSchema" ];then
mkdir -p deploy/oas/$version/meta
mkdir -p deploy/oas/$version/dialect
if [ -n"$updateNoDialect" ];then
node scripts/schema-convert.js "$noDialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/schema/$noDialectCommitDatefiif [ -n"$updateVocab" ];then
node scripts/schema-convert.js "$vocabSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/meta/$vocabCommitDatefiif [ -n"$updateDialect" ];then
node scripts/schema-convert.js "$dialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/dialect/$dialectCommitDatefiif [ -n"$updateStrictDialect" ];then
node scripts/schema-convert.js "$strictDialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/schema-base/$strictDialectCommitDatefielseif [ -n"$updateNoDialect" ];then
node scripts/schema-convert.js "$noDialectSchema"$noDialectCommitDate> deploy/oas/$version/schema/$noDialectCommitDatefifidone
#!/usr/bin/env node
'use strict';constfs=require('fs');constyaml=require('yaml');functionconvert(filename,noDialectDate,vocabDate=false,dialectDate=false,strictDialectDate=false,){try{vars=fs.readFileSync(filename,'utf8');s=s.replace(/schema\/WORK-IN-PROGRESS/g,'schema/'+noDialectDate,);if(vocabDate){s=s.replace(/meta\/WORK-IN-PROGRESS/g,'meta/'+vocabDate,);}if(dialectDate){s=s.replace(/dialect\/WORK-IN-PROGRESS/g,'dialect/'+dialectDate,);}if(strictDialectDate){s=s.replace(/schema-base\/WORK-IN-PROGRESS/g,'schema-base/'+strictDialectDate,);}constobj=yaml.parse(s,{prettyErrors: true});console.log(JSON.stringify(obj,null,2));}catch(ex){console.warn(' ',ex.message);process.exitCode=1;}}if(process.argv.length<4){console.warn('Usage: convert-schema.js file.yaml YYYY-MM-DD [YYYY-MM-DD YYYY-MM-DD YYYY-MM-DD]');}else{if(process.argv.length>4){convert(process.argv[2],process.argv[3],process.argv[4],process.argv[5],process.argv[6]);}else{convert(process.argv[2],process.argv[3]);}}

@ralfhandl

Copy link
Copy Markdown
ContributorAuthor

@handrews Thanks, will look into this once #4146 is merged.

@ralfhandl
ralfhandl deleted the publish-schemas branch October 25, 2024 13:55
@ralfhandl

Copy link
Copy Markdown
ContributorAuthor

Replaced with simpler approach:

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Schemachanges related to the schema(s)scriptPull requests that update Bash or JavaScript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@ralfhandl@karenetheridge@handrews
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Workflow to publish schemas - #4139

Closed
ralfhandl wants to merge 13 commits into
OAI:mainfrom
ralfhandl:publish-schemas
Closed

Workflow to publish schemas#4139
ralfhandl wants to merge 13 commits into
OAI:mainfrom
ralfhandl:publish-schemas

Conversation

@ralfhandl

@ralfhandlralfhandl commented Oct 16, 2024

Copy link
Copy Markdown
Contributor
  • GitHub workflow
  • bash script called from workflow
  • JS script to convert YAML to JSON and patch iteration date
  • unit tests for JS script
  • Align with outcome of
  • Dependencies between schema files:
    • if meta changes, republish all four files
    • if dialect changes, republish it, schema, and schema_base
    • if schema changes, republish it and schema_base
    • if schema_base changes, republish it
    • new date stamp is maximum date of last commit in the dependency chain
flowchart LR
schema_base
schema
dialect
meta
schema --> |default| dialect
schema_base --> |$ref| schema
schema_base --> |$ref| dialect
dialect --> |$ref| meta
Loading

Example PR created by this workflow

@handrewshandrews added Schema changes related to the schema(s) script Pull requests that update Bash or JavaScript code labels Oct 16, 2024
@ralfhandl
ralfhandl marked this pull request as ready for review October 17, 2024 10:00
@ralfhandl
ralfhandl requested review from a team as code ownersOctober 17, 2024 10:00
@karenetheridge

karenetheridge commented Oct 17, 2024

Copy link
Copy Markdown
Member

to confirm, these are both edited in the files?

  • dates in the $id keywords
  • $comment links in each definition, that currently go to the 3.1.0 spec and should go to 3.1.1

@ralfhandl

Copy link
Copy Markdown
ContributorAuthor
  • What about the dates in the $ids?

Those are replaced when converting from YAML to JSON, see example PR https://github.com/ralfhandl/OpenAPI-Specification/pull/26/files

@ralfhandl

ralfhandl commented Oct 17, 2024

Copy link
Copy Markdown
ContributorAuthor
  • What about the description links in each definition, that currently go to the 3.1.0 spec and should go to 3.1.1?

These need to be adjusted manually. Changing them in main will then trigger the schema-publish workflow.

@handrewshandrews left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this work! To the extend that I understand current JavaScript, this looks great.

However, I'd like to merge #4146 and update this PR accordingly before publishing any new schemas. Let's make sure that when we resume publication after such a long gap, the first newly-published schemas are what we want.

Unfortunately, this does introduce a complexity, which is that the various 3.1 schema resources (of which there are four) can change independently. Ideally, we would only re-publish and update the $id for each when it changes, although it would not be the end of the world to just publish all four at once with the same updated data whenever any of them change. For the first publication, we'll need to do that anyway, so perhaps supporting independent updating can be something for later to keep the immediate work manageable?

I believe that the search-and-replace could just become a global grep for WORK-IN-PROGRESS once #4146 is merged, rather than worrying about parsing anything. We'd have to know not to put "WORK-IN-PROGRESS" anywhere else in the schemas, but that shouldn't be too hard to document.

It's worth noting that there are more places than id, $id, and $ref where the replacement needs to be done, so a global grep for a unique token would be more robust anyway.

@handrews

handrews commented Oct 22, 2024

Copy link
Copy Markdown
Member

@ralfhandl I realize I am asking for a substantially more complex workflow, so I took a pass at it. I was going to use the "suggest" feature on this PR but... my JavaScript skills are very poor and my bash skills are atrocious.

So here's something that I got working locally that you can use as a proof-of-concept (it doesn't update the markdown but I'm not quite sure what's going on there and I think this should get the point across). Or if you'd prefer, I can try to clean this up and submit it myself. I'm also happy to help with updates to the spec site for the date-using vocabulary and dialect schemas.

In local testing it handled various combinations of only certain schemas being updated correctly, including all updated, only the schema updated (but for both versions) and having the vocab and/or dialect schema changes cause further updates.

thisCommit="$GITHUB_SHA"# Note that for 3.0, "noDialectSchema" is the only schema
noDialectWIP="schema/WORK-IN-PROGRESS"
vocabWIP="meta/WORK-IN-PROGRESS"
dialectWIP="dialect/WORK-IN-PROGRESS"
strictDialectWIP="schema-base/WORK-IN-PROGRESS"forschemaDirin schemas/v3*;do
version=$(basename "$schemaDir")
noDialectSchema="$schemaDir/schema.yaml"
vocabSchema="$schemaDir/meta/base.schema.yaml"
dialectSchema="$schemaDir/dialect/base.schema.yaml"
strictDialectSchema="$schemaDir/schema-base.yaml"echo$noDialectSchemaecho$vocabSchemaecho$dialectSchemaecho$strictDialectSchemaecho""if [ -f"$noDialectSchema" ];then
noDialectCommit=$(git log -1 --format="%H" -- "$noDialectSchema")
noDialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$noDialectSchema")if [ "$noDialectCommit"="$thisCommit" ];then
updateNoDialect="1"fifiif [ -f"$vocabSchema" ];then
vocabCommit=$(git log -1 --format="%H" -- "$vocabSchema")
vocabCommitDate=$(git log -1 --format="%ad" --date=short -- "$vocabSchema")if [ "$vocabCommit"="$thisCommit" ];then
updateVocab="1"fifiif [ -f"$dialectSchema" ];then
dialectCommit=$(git log -1 --format="%H" -- "$dialectSchema")
dialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$dialectSchema")
updateDialect="$updateVocab"if [ "$dialectCommit"="$thisCommit" ];then
updateDialect="1"fifiif [ -f"$strictDialectSchema" ];then
strictDialectCommit=$(git log -1 --format="%H" -- "$strictDialectSchema")
strictDialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$strictDialectSchema")
updateStrictDialect="$updateDialect"if [ -n"$updateNoDialect" ];then
updateStrictDialect="1"fiif [ "$strictDialectCommit"="$thisCommit" ];then
updateStrictDialect="1"fifiecho$thisCommitecho$version$noDialectCommit$noDialectCommitDate$updateNoDialectecho$version$vocabCommit$vocabCommitDate$updateVocabecho$version$dialectCommit$dialectCommitDate$updateDialectecho$version$strictDialectCommit$strictDialectCommitDate$updateStrictDialectecho""
mkdir -p deploy/oas/$version/schema
if [ -f"$vocabSchema" ];then
mkdir -p deploy/oas/$version/meta
mkdir -p deploy/oas/$version/dialect
if [ -n"$updateNoDialect" ];then
node scripts/schema-convert.js "$noDialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/schema/$noDialectCommitDatefiif [ -n"$updateVocab" ];then
node scripts/schema-convert.js "$vocabSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/meta/$vocabCommitDatefiif [ -n"$updateDialect" ];then
node scripts/schema-convert.js "$dialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/dialect/$dialectCommitDatefiif [ -n"$updateStrictDialect" ];then
node scripts/schema-convert.js "$strictDialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/schema-base/$strictDialectCommitDatefielseif [ -n"$updateNoDialect" ];then
node scripts/schema-convert.js "$noDialectSchema"$noDialectCommitDate> deploy/oas/$version/schema/$noDialectCommitDatefifidone
#!/usr/bin/env node
'use strict';constfs=require('fs');constyaml=require('yaml');functionconvert(filename,noDialectDate,vocabDate=false,dialectDate=false,strictDialectDate=false,){try{vars=fs.readFileSync(filename,'utf8');s=s.replace(/schema\/WORK-IN-PROGRESS/g,'schema/'+noDialectDate,);if(vocabDate){s=s.replace(/meta\/WORK-IN-PROGRESS/g,'meta/'+vocabDate,);}if(dialectDate){s=s.replace(/dialect\/WORK-IN-PROGRESS/g,'dialect/'+dialectDate,);}if(strictDialectDate){s=s.replace(/schema-base\/WORK-IN-PROGRESS/g,'schema-base/'+strictDialectDate,);}constobj=yaml.parse(s,{prettyErrors: true});console.log(JSON.stringify(obj,null,2));}catch(ex){console.warn(' ',ex.message);process.exitCode=1;}}if(process.argv.length<4){console.warn('Usage: convert-schema.js file.yaml YYYY-MM-DD [YYYY-MM-DD YYYY-MM-DD YYYY-MM-DD]');}else{if(process.argv.length>4){convert(process.argv[2],process.argv[3],process.argv[4],process.argv[5],process.argv[6]);}else{convert(process.argv[2],process.argv[3]);}}

@ralfhandl

Copy link
Copy Markdown
ContributorAuthor

@handrews Thanks, will look into this once #4146 is merged.

@ralfhandl
ralfhandl deleted the publish-schemas branch October 25, 2024 13:55
@ralfhandl

Copy link
Copy Markdown
ContributorAuthor

Replaced with simpler approach:

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Schemachanges related to the schema(s)scriptPull requests that update Bash or JavaScript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@ralfhandl@karenetheridge@handrews
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Workflow to publish schemas - #4139

Closed
ralfhandl wants to merge 13 commits into
OAI:mainfrom
ralfhandl:publish-schemas
Closed

Workflow to publish schemas#4139
ralfhandl wants to merge 13 commits into
OAI:mainfrom
ralfhandl:publish-schemas

Conversation

@ralfhandl

@ralfhandlralfhandl commented Oct 16, 2024

Copy link
Copy Markdown
Contributor
  • GitHub workflow
  • bash script called from workflow
  • JS script to convert YAML to JSON and patch iteration date
  • unit tests for JS script
  • Align with outcome of
  • Dependencies between schema files:
    • if meta changes, republish all four files
    • if dialect changes, republish it, schema, and schema_base
    • if schema changes, republish it and schema_base
    • if schema_base changes, republish it
    • new date stamp is maximum date of last commit in the dependency chain
flowchart LR
schema_base
schema
dialect
meta
schema --> |default| dialect
schema_base --> |$ref| schema
schema_base --> |$ref| dialect
dialect --> |$ref| meta
Loading

Example PR created by this workflow

@handrewshandrews added Schema changes related to the schema(s) script Pull requests that update Bash or JavaScript code labels Oct 16, 2024
@ralfhandl
ralfhandl marked this pull request as ready for review October 17, 2024 10:00
@ralfhandl
ralfhandl requested review from a team as code ownersOctober 17, 2024 10:00
@karenetheridge

karenetheridge commented Oct 17, 2024

Copy link
Copy Markdown
Member

to confirm, these are both edited in the files?

  • dates in the $id keywords
  • $comment links in each definition, that currently go to the 3.1.0 spec and should go to 3.1.1

@ralfhandl

Copy link
Copy Markdown
ContributorAuthor
  • What about the dates in the $ids?

Those are replaced when converting from YAML to JSON, see example PR https://github.com/ralfhandl/OpenAPI-Specification/pull/26/files

@ralfhandl

ralfhandl commented Oct 17, 2024

Copy link
Copy Markdown
ContributorAuthor
  • What about the description links in each definition, that currently go to the 3.1.0 spec and should go to 3.1.1?

These need to be adjusted manually. Changing them in main will then trigger the schema-publish workflow.

@handrewshandrews left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this work! To the extend that I understand current JavaScript, this looks great.

However, I'd like to merge #4146 and update this PR accordingly before publishing any new schemas. Let's make sure that when we resume publication after such a long gap, the first newly-published schemas are what we want.

Unfortunately, this does introduce a complexity, which is that the various 3.1 schema resources (of which there are four) can change independently. Ideally, we would only re-publish and update the $id for each when it changes, although it would not be the end of the world to just publish all four at once with the same updated data whenever any of them change. For the first publication, we'll need to do that anyway, so perhaps supporting independent updating can be something for later to keep the immediate work manageable?

I believe that the search-and-replace could just become a global grep for WORK-IN-PROGRESS once #4146 is merged, rather than worrying about parsing anything. We'd have to know not to put "WORK-IN-PROGRESS" anywhere else in the schemas, but that shouldn't be too hard to document.

It's worth noting that there are more places than id, $id, and $ref where the replacement needs to be done, so a global grep for a unique token would be more robust anyway.

@handrews

handrews commented Oct 22, 2024

Copy link
Copy Markdown
Member

@ralfhandl I realize I am asking for a substantially more complex workflow, so I took a pass at it. I was going to use the "suggest" feature on this PR but... my JavaScript skills are very poor and my bash skills are atrocious.

So here's something that I got working locally that you can use as a proof-of-concept (it doesn't update the markdown but I'm not quite sure what's going on there and I think this should get the point across). Or if you'd prefer, I can try to clean this up and submit it myself. I'm also happy to help with updates to the spec site for the date-using vocabulary and dialect schemas.

In local testing it handled various combinations of only certain schemas being updated correctly, including all updated, only the schema updated (but for both versions) and having the vocab and/or dialect schema changes cause further updates.

thisCommit="$GITHUB_SHA"# Note that for 3.0, "noDialectSchema" is the only schema
noDialectWIP="schema/WORK-IN-PROGRESS"
vocabWIP="meta/WORK-IN-PROGRESS"
dialectWIP="dialect/WORK-IN-PROGRESS"
strictDialectWIP="schema-base/WORK-IN-PROGRESS"forschemaDirin schemas/v3*;do
version=$(basename "$schemaDir")
noDialectSchema="$schemaDir/schema.yaml"
vocabSchema="$schemaDir/meta/base.schema.yaml"
dialectSchema="$schemaDir/dialect/base.schema.yaml"
strictDialectSchema="$schemaDir/schema-base.yaml"echo$noDialectSchemaecho$vocabSchemaecho$dialectSchemaecho$strictDialectSchemaecho""if [ -f"$noDialectSchema" ];then
noDialectCommit=$(git log -1 --format="%H" -- "$noDialectSchema")
noDialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$noDialectSchema")if [ "$noDialectCommit"="$thisCommit" ];then
updateNoDialect="1"fifiif [ -f"$vocabSchema" ];then
vocabCommit=$(git log -1 --format="%H" -- "$vocabSchema")
vocabCommitDate=$(git log -1 --format="%ad" --date=short -- "$vocabSchema")if [ "$vocabCommit"="$thisCommit" ];then
updateVocab="1"fifiif [ -f"$dialectSchema" ];then
dialectCommit=$(git log -1 --format="%H" -- "$dialectSchema")
dialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$dialectSchema")
updateDialect="$updateVocab"if [ "$dialectCommit"="$thisCommit" ];then
updateDialect="1"fifiif [ -f"$strictDialectSchema" ];then
strictDialectCommit=$(git log -1 --format="%H" -- "$strictDialectSchema")
strictDialectCommitDate=$(git log -1 --format="%ad" --date=short -- "$strictDialectSchema")
updateStrictDialect="$updateDialect"if [ -n"$updateNoDialect" ];then
updateStrictDialect="1"fiif [ "$strictDialectCommit"="$thisCommit" ];then
updateStrictDialect="1"fifiecho$thisCommitecho$version$noDialectCommit$noDialectCommitDate$updateNoDialectecho$version$vocabCommit$vocabCommitDate$updateVocabecho$version$dialectCommit$dialectCommitDate$updateDialectecho$version$strictDialectCommit$strictDialectCommitDate$updateStrictDialectecho""
mkdir -p deploy/oas/$version/schema
if [ -f"$vocabSchema" ];then
mkdir -p deploy/oas/$version/meta
mkdir -p deploy/oas/$version/dialect
if [ -n"$updateNoDialect" ];then
node scripts/schema-convert.js "$noDialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/schema/$noDialectCommitDatefiif [ -n"$updateVocab" ];then
node scripts/schema-convert.js "$vocabSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/meta/$vocabCommitDatefiif [ -n"$updateDialect" ];then
node scripts/schema-convert.js "$dialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/dialect/$dialectCommitDatefiif [ -n"$updateStrictDialect" ];then
node scripts/schema-convert.js "$strictDialectSchema"$noDialectCommitDate$vocabCommitDate$dialectCommitDate$strictDialectCommitDate> deploy/oas/$version/schema-base/$strictDialectCommitDatefielseif [ -n"$updateNoDialect" ];then
node scripts/schema-convert.js "$noDialectSchema"$noDialectCommitDate> deploy/oas/$version/schema/$noDialectCommitDatefifidone
#!/usr/bin/env node
'use strict';constfs=require('fs');constyaml=require('yaml');functionconvert(filename,noDialectDate,vocabDate=false,dialectDate=false,strictDialectDate=false,){try{vars=fs.readFileSync(filename,'utf8');s=s.replace(/schema\/WORK-IN-PROGRESS/g,'schema/'+noDialectDate,);if(vocabDate){s=s.replace(/meta\/WORK-IN-PROGRESS/g,'meta/'+vocabDate,);}if(dialectDate){s=s.replace(/dialect\/WORK-IN-PROGRESS/g,'dialect/'+dialectDate,);}if(strictDialectDate){s=s.replace(/schema-base\/WORK-IN-PROGRESS/g,'schema-base/'+strictDialectDate,);}constobj=yaml.parse(s,{prettyErrors: true});console.log(JSON.stringify(obj,null,2));}catch(ex){console.warn(' ',ex.message);process.exitCode=1;}}if(process.argv.length<4){console.warn('Usage: convert-schema.js file.yaml YYYY-MM-DD [YYYY-MM-DD YYYY-MM-DD YYYY-MM-DD]');}else{if(process.argv.length>4){convert(process.argv[2],process.argv[3],process.argv[4],process.argv[5],process.argv[6]);}else{convert(process.argv[2],process.argv[3]);}}

@ralfhandl

Copy link
Copy Markdown
ContributorAuthor

@handrews Thanks, will look into this once #4146 is merged.

@ralfhandl
ralfhandl deleted the publish-schemas branch October 25, 2024 13:55
@ralfhandl

Copy link
Copy Markdown
ContributorAuthor

Replaced with simpler approach:

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Schemachanges related to the schema(s)scriptPull requests that update Bash or JavaScript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@ralfhandl@karenetheridge@handrews