Skip to content

Commit

Permalink
Enhancing file set check to report xpl and xspec not under CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
wendellpiez committed Oct 19, 2024
1 parent 3ecec1c commit 92c63cb
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 22 deletions.
2 changes: 2 additions & 0 deletions testing/FILESET_XPROC3_HOUSE-RULES.xpl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
<p:document href="../tutorial/PRODUCE-TUTORIAL-MARKDOWN.xpl"/>
<p:document href="../tutorial/SOURCES-PREVIEW.xpl"/>
<p:document href="../tutorial/PRODUCE-TUTORIAL-TOC.xpl"/>
<p:document href="../tutorial/PRODUCE-TUTORIAL-PREVIEW.xpl"/>
<p:document href="../tutorial/PRODUCE-TUTORIAL-ELEMENTLIST.xpl"/>

<p:document href="../smoketest/TEST-XPROC3.xpl"/>
<p:document href="../smoketest/TEST-SCHEMATRON.xpl"/>
Expand Down
56 changes: 43 additions & 13 deletions testing/REPO-FILESET-CHECK.xpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,28 @@
name="REPO-FILESET-CHECK"
>



<!--
High-level validation pipeline for checking the repository against the file sets
We get an early clean fail if any files listed in a file set are not here in the repo
We get an early clean failure if any files listed in a file set are not here in the repository
As a bonus (not an error condition) we get a listing of XProc and XSpec files in the repository
that are *not* in the file list - this does not error, only echoes
Running this in the local repository we can keep track
Running this in the local repository we can keep track of status
Running it under CI/CD, we get an early fail before HARDFAIL batch schematron is run
i.e. no longer have to blow up for a file missing
This is second-best to aligning with git directly
-->

<!-- <p:output port="result" serialization="map{ 'indent': true() }"/> -->
<p:output port="result" serialization="map{ 'indent': true(), 'method': 'text' }"/>

<!-- /prologue -->
<!-- INCIPIT -->

<p:group name="house-rules-check-fileset">
<p:load href="FILESET_XPROC3_HOUSE-RULES.xpl" message="[REPO-FILESET-CHECK] SEEING XProc3 House Rules fileset at FILESET_XPROC3_HOUSE-RULES.xpl"/>
<p:load href="FILESET_XPROC3_HOUSE-RULES.xpl" message="[REPO-FILESET-CHECK] SEEING XProc3 House Rules file set at FILESET_XPROC3_HOUSE-RULES.xpl"/>
<!--<p:filter select="descendant::p:document"/>-->
<p:make-absolute-uris match="@href"/>
</p:group>
Expand Down Expand Up @@ -59,6 +58,10 @@

<!-- Next step annotates the directory structure based on findings passed in -->
<p:xslt name="path-list">
<!-- Map within a map lets us configure the containers dynamically -->
<p:with-option name="parameters" select="map{
'file-lists': map{ 'house-rules': $house-rules-files,
'xspec': $xspec-files } }"/>
<p:with-input port="stylesheet">
<p:inline expand-text="false">
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
Expand Down Expand Up @@ -96,13 +99,9 @@
</xsl:stylesheet>
</p:inline>
</p:with-input>
<p:with-option name="parameters" select="map{
'file-lists': map{ 'house-rules': $house-rules-files,
'xspec': $xspec-files } }"/>
</p:xslt>

<p:namespace-delete prefixes="c p ox"/>
<p:namespace-delete prefixes="c p ox map" xmlns:map="http://www.w3.org/2005/xpath-functions/map"/>

<p:choose>
<p:when test="exists(descendant::document[@in-place='false'])">
Expand All @@ -116,8 +115,39 @@
<p:identity message="[REPO-FILESET-CHECK] File sets for validation check out on this system - TESTING SYSTEMS GO"/>
</p:otherwise>
</p:choose>



<!-- Next, report //file[empty(@house-rules|@xspec)] -->
<p:xslt name="summary">
<p:with-input port="stylesheet">
<p:inline expand-text="false">
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*"/>
<xsl:mode on-no-match="shallow-skip"/>
<xsl:template match="/*">
<xsl:text>Files currently not under CI/CD (not referenced in file sets):</xsl:text>
<xsl:sequence>
<xsl:apply-templates select="descendant::file[empty(@house-rules|@xspec)]"/>
<xsl:on-empty>
<xsl:text> [None found - nicely done]&#xA;</xsl:text>
</xsl:on-empty>
</xsl:sequence>
</xsl:template>
<xsl:template match="file">
<xsl:value-of select="'&#xA;' || ' ' || @path"/>
</xsl:template>
</xsl:stylesheet>
</p:inline>
</p:with-input>
</p:xslt>

