This is an automated email from the ASF dual-hosted git repository.

erose pushed a commit to branch HDDS-9225-website-v2
in repository https://gitbox.apache.org/repos/asf/ozone-site.git


The following commit(s) were added to refs/heads/HDDS-9225-website-v2 by this 
push:
     new 72032e7c HDDS-10349. Add GitHub Actions check for consistent file name 
formatting. (#79)
72032e7c is described below

commit 72032e7c4242ebfc0365feb81e18efc74e3c0c90
Author: Ethan Rose <[email protected]>
AuthorDate: Tue Feb 27 10:10:46 2024 -0800

    HDDS-10349. Add GitHub Actions check for consistent file name formatting. 
(#79)
---
 .github/scripts/file_names.sh                      | 74 ++++++++++++++++++++++
 .github/workflows/static.yml                       |  9 +++
 .../02-integrations/{hive.md => 01-hive.md}        |  0
 .../02-integrations/{hue.md => 02-hue.md}          |  0
 .../02-integrations/{iceberg.md => 03-iceberg.md}  |  0
 .../02-integrations/{impala.md => 04-impala.md}    |  0
 .../02-integrations/{oozie.md => 05-oozie.md}      |  0
 .../02-integrations/{spark.md => 06-spark.md}      |  0
 .../02-integrations/{trino.md => 07-trino.md}      |  0
 .../{placeholder.md => 01-placeholder.md}          |  0
 .../{placeholder.md => 01-placeholder.md}          |  0
 .../{placeholder.md => 01-placeholder.md}          |  0
 12 files changed, 83 insertions(+)

diff --git a/.github/scripts/file_names.sh b/.github/scripts/file_names.sh
new file mode 100755
index 00000000..62303ed2
--- /dev/null
+++ b/.github/scripts/file_names.sh
@@ -0,0 +1,74 @@
+#!/usr/bin/env sh
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Checks all page files and their parent directories to ensure that they use 
docusaurus number prefixes and are named
+# all lower case with kebab-case.
+
+root="$(git rev-parse --show-toplevel)"
+rc=0
+
+dir_regex='[a-z0-9][a-z0-9./-]*[a-z0-9]'
+file_regex="$dir_regex\.mdx?"
+# Pages used for docs should have a two digit number prefix to indicate their 
position in the sidebar.
+# Docusaurus automatically strips this prefix from the links generated from 
file names.
+doc_dir_regex="[0-9][0-9]-$dir_regex"
+doc_file_regex="[0-9][0-9]-$file_regex"
+
+check_regex() {
+    file="$1"
+    regex="$2"
+    if ! basename "$file" | grep -Exq "$regex"; then
+        echo "$file does not match regex '$regex'" 1>&2
+        rc=1
+    fi
+}
+
+is_markdown() {
+    file="$1"
+    # .md is a plain markdown file. .mdx is markdown with embedded Javascript.
+    echo "$(basename "$file")" | grep -Exq '.+\.mdx?'
+}
+
+# Check docs pages. These must use number prefixes.
+for file in $(find "$root"/docs/*); do
+    if [ -d "$file" ]; then
+        # Check docs directories.
+        check_regex "$file" "$doc_dir_regex"
+    elif is_markdown "$file"; then
+        # Check docs files.
+        check_regex "$file" "$doc_file_regex"
+    fi
+done
+
+# Check regular pages. These do not have number prefixes.
+for file in $(find "$root"/src/pages/*); do
+    # Check directories.
+    if [ -d "$file" ]; then
+        check_regex "$file" "$dir_regex"
+    # Check files.
+    elif is_markdown "$file"; then
+        check_regex "$file" "$file_regex"
+    fi
+done
+
+if [ "$rc" != 0 ]; then
+    echo '\nFile and directory names of website pages must be all lower case 
and kebab-case. A two digit number prefix' \
+        'must be used to order docs pages in the sidebar.' 1>&2
+fi
+
+exit "$rc"
diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml
index 7c5b4cc1..98c282de 100644
--- a/.github/workflows/static.yml
+++ b/.github/workflows/static.yml
@@ -32,6 +32,15 @@ env:
   node_version: 20
 
 jobs:
+  file-names:
+    runs-on: ubuntu-latest
+    steps:
+    - name: Checkout project
+      uses: actions/checkout@v4
+    - name: Run file name check
+      working-directory: ${{ env.script_dir }}
+      run: |
+        ./file_names.sh
   spelling:
     runs-on: ubuntu-latest
     steps:
diff --git a/docs/04-user-guide/02-integrations/hive.md 
b/docs/04-user-guide/02-integrations/01-hive.md
similarity index 100%
rename from docs/04-user-guide/02-integrations/hive.md
rename to docs/04-user-guide/02-integrations/01-hive.md
diff --git a/docs/04-user-guide/02-integrations/hue.md 
b/docs/04-user-guide/02-integrations/02-hue.md
similarity index 100%
rename from docs/04-user-guide/02-integrations/hue.md
rename to docs/04-user-guide/02-integrations/02-hue.md
diff --git a/docs/04-user-guide/02-integrations/iceberg.md 
b/docs/04-user-guide/02-integrations/03-iceberg.md
similarity index 100%
rename from docs/04-user-guide/02-integrations/iceberg.md
rename to docs/04-user-guide/02-integrations/03-iceberg.md
diff --git a/docs/04-user-guide/02-integrations/impala.md 
b/docs/04-user-guide/02-integrations/04-impala.md
similarity index 100%
rename from docs/04-user-guide/02-integrations/impala.md
rename to docs/04-user-guide/02-integrations/04-impala.md
diff --git a/docs/04-user-guide/02-integrations/oozie.md 
b/docs/04-user-guide/02-integrations/05-oozie.md
similarity index 100%
rename from docs/04-user-guide/02-integrations/oozie.md
rename to docs/04-user-guide/02-integrations/05-oozie.md
diff --git a/docs/04-user-guide/02-integrations/spark.md 
b/docs/04-user-guide/02-integrations/06-spark.md
similarity index 100%
rename from docs/04-user-guide/02-integrations/spark.md
rename to docs/04-user-guide/02-integrations/06-spark.md
diff --git a/docs/04-user-guide/02-integrations/trino.md 
b/docs/04-user-guide/02-integrations/07-trino.md
similarity index 100%
rename from docs/04-user-guide/02-integrations/trino.md
rename to docs/04-user-guide/02-integrations/07-trino.md
diff --git 
a/docs/05-administrator-guide/02-configuration/02-logging/placeholder.md 
b/docs/05-administrator-guide/02-configuration/02-logging/01-placeholder.md
similarity index 100%
rename from 
docs/05-administrator-guide/02-configuration/02-logging/placeholder.md
rename to 
docs/05-administrator-guide/02-configuration/02-logging/01-placeholder.md
diff --git 
a/docs/05-administrator-guide/02-configuration/04-performance/placeholder.md 
b/docs/05-administrator-guide/02-configuration/04-performance/01-placeholder.md
similarity index 100%
rename from 
docs/05-administrator-guide/02-configuration/04-performance/placeholder.md
rename to 
docs/05-administrator-guide/02-configuration/04-performance/01-placeholder.md
diff --git a/docs/06-troubleshooting/07-integrations/placeholder.md 
b/docs/06-troubleshooting/07-integrations/01-placeholder.md
similarity index 100%
rename from docs/06-troubleshooting/07-integrations/placeholder.md
rename to docs/06-troubleshooting/07-integrations/01-placeholder.md


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to