55
66name : compile and test
77
8- on : [push, pull_request]
8+ on :
9+ push :
10+ # branches-ignore:
11+ # - 'ref/pull/**'
12+ workflow_dispatch :
13+
14+ # concurrency:
15+ # group: lint-${{ github.event.pull_request.number || github.sha }}
16+ # cancel-in-progress: true
917
1018jobs :
11- build :
19+ lint :
1220 runs-on : ubuntu-latest
13- strategy :
14- matrix :
15- java-version : [11, 21]
1621
1722 steps :
18- # Checkout code fetch-depth significantly impacts performance
19- - uses : actions/checkout@v4
20- with :
21- fetch-depth : 15
2223 - name : Install Test Dependencies
2324 run : |
2425 sudo apt-get update
25- sudo apt-get install -y libxml2-utils libsaxonhe-java
26-
27- # - name: Where is Saxon
28- # run: dpkg -L libsaxonhe-java
26+ sudo apt-get install -y libxml2-utils
2927
30- - name : Create Toc
31- run : |
32- mkdir -p frus-toc
33- java -jar /usr/share/java/Saxon-HE.jar -s:volumes/ -xsl:modules/lib/frus-toc.xsl -o:frus-toc/ -it:main
34-
35- - name : Get changed files
36- id : changed-files
37- run : |
38- echo "changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
39-
40- - name : Create xml files in .last-modified folder
41- run : |
42- for file in ${{ steps.changed-files.outputs.changed_files }}; do
43- # Skip files in hidden folders (starting with .)
44- if [[ "$file" =~ ^\..*/ ]]; then
45- continue
46- fi
47-
48- if [ ! -f "$file" ]; then
49- echo "Error: File '$file' does not exist" >&2
50- return 1
51- fi
52-
53- # Get last commit date in ISO format
54- if ! iso=$(git log -1 --format=%cd --date=format-local:'%Y-%m-%dT%H:%M:%S%z' "$file"); then
55- echo "Error: Failed to get git log for '$file'" >&2
56- return 1
57- fi
58- if ! datetime=$(git log -1 --format=%cd --date=iso-strict-local "$file"); then
59- echo "Error: Failed to get git log for '$file'" >&2
60- return 1
61- fi
62-
63- # Create output directory structure
64- dir=$(dirname ".last-modified/$file")
65- if ! mkdir -p "$dir"; then
66- echo "Error: Failed to create directory '$dir'" >&2
67- return 1
68- fi
69-
70- # Replace any forward slashes in path with underscores for xml:id
71- xml_id=${file//\//0x2F}
72-
73- # Convert date to seconds since epoch
74- if [[ "$OSTYPE" == "darwin"* ]]; then
75- if ! seconds_since_epoch=$(date -j -f "%Y-%m-%dT%H:%M:%S%z" "$iso" "+%s"); then
76- echo "Error: Failed to convert date for '$file'" >&2
77- return 1
78- fi
79- else
80- if ! seconds_since_epoch=$(date -d "$iso" +%s); then
81- echo "Error: Failed to convert date for '$file'" >&2
82- return 1
83- fi
84- fi
85-
86- # Write XML files
87- if ! echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > ".last-modified/$file"; then
88- echo "Error: Failed to write XML header for '$file'" >&2
89- return 1
90- fi
91-
92- if ! echo "<last-modified xml:id=\"$xml_id\" seconds_since_epoch=\"$seconds_since_epoch\">$datetime</last-modified>" >> ".last-modified/$file"; then
93- echo "Error: Failed to write XML content for '$file'" >&2
94- return 1
95- fi
96- echo "Successfully created .last-modified/$file"
97- done
98-
99- # sanity check
100- - name : What happened
101- run : git status
28+ # Checkout code fetch-depth significantly impacts performance
29+ - uses : actions/checkout@v4
30+ with :
31+ fetch-depth : 1
10232
10333 # TODO(DP) Validate ?
10434 - name : Ensure all XML files are well-formed
10535 run : |
10636 xmllint --noout \
10737 $(find . -type f -name '*.xml')
10838
39+ # Lint commit messages
40+ - name : lint commit message
41+ uses : wagoid/commitlint-github-action@v6
42+ build :
43+ runs-on : ubuntu-latest
44+ strategy :
45+ fail-fast : false
46+ matrix :
47+ exist-version : [latest, release]
48+ java-version : [11, 21]
49+ exclude :
50+ - exist-version : release
51+ java-version : 21
52+ - exist-version : latest
53+ java-version : 11
54+ steps :
55+ - name : Checkout (sparse)
56+ uses : actions/checkout@v4
57+ with :
58+ fetch-depth : 1
10959 - name : Build Expath Package
11060 uses : actions/setup-java@v4
11161 with :
@@ -129,16 +79,6 @@ jobs:
12979 path : tests/bats/
13080 if-no-files-found : ignore
13181
132- # Lint commit messages
133- - name : lint commit message
134- uses : wagoid/commitlint-github-action@v6
135-
136- # Commit generated files
137- - name : Commit and Push
138- if : ${{ matrix.java-version == 21 && github.event_name == 'push' && github.ref != 'refs/heads/master' }}
139- uses : actions-x/commit@v6
140- with :
141- message : " fix(toc): update [skip ci]"
14282 test :
14383 runs-on : ubuntu-latest
14484 needs : build
0 commit comments