Uh oh!
There was an error while loading. Please reload this page.
Workflow to publish schemas - #4139
Conversation
to confirm, these are both edited in the files?
|
ralfhandl
commented
Oct 17, 2024
Those are replaced when converting from YAML to JSON, see example PR https://github.com/ralfhandl/OpenAPI-Specification/pull/26/files |
These need to be adjusted manually. Changing them in |
handrews
left a comment
There was a problem hiding this comment.
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.
@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 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
commented
Oct 22, 2024
ralfhandl
commented
Oct 25, 2024
Replaced with simpler approach: |
metachanges, republish all four filesdialectchanges, republish it,schema, andschema_baseschemachanges, republish it andschema_baseschema_basechanges, republish itExample PR created by this workflow