<!-- <p:viewport match="file">
<p:identity>
<p:with-input>
<file>{ /*/@path}&#xA;</file>
</p:with-input>
</p:identity>
</p:viewport>-->

<p:identity name="final"/>

</p:declare-step>
Expand Down
3 changes: 1 addition & 2 deletions testing/xproc3-house-rules.sch
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
<sch:let name="fileset-doc" value="document('FILESET_XPROC3_HOUSE-RULES.xpl')"/>
<sch:let name="listed-uris" value="$fileset-doc/p:*/p:input[@port='source']/p:document/@href ! resolve-uri(.,base-uri(../..))"/>


<!--file:/C:/Users/wap1/Documents/usnistgov/oscal-xproc3
testing/FILESET_XPROC3_HOUSE-RULES.xpl
../projects/schema-field-tests/reference-sets/catalog-model/CONVERT-XML-REFERENCE-SET.xpl
Expand Down Expand Up @@ -102,7 +101,7 @@

<sch:assert sqf:fix="sqf-exempt-from-houserules-check" role="warning" test="base-uri(.) = $listed-uris or exists(p:documentation[contains(.,'HALL PASS') and contains(.,'HOUSE RULES')])">file <sch:value-of select="$filename"/> isn't listed in validation set maintained in <sch:value-of select="$fileset-resource-path"/> - should it be?</sch:assert>
<sch:let name="unexpected-prefixes" value="in-scope-prefixes(.)[not(.=('','p','c','ox','xml','xsl','x','xs','html','svrl','xvrl'))]"/>
<sch:report test="$unexpected-prefixes => exists()">We want to see only 'p', 'c' and 'ox', 'xsl' and 'x' namespace prefixes assigned at the top of an XProc (so far, for this repository): this file has <sch:value-of select="$unexpected-prefixes => string-join(', ')"/></sch:report>
<sch:report test="$unexpected-prefixes => exists()">This repo is keeping a list of recognized namespace prefixes, which does not include <sch:value-of select="$unexpected-prefixes => string-join(', ')"/></sch:report>
<sch:assert sqf:fix="sqf-make-version-3" test="@version = '3.0'">Expecting XProc 3.0, not <sch:value-of select="@version"/></sch:assert>
</sch:rule>
<sch:rule context="p:documentation[contains(.,'HALL PASS') and contains(.,'HOUSE RULES')]">
Expand Down
4 changes: 2 additions & 2 deletions tutorial/PRODUCE-TUTORIAL-ELEMENTLIST.xpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:ox="http://csrc.nist.gov/ns/oscal-xproc3" type="ox:PRODUCE-TUTORIAL-ELEMENTLIST" name="PRODUCE-TUTORIAL-TOC">
xmlns:ox="http://csrc.nist.gov/ns/oscal-xproc3" type="ox:PRODUCE-TUTORIAL-ELEMENTLIST" name="PRODUCE-TUTORIAL-ELEMENTLIST">

<!-- PRODUCE-TUTORIAL-ELEMENTLIST produces an XML file
Expand Down Expand Up @@ -170,7 +170,7 @@
</p:xslt>

<p:store href="{$result-md-path}" serialization="map{'method': 'text', 'encoding': 'us-ascii'}"
message="[PRODUCE-TUTORIAL-TOC] [PRODUCE-TUTORIAL-MARKDOWN] Storing { $result-md-path }"/>
message="[PRODUCE-TUTORIAL-ELEMENTLIST] Storing { $result-md-path }"/>

<!--<p:identity message="[PRODUCE-TUTORIAL-MARKDOWN] Storing { $result-md-path }"/>-->

Expand Down
9 changes: 4 additions & 5 deletions tutorial/PRODUCE-TUTORIAL-PREVIEW.xpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:c="http://www.w3.org/ns/xproc-step"
version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ox="http://csrc.nist.gov/ns/oscal-xproc3"
type="ox:TUTORIAL-PAGE"
type="ox:PRODUCE-TUTORIAL-PREVIEW"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:html="http://www.w3.org/1999/xhtml"

name="TUTORIAL-PAGE">
name="PRODUCE-TUTORIAL-PREVIEW">


<!--<p:output port="tutorial-singlepage" serialization="map{'indent': true() }" sequence="true"/>-->
Expand Down Expand Up @@ -67,7 +66,7 @@
<p:variable name="project-uri" select="p:urify('.')"/>
<p:variable name="lesson-no" select="format-number(p:iteration-position(),'01')"/>
<!--<p:identity message="[PRODUCE-TUTORIAL-MARKDOWN] Loading {$path} "/>-->
<p:load href="{$path}" message="[TUTORIAL-PAGE] Loading {$path} "/>
<p:load href="{$path}" message="[PRODUCE-TUTORIAL-PREVIEW] Loading {$path} "/>

<p:filter select="//body"/>
<p:add-attribute attribute-name="id"
Expand Down Expand Up @@ -153,6 +152,6 @@

<p:namespace-delete prefixes="xsl ox c"/>

<p:store href="tutorial-preview.html" message="[TUTORIAL-PAGE] Storing tutorial-preview.html" serialization="map{ 'method': 'html', 'indent': true() }"/>
<p:store href="tutorial-preview.html" message="[PRODUCE-TUTORIAL-PREVIEW] Storing tutorial-preview.html" serialization="map{ 'method': 'html', 'indent': true() }"/>

</p:declare-step>

0 comments on commit 92c63cb

Please sign in to comment.