-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #183 from 18F/develop
10x final sync before P3 close-out
- Loading branch information
Showing
16 changed files
with
2,504 additions
and
2,359 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,43 +17,39 @@ jobs: | |
# Check-out the repository under $GITHUB_WORKSPACE | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- run: | | ||
git submodule update --init --recursive | ||
|
||
# Install Saxon HE to /tmp | ||
- name: Install Saxon HE | ||
run: | | ||
echo "Installing Saxon" | ||
mkdir -p /tmp/saxon | ||
echo "Dowloading Saxon" | ||
export SAXON_CP=/tmp/saxon/Saxon-HE-10.2.jar | ||
wget -O "${SAXON_CP}" https://repo1.maven.org/maven2/net/sf/saxon/Saxon-HE/10.2/Saxon-HE-10.2.jar | ||
echo "saxon_cp is ${SAXON_CP}" | ||
- name: Read node version from `.nvmrc` file | ||
id: nvmrc | ||
uses: browniebroke/read-nvmrc-action@v1 | ||
|
||
- name: Install required node.js version | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: "${{ steps.nvmrc.outputs.node_version }}" | ||
|
||
# Run XSpec after the dependencies are completed | ||
- name: Run XSpec | ||
# Initialize the workspace with submodules and dependencies. | ||
- name: Initialize workspace | ||
run: make init | ||
|
||
- name: Run test suite | ||
run: | | ||
echo "Running XSpec" | ||
cd $GITHUB_WORKSPACE/src/validations | ||
export SAXON_CP=/tmp/saxon/Saxon-HE-10.2.jar | ||
export TEST_DIR=$(pwd)/report/test | ||
$GITHUB_WORKSPACE/vendor/xspec/bin/xspec.sh -s -j test/test_all.xspec | ||
make test-web test-validations | ||
# Sets the test report path for visibility | ||
- name: Publish XSpec Test Results | ||
uses: mikepenz/action-junit-report@v1 | ||
with: | ||
report_paths: '**/report/test/*junit.xml' | ||
report_paths: "**/report/test/*junit.xml" | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# publish the test summary as comment on the PR | ||
# Publish the test summary as comment on the PR | ||
- name: Publish XSpec Test Results Summary | ||
uses: EnricoMi/[email protected] | ||
if: always() | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
check_name: XSpec Test Results | ||
files: '**/report/test/*junit.xml' | ||
files: "**/report/test/*junit.xml" | ||
report_individual_runs: true | ||
deduplicate_classes_by_file_name: false | ||
|
||
|
@@ -64,4 +60,4 @@ jobs: | |
path: | | ||
./src/validations/report/schematron/**/*.* | ||
./src/validations/report/test/**/*.* | ||
if-no-files-found: error | ||
if-no-files-found: error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
test-examples: test-example-java test-example-python ## Test example code projects | ||
|
||
test-example-java: ## Test example Java project | ||
@echo "Verifying Java example..." | ||
cd src/examples/java && \ | ||
docker-compose run example mvn test | ||
|
||
test-example-python: ## Test example Python project | ||
@echo "Verifying Python example..." | ||
cd src/examples/python && \ | ||
docker-compose run example pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
import sys | ||
import xml.etree.ElementTree as ET | ||
|
||
|
||
def assert_svrl(svrl_string): | ||
root = ET.fromstring(svrl_string) | ||
failed_asserts = root.findall('{http://purl.oclc.org/dsdl/svrl}failed-assert') | ||
for failed_assert in failed_asserts: | ||
text = failed_assert.find('{http://purl.oclc.org/dsdl/svrl}text').text | ||
diagnostic = failed_assert.find('{http://purl.oclc.org/dsdl/svrl}diagnostic-reference').text | ||
location = failed_assert.get('location') | ||
print(f"""* failed-assert at {location} | ||
{text} | ||
{diagnostic} | ||
""") | ||
print(f'Found {len(failed_asserts)} failed assertions') | ||
return len(failed_asserts) | ||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser(prog='assert_svrl') | ||
parser.add_argument('file_name') | ||
arguments = parser.parse_args(sys.argv[1:]) | ||
with open(arguments.file_name, 'r') as f: | ||
svrl_string = f.read() | ||
assertion_count = assert_svrl(svrl_string) | ||
sys.exit(assertion_count) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
set -euxo pipefail | ||
|
||
SOURCE=$1 | ||
DESTINATION=$2 | ||
|
||
echo "Preprocessing stage 1/3 of ${SOURCE}..." | ||
STAGE_1=$(mktemp) | ||
java -cp "${SAXON_CP}" net.sf.saxon.Transform \ | ||
-o:"${STAGE_1}" \ | ||
-s:"${SOURCE}" \ | ||
"${BASE_DIR}/vendor/schematron/trunk/schematron/code/iso_dsdl_include.xsl" \ | ||
${SAXON_OPTS} | ||
|
||
echo "Preprocessing stage 2/3 of ${SOURCE}..." | ||
STAGE_2=$(mktemp) | ||
java -cp "${SAXON_CP}" net.sf.saxon.Transform \ | ||
-o:"${STAGE_2}" \ | ||
-s:"${STAGE_1}" \ | ||
"${BASE_DIR}/vendor/schematron/trunk/schematron/code/iso_abstract_expand.xsl" \ | ||
${SAXON_OPTS} | ||
|
||
echo "Preprocessing stage 3/3 of ${SOURCE}..." | ||
java -cp "${SAXON_CP}" net.sf.saxon.Transform \ | ||
-o:"${DESTINATION}" \ | ||
-s:"${STAGE_2}" \ | ||
"${BASE_DIR}/vendor/schematron/trunk/schematron/code/iso_svrl_for_xslt2.xsl" \ | ||
${SAXON_OPTS} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
set -euxo pipefail | ||
|
||
SOURCE_XSL=$1 | ||
SOURCE_XML=$2 | ||
SVRL_DESTINATION=$3 | ||
|
||
java -cp "${SAXON_CP}" net.sf.saxon.Transform \ | ||
-o:"${SVRL_DESTINATION}" \ | ||
-s:"${SOURCE_XML}" \ | ||
"${SOURCE_XSL}" \ | ||
${SAXON_OPTS} | ||
if "${BASE_DIR}/src/validations/bin/assert-svrl.py" "${SVRL_DESTINATION}" ; then | ||
echo "Schematron evaluation succeeded" | ||
exit 0 | ||
else | ||
echo "Schematron evaluation failed" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
SAXON_VERSION := 10.5 | ||
SAXON_JAR := Saxon-HE-$(SAXON_VERSION).jar | ||
SAXON_LOCATION := saxon/Saxon-HE/$(SAXON_VERSION)/$(SAXON_JAR) | ||
SAXON_URL := https://repo1.maven.org/maven2/net/sf/$(SAXON_LOCATION) | ||
export SAXON_OPTS = allow-foreign=true diagnose=true | ||
export SAXON_CP = $(BASE_DIR)/vendor/$(SAXON_JAR) | ||
|
||
VALIDATIONS_DIR := $(BASE_DIR)/src/validations | ||
|
||
COMPILE_SCH := $(VALIDATIONS_DIR)/bin/compile-sch.sh | ||
EVAL_SCHEMATRON := $(VALIDATIONS_DIR)/bin/evaluate-compiled-schematron.sh | ||
EVAL_XSPEC := TEST_DIR=$(VALIDATIONS_DIR)/report/test $(BASE_DIR)/vendor/xspec/bin/xspec.sh -s -j | ||
|
||
init-validations: $(SAXON_CP) ## Initialize validations dependencies | ||
|
||
$(SAXON_CP): ## Download Saxon-HE to the vendor directory | ||
curl -H "Accept: application/zip" -o "$(SAXON_CP)" "$(SAXON_URL)" &> /dev/null | ||
|
||
clean-validations: ## Clean validations artifact | ||
@echo "Cleaning validations..." | ||
rm -rf $(VALIDATIONS_DIR)/target | ||
git clean -xfd $(VALIDATIONS_DIR)/report | ||
|
||
test-validations: $(SAXON_CP) test-xspec test-sch ## Test validations | ||
|
||
test-xspec: $(VALIDATIONS_DIR)/test/test_all.xspec | ||
$(EVAL_XSPEC) $^ | ||
|
||
$(VALIDATIONS_DIR)/target/%.sch.xsl: $(VALIDATIONS_DIR)/styleguides/%.sch | ||
$(COMPILE_SCH) $^ $@ | ||
|
||
$(VALIDATIONS_DIR)/report/test/%.svrl.xml: $(VALIDATIONS_DIR)/target/%.sch.xsl $(VALIDATIONS_DIR)/rules/ssp.sch | ||
$(EVAL_SCHEMATRON) $^ $@ | ||
|
||
test-sch: $(VALIDATIONS_DIR)/report/test/sch.svrl.xml $(VALIDATIONS_DIR)/report/test/xspec.svrl.xml | ||
|
||
$(VALIDATIONS_DIR)/target/ssp.xsl: $(VALIDATIONS_DIR)/rules/ssp.sch | ||
@echo "Building Schematron validations..." | ||
$(COMPILE_SCH) $^ $@ | ||
|
||
build-validations: $(SAXON_CP) $(VALIDATIONS_DIR)/target/ssp.xsl ## Build Schematron validations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.