Skip to content

Commit

Permalink
lints
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed May 19, 2024
1 parent e4d4144 commit 618ef1d
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 53 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/actionlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# MIT License
#
# Copyright (c) 2024 Zerocracy
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
---
name: actionlint
'on':
push:
branches:
- master
pull_request:
branches:
- master
jobs:
actionlint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Download actionlint
id: get_actionlint
# yamllint disable-line rule:line-length
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
shell: bash
- name: Check workflow files
run: ${{ steps.get_actionlint.outputs.executable }} -color
shell: bash
4 changes: 3 additions & 1 deletion .github/workflows/make.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: sudo wget --no-verbose -O /usr/local/Saxon.jar https://repo.maven.apache.org/maven2/net/sf/saxon/Saxon-HE/9.8.0-5/Saxon-HE-9.8.0-5.jar
- run: |
sudo wget --no-verbose -O /usr/local/Saxon.jar \
https://repo.maven.apache.org/maven2/net/sf/saxon/Saxon-HE/9.8.0-5/Saxon-HE-9.8.0-5.jar
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# MIT License
#
# Copyright (c) 2024 Zerocracy
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
---
name: yamllint
'on':
push:
branches:
- master
pull_request:
branches:
- master
jobs:
yamllint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: ibiqlik/action-yamllint@v3
30 changes: 14 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,24 @@

.SHELLFLAGS: -c
.ONESHELL:
.PHONY: clean entry test
SAXON=/usr/local/Saxon.jar
.PHONY: clean

entry: target/foo.fb test
YAMLS = $(wildcard tests/*.yml)
FBS = $(subst tests/,target/fb/,${YAMLS:.yml=.fb})
HTMLS = $(subst fb/,html/,${FBS:.fb=.html})

all: $(HTMLS)

target/html/%.html: target/fb/%.fb
export INPUT_VERBOSE=yes
export GITHUB_WORKSPACE=.
export INPUT_FACTBASE=target/foo.fb
export INPUT_PAGES=target/pages
export INPUT_FACTBASE=$<
export INPUT_PAGES=$$(dirname $@)
./entry.sh

target/foo.fb: Makefile
mkdir -p target/judges/foo
echo '$$fb.insert.foo = 42' > target/judges/foo/foo.rb
judges update --max-cycles 5 target/judges $@

test:
mkdir -p target/html
for i in $$(ls tests/*.xml); do
name=$$(basename "$${i%.*}")
java -jar "$(SAXON)" "-s:$${i}" -xsl:xsl/index.xsl "-o:target/html/$${name}.html"
done
target/fb/%.fb: tests/%.yml
mkdir -p target/fb
judges import $< $@

clean:
rm -rf target
11 changes: 7 additions & 4 deletions entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ set -x
set -o pipefail

SAXON=/usr/local/Saxon.jar

export GLI_DEBUG=true
if [ ! -e "${SAXON}" ]; then
echo "There is not Saxon JAR at this path: ${SAXON}."
echo "Because of this, XSLT transformations won't work."
exit 1
fi

# Convert the factbase to a few human-readable formats
if [ -z "${GITHUB_WORKSPACE}" ]; then
Expand All @@ -40,6 +43,7 @@ cd "${GITHUB_WORKSPACE}"
declare -a gopts=()
if [ -n "${INPUT_VERBOSE}" ]; then
gopts+=("--verbose")
export GLI_DEBUG=true
fi

# Convert the factbase to a few human-readable formats
Expand All @@ -60,5 +64,4 @@ done
# Build a summary HTML.
index="${INPUT_FACTBASE%.*}.${f}"
judges "${gopts[@]}" print --format xml "${INPUT_FACTBASE}" "${index}"
java -jar ${SAXON} "-s:${index}" -xsl:xsl/index.xsl "-o:${INPUT_FACTBASE%.*}.html"

java -jar ${SAXON} "-s:${index}" -xsl:xsl/index.xsl "-o:${INPUT_FACTBASE%.*}.html" -Tnormal version=0.0.0
22 changes: 0 additions & 22 deletions tests/simple.xml

This file was deleted.

19 changes: 19 additions & 0 deletions tests/simple.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
-
time: 2024-05-18T22:22:22.8492Z
award: 15
payee: yegor256
reason: for being a good boy
href: https://github.com/yegor256/judges/issues/111
-
time: 2024-05-15T22:22:22.8492Z
award: -24
payee: yegor256
reason: for being a bad boy
href: https://github.com/yegor256/judges/issues/111
-
time: 2024-05-15T22:22:22.8492Z
award: 55
payee: torvalds
reason: for new release
href: https://github.com/yegor256/judges/issues/111
15 changes: 5 additions & 10 deletions xsl/index.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,13 @@ SOFTWARE.
<xsl:text>The page was generated by the </xsl:text>
<a href="https://github.com/zerocracy/pages-action">
<xsl:text>pages-action</xsl:text>
<xsl:text> </xsl:text>
<xsl:value-of select="$version"/>
</a>
<xsl:text> plugin at </xsl:text>
<xsl:text> plugin (</xsl:text>
<xsl:value-of select="$version"/>
<xsl:text>) on </xsl:text>
<xsl:value-of select="fb/@dob"/>
<xsl:text>, factbase version is </xsl:text>
<br/>
<xsl:text>The numbers you see reflect the activity of the last </xsl:text>
<b>
<xsl:value-of select="cobench/@days"/>
<xsl:text> days</xsl:text>
</b>
<xsl:text>; factbase version is </xsl:text>
<xsl:value-of select="fb/@factbase_version"/>
<xsl:text>.</xsl:text>
<br/>
<xsl:text>The XML with the data </xsl:text>
Expand Down

0 comments on commit 618ef1d

Please sign in to comment.