Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the HTML schema #1589

Merged
merged 3 commits into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 36 additions & 15 deletions src/build/update-validator-schemas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ LAST_UPDATE_FILE=$EPUBCHECK_DIR/src/main/resources/com/adobe/epubcheck/schema/30
if [ ! -f "$LAST_UPDATE_FILE" ]; then
error_exit "could not find the last commit sha-1; make sure you are in the EPUBCheck git repository"
fi
LAST_SHA1=`cat $LAST_UPDATE_FILE`
SHA_LAST_UPDATE=`cat $LAST_UPDATE_FILE`

## Move to validator.nu repo
echo "Moving to the validator.nu repository"
Expand All @@ -55,22 +55,23 @@ fi
echo "Fetching new commits from remote '$UPSTREAM'"
git fetch $UPSTREAM

## Create patches since last update (to the `latest` tag)
echo "Creating paches of changes since the last update"
git format-patch -o $EPUBCHECK_DIR/ $LAST_SHA1..latest schema
## Get the SHA-1 of the SHA_VALIDATOR_LATEST revision on upstream
SHA_VALIDATOR_LATEST=`git rev-list -n 1 $UPSTREAM/main`
echo $SHA_VALIDATOR_LATEST

## Get the SHA-1 of the `latest` tag
LATEST=`git rev-list -n 1 latest`
echo $LATEST
## Create patches since last update (to the `SHA_VALIDATOR_LATEST` tag)
echo "Creating paches of changes since the last update"
git format-patch -o $EPUBCHECK_DIR/ $SHA_LAST_UPDATE..$SHA_VALIDATOR_LATEST schema

## Move to EPUBCheck repo
echo "Moving back to the EPUBCheck repository"
cd "$EPUBCHECK_DIR" # let's move to the validator repo

## Edit the LAST_UPDATE file
echo $LATEST > $LAST_UPDATE_FILE
echo $SHA_VALIDATOR_LATEST > $LAST_UPDATE_FILE
git add $LAST_UPDATE_FILE
git ci -m "feat: update to latest schemas from the Nu HTML Checker"
SHA_BEFORE_PATCH=`git rev-list -n 1 HEAD`

## Update the paths in patches to the EPUBCheck location
echo "Updating paths in patch files"
Expand All @@ -80,10 +81,30 @@ sed -i "" -E "/^(diff|---|\+\+\+) / s:/schema/:/src/main/resources/com/adobe/ep
echo "Applying the patches"
git am *.patch

## FROM HERE ON, THE INTERACTIVE APPLICATION OF PATCHES MAY EXIT THE SCRIPT

# Remaing tasks:
# - commit new last commit ID
# - squash commits (add "Co-Authored by" credits)
# `git log --pretty=format:"---------------------%n%n%s%n%nhttps://github.com/validator/validator/commit/%h%n%nCo-authored-by: %aN <%aE>%n" $LAST-SHA1..latest schema``
# - remove patch files
###
echo ""
echo "WARNING! From here on, the interactive application of patches may exit the script."
echo ""
###

SHA_AFTER_PATCH=`git rev-list -n 1 HEAD`

## Build a commit message
## - with proper credits to original committers
## - replacing issue references to the validator repo
echo "Creating the consolidated commit message"
printf "feat: update to latest schemas from the Nu HTML Checker\n\n" > commit-message.txt
git log \
--pretty=format:"---------------------%n%n%s%n%nhttps://github.com/validator/validator/commit/%h%n%nCo-authored-by: %aN <%aE>%n" \
$SHA_BEFORE_PATCH..$SHA_AFTER_PATCH \
| sed -E "s/#([0-9]+)/validator\/validator\/#\1/" >> commit-message.txt

## Squash the patch commits
echo "Consolidating the commits"
git reset --soft $SHA_BEFORE_PATCH~1
git ci -F commit-message.txt

## Clean up the files
echo "Cleaning the patch files"
rm *.patch
rm commit-message.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b118bf6031b0b06797f3ccdc25d0f74c1447139a
9855955c12fa95b0b452ddf62ca731172b5c7cea
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace local = ""
| common.attrs.aria.role.checkbox
| common.attrs.aria.role.img
| common.attrs.aria.role.link
| common.attrs.aria.role.math
| common.attrs.aria.role.menuitem
| common.attrs.aria.role.menuitemcheckbox
| common.attrs.aria.role.menuitemradio
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
| common.attrs.aria.role.doc-dedication
| common.attrs.aria.role.doc-example
| common.attrs.aria.role.doc-footnote
| common.attrs.aria.role.doc-glossary
| common.attrs.aria.role.doc-pullquote
| common.attrs.aria.role.doc-tip
)?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,6 @@ Feature: EPUB 3 — Content Documents — XHTML
Then error RSC-005 is reported
And the message contains 'attribute "aria-describedat" not allowed here'
And no other errors or warnings are reported

Scenario: Verify the DPUB-ARIA roles allowed on `a`
When checking document 'aria-roles-img-valid.xhtml'
Then no errors or warnings are reported

Scenario: Verify the DPUB-ARIA roles allowed on `aside`
When checking document 'aria-roles-img-valid.xhtml'
Then no errors or warnings are reported

Scenario: Verify the DPUB-ARIA roles allowed on `footer`
When checking document 'aria-roles-footer-valid.xhtml'
Expand All @@ -162,10 +154,6 @@ Feature: EPUB 3 — Content Documents — XHTML
When checking document 'aria-roles-header-valid.xhtml'
Then no errors or warnings are reported

Scenario: Verify the DPUB-ARIA roles allowed on `hr`
When checking document 'aria-roles-header-valid.xhtml'
Then no errors or warnings are reported

Scenario: Verify the DPUB-ARIA roles allowed on `img`
When checking document 'aria-roles-img-valid.xhtml'
Then no errors or warnings are reported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<title>DPUB-ARIA roles allowed on img</title>
</head>
<body>
<img role="doc-cover" src="test.jpg" alt="okay"/>
<img role="doc-cover" src="cover.jpg" alt="cover"/>
<img role="math" src="math.jpg" alt="math"/>
</body>
</html>
Loading