diff --git a/.github/workflows/data-deploy.yml b/.github/workflows/data-deploy.yml index 5bc2fdc..cb49178 100644 --- a/.github/workflows/data-deploy.yml +++ b/.github/workflows/data-deploy.yml @@ -359,30 +359,42 @@ jobs: TITLE: ${{ steps.branding.outputs.title }} FAVICON: ${{ steps.branding.outputs.favicon }} DESCRIPTION: ${{ steps.branding.outputs.description }} + PUBID_FLAVOR: ${{ steps.branding.outputs.pubid_flavor }} + PUBLISH_DATA: ${{ steps.branding.outputs.publish_data }} run: | + EXTRA=() + [ -n "$PUBID_FLAVOR" ] && EXTRA+=(--pubid-flavor "$PUBID_FLAVOR") + [ "$PUBLISH_DATA" = "true" ] && EXTRA+=(--publish-data) relaton index "${{ inputs.data-dir }}" \ --output _site \ --title "$TITLE" \ --favicon "$FAVICON" \ --description "$DESCRIPTION" \ - --base-url "https://raw.githubusercontent.com/${GITHUB_REPOSITORY}/${GITHUB_REF_NAME}" + --base-url "https://raw.githubusercontent.com/${GITHUB_REPOSITORY}/${GITHUB_REF_NAME}" \ + "${EXTRA[@]}" - name: Build index (git source) if: inputs.source == 'git' # BUNDLE_GEMFILE is exported to GITHUB_ENV in the build step above. # TITLE/FAVICON/DESCRIPTION travel by env for the same reason as the gem - # step. + # step. PUBID_FLAVOR/PUBLISH_DATA come from configs.yml via branding. env: TITLE: ${{ steps.branding.outputs.title }} FAVICON: ${{ steps.branding.outputs.favicon }} DESCRIPTION: ${{ steps.branding.outputs.description }} + PUBID_FLAVOR: ${{ steps.branding.outputs.pubid_flavor }} + PUBLISH_DATA: ${{ steps.branding.outputs.publish_data }} run: | + EXTRA=() + [ -n "$PUBID_FLAVOR" ] && EXTRA+=(--pubid-flavor "$PUBID_FLAVOR") + [ "$PUBLISH_DATA" = "true" ] && EXTRA+=(--publish-data) bundle exec relaton index "${{ github.workspace }}/${{ inputs.data-dir }}" \ --output "${{ github.workspace }}/_site" \ --title "$TITLE" \ --favicon "$FAVICON" \ --description "$DESCRIPTION" \ - --base-url "https://raw.githubusercontent.com/${GITHUB_REPOSITORY}/${GITHUB_REF_NAME}" + --base-url "https://raw.githubusercontent.com/${GITHUB_REPOSITORY}/${GITHUB_REF_NAME}" \ + "${EXTRA[@]}" # Both gated on the deploy job's own publish gate, so a run that cannot # publish does no Pages work: no API call to configure Pages, no artifact diff --git a/data-index/configs.yml b/data-index/configs.yml index 85c325f..a2dc3c4 100644 --- a/data-index/configs.yml +++ b/data-index/configs.yml @@ -88,6 +88,20 @@ repos: description: >- Combined bibliographic index of ITU-R and ITU-T publications in Relaton format. + # Combined IETF corpus for Relaton v3 (parsed from ietf-tools' + # relaton-data-{rfcs,ids,rfcsubseries}). publish_data puts the corpus + # on the Pages site so clients fetch documents from the same origin + # as the machine index; the data is fully derived, so it need not + # live in git long-term. + - repo: ietf + display: IETF + source: index-v1.yaml + branch: main + pubid_class: Pubid::Ietf::Identifier + publish_data: true + description: >- + Combined bibliographic index of IETF RFCs, Internet-Drafts and + BCP/STD/FYI series in Relaton format. - { repo: jcgm, display: JCGM, source: index-v1.yaml, branch: main, pubid_class: Pubid::Jcgm::Identifier } - { repo: jis, display: JIS, source: index-v2.yaml, branch: v2, pubid_class: Pubid::Jis::Identifier } - { repo: nist, display: NIST, source: index-v2.yaml, branch: v2, pubid_class: Pubid::Nist::Identifier } diff --git a/data-index/generated/ietf_config.yml b/data-index/generated/ietf_config.yml new file mode 100644 index 0000000..858921b --- /dev/null +++ b/data-index/generated/ietf_config.yml @@ -0,0 +1,11 @@ +title: IETF Index +description: >- + Combined bibliographic index of IETF RFCs, Internet-Drafts and BCP/STD/FYI series in Relaton format. +paginate: 100 +jekyll-index: + favicon: 'https://www.relaton.org/favicon.ico' + source: 'index-v1.yaml' + baseurl: 'https://raw.githubusercontent.com/relaton/relaton-data-ietf/main/' + add_type_to_reference: true + pubid_class: 'Pubid::Ietf::Identifier' + pubid_require: 'pubid' diff --git a/lib/data_index_config.rb b/lib/data_index_config.rb index df49158..08a1d5a 100644 --- a/lib/data_index_config.rb +++ b/lib/data_index_config.rb @@ -67,6 +67,12 @@ def branding(repo, title: nil, favicon: nil, description: nil) "title" => present(title) || (found ? entry_title(found) : derived_title(repo)), "favicon" => present(favicon) || (found ? entry_favicon(found) : ""), "description" => present(description) || (found ? entry_description(found) : ""), + # Machine-index flags for `relaton index` (relaton/relaton#113). + # Derived from the existing pubid_class row so no new configs.yml + # key is required for structured corpora; publish_data is the one + # explicit opt-in (only fully-derived corpora want it). + "pubid_flavor" => found ? pubid_flavor(found) : "", + "publish_data" => found && found["publish_data"] ? "true" : "false", } end @@ -187,4 +193,14 @@ def pubid_class(entry) value.strip.sub(/\A::/, "") end + + # "Pubid::Iso::Identifier" -> "iso". The short flavor name is what + # `relaton index --pubid-flavor` takes. + def pubid_flavor(entry) + klass = pubid_class(entry) + return "" unless klass + + m = klass.match(/\APubid::(\w+)::/) + m ? m[1].downcase : "" + end end diff --git a/spec/cimas_data_pages_spec.rb b/spec/cimas_data_pages_spec.rb index fd18eca..2616ae4 100644 --- a/spec/cimas_data_pages_spec.rb +++ b/spec/cimas_data_pages_spec.rb @@ -77,10 +77,9 @@ # has no configs.yml row would deploy the theme with no per-repo _config.yml. # Excludes are the deliberate non-index repos (see data-pages-rollout hand-off). known = configs.repos.map { |e| "relaton-data-#{e['repo']}" } - # ietf gets deploy.yml but is deliberately not a Pages index (no document - # index published); every other data-group repo is covered by configs.yml, - # including the already-live ids/oasis/w3c now folded in. - excluded = %w[relaton-data-ietf] + # Every data-group repo that gets deploy.yml is covered by configs.yml + # (ietf was excluded until its combined-corpus rollout landed). + excluded = %w[] deploys_pages = data_group.select do |name| files = repositories.fetch(name, {}).fetch("files", nil) || {} @@ -93,9 +92,8 @@ end it "syncs deploy.yml and check-index.yml together, or neither" do - # Not folded into the per-repo examples above: those iterate configs.yml, - # which deliberately has no relaton-data-ietf row (it gets deploy.yml but - # publishes no document index). A repo that merges data with no PR-time + # Not folded into the per-repo examples above: those iterate configs.yml. + # A repo that merges data with no PR-time # build is exactly the gap this file exists to make loud, whether or not it # has a page — so drive this one off cimas.yml instead. # diff --git a/spec/data_index_config_spec.rb b/spec/data_index_config_spec.rb index 02dab56..85df68a 100644 --- a/spec/data_index_config_spec.rb +++ b/spec/data_index_config_spec.rb @@ -135,17 +135,18 @@ def jekyll_index(repo) end describe "configs.yml data" do - it "covers exactly the 30 repos with no duplicates" do + it "covers exactly the 31 repos with no duplicates" do repos = config.repos.map { |e| e["repo"] } - expect(repos.size).to eq(30) - expect(repos.uniq.size).to eq(30) + expect(repos.size).to eq(31) + expect(repos.uniq.size).to eq(31) expect(repos).to include("iso", "ieee", "jis", "adobe", "easc", "gost", "jcgm", "oiml", "iala") expect(repos).to include("ids", "oasis", "w3c") # already-live, folded in + expect(repos).to include("ietf") # combined v3 corpus # Both ITU rows: `itu` is the combined ITU-R + ITU-T corpus, `itu-r` the # ITU-R-only repo the relaton gem still consumes. Neither is a typo for # the other, and dropping either silently 404s a site. expect(repos).to include("itu", "itu-r") - expect(repos).not_to include("sdo", "ietf", "misc") + expect(repos).not_to include("sdo", "misc") end it "gives every entry the required fields" do diff --git a/spec/index_branding_spec.rb b/spec/index_branding_spec.rb index c6b7996..6275cc4 100644 --- a/spec/index_branding_spec.rb +++ b/spec/index_branding_spec.rb @@ -8,7 +8,7 @@ # # The load-bearing invariants here are the fallbacks: the workflow passes all # three flags unconditionally, and Cimas syncs deploy.yml into one repo -# (relaton-data-ietf) that configs.yml deliberately does not cover. +# (any future data-group repo) that configs.yml does not yet cover. require "English" # $CHILD_STATUS require "shellwords" @@ -80,9 +80,11 @@ title: "Custom", favicon: "custom.ico", description: "Custom desc", ) - expect(branding).to eq( + expect(branding).to include( "title" => "Custom", "favicon" => "custom.ico", "description" => "Custom desc", ) + expect(branding["pubid_flavor"]).to eq("iso") + expect(branding["publish_data"]).to eq("false") end it "treats an explicit blank override as unset" do @@ -97,11 +99,18 @@ end it "falls back to the derived title and no branding for a repo configs.yml omits" do - # relaton-data-ietf gets deploy.yml from Cimas but publishes no document - # index, so it has no configs.yml row (see cimas_data_pages_spec.rb). - # Its result must match what the retired shell derivation produced. - expect(config.branding("relaton/relaton-data-ietf")) - .to eq("title" => "IETF Index", "favicon" => "", "description" => "") + # A data-group repo that has not yet been folded into configs.yml must + # still resolve without raising (the deploy step always runs branding). + expect(config.branding("relaton/relaton-data-nope")) + .to include("title" => "NOPE Index", "favicon" => "", "description" => "", + "pubid_flavor" => "", "publish_data" => "false") + end + + it "resolves ietf with publish_data and the ietf pubid flavor" do + branding = config.branding("relaton/relaton-data-ietf") + expect(branding["title"]).to eq("IETF Index") + expect(branding["pubid_flavor"]).to eq("ietf") + expect(branding["publish_data"]).to eq("true") end it "does not raise for an unknown repo, unlike #entry" do @@ -162,17 +171,28 @@ out = `#{bin.shellescape} relaton/relaton-data-w3c 2>/dev/null` expect($CHILD_STATUS).to be_success - expect(parse.call(out)).to eq( + expect(parse.call(out)).to include( config.branding("relaton/relaton-data-w3c"), ) end it "resolves a repo configs.yml does not cover" do + out = `#{bin.shellescape} relaton/relaton-data-nope 2>/dev/null` + + expect($CHILD_STATUS).to be_success + expect(parse.call(out)).to include( + "title" => "NOPE Index", "favicon" => "", "description" => "", + "pubid_flavor" => "", "publish_data" => "false", + ) + end + + it "emits ietf's pubid_flavor and publish_data" do out = `#{bin.shellescape} relaton/relaton-data-ietf 2>/dev/null` expect($CHILD_STATUS).to be_success - expect(parse.call(out)) - .to eq("title" => "IETF Index", "favicon" => "", "description" => "") + parsed = parse.call(out) + expect(parsed.fetch("pubid_flavor")).to eq("ietf") + expect(parsed.fetch("publish_data")).to eq("true") end it "applies the flags the workflow always passes, blanks included" do