Skip to content

Commit 23663df

Browse files
CCM-14029 Centralise Precommits & GHAs
1 parent 4415244 commit 23663df

2 files changed

Lines changed: 59 additions & 23 deletions

File tree

.github/actions/check-todo-usage/check-todos.sh

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,39 @@ set -euo pipefail
2525

2626
# ==============================================================================
2727

28-
EXCLUDED_FILES=(
29-
".devcontainer/devcontainer.json"
30-
".pre-commit-hooks.yaml"
31-
".tool-versions"
32-
".vscode/extensions.json"
33-
"infrastructure/terraform/bin/terraform.sh"
34-
"Makefile"
35-
"project.code-workspace"
36-
"src/jekyll-devcontainer/src/.devcontainer/devcontainer.json"
37-
)
38-
39-
EXCLUDED_DIRS=(
40-
".git/"
41-
".venv/"
42-
"docs/"
43-
"node_modules/"
44-
)
28+
CONFIG_FILE="scripts/config/check-todos-ignore.conf"
29+
30+
# Arrays to be populated from config file
31+
EXCLUDED_FILES=()
32+
EXCLUDED_DIRS=()
33+
34+
35+
# Load exclusions from configuration file
36+
function load_exclusions_from_config() {
37+
local config_file="$1"
38+
local section=""
39+
40+
while IFS= read -r line || [ -n "$line" ]; do
41+
# Skip empty lines and comments
42+
[[ -z "$line" || "$line" =~ ^[[:space:]]*# ]] && continue
43+
44+
# Check for section headers
45+
if [[ "$line" =~ ^\[([^]]+)\]$ ]]; then
46+
section="${BASH_REMATCH[1]}"
47+
continue
48+
fi
49+
50+
# Add entries to appropriate arrays based on current section
51+
case "$section" in
52+
files)
53+
EXCLUDED_FILES+=("$line")
54+
;;
55+
directories)
56+
EXCLUDED_DIRS+=("$line")
57+
;;
58+
esac
59+
done < "$config_file"
60+
}
4561

4662

4763
# Get files to check based on mode
@@ -69,12 +85,7 @@ function get_files_to_check() {
6985

7086

7187
function build_exclude_args() {
72-
local args=(
73-
--exclude=".github/actions/check-todo-usage/action.yaml"
74-
--exclude=".github/workflows/stage-1-commit.yaml"
75-
--exclude="scripts/config/pre-commit.yaml"
76-
--exclude="scripts/githooks/check-todos.sh"
77-
) # Exclude this script and its references by default, as it naturally contains TODOs. Todo todo todo <- see?
88+
local args=() # Exclusions are now loaded from config file
7889

7990
if [ ${#EXCLUDED_DIRS[@]} -gt 0 ]; then
8091
for dir in "${EXCLUDED_DIRS[@]}"; do
@@ -204,6 +215,9 @@ function print_output() {
204215
function main() {
205216
cd "$(git rev-parse --show-toplevel)"
206217

218+
# Load exclusions from config file
219+
load_exclusions_from_config "$CONFIG_FILE"
220+
207221
local check_mode="${check:-working-tree-changes}"
208222
local exclude_args=$(build_exclude_args)
209223
local todos=$(search_todos "$check_mode" $exclude_args)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Configuration file for check-todos.sh
2+
3+
[files]
4+
.devcontainer/devcontainer.json
5+
.github/workflows/stage-1-commit.yaml
6+
.pre-commit-hooks.yaml
7+
.tool-versions
8+
.vscode/extensions.json
9+
infrastructure/terraform/bin/terraform.sh
10+
Makefile
11+
project.code-workspace
12+
scripts/config/check-todos-ignore.conf
13+
scripts/config/pre-commit.yaml
14+
scripts/githooks/check-todos.sh
15+
src/jekyll-devcontainer/src/.devcontainer/devcontainer.json
16+
17+
[directories]
18+
.git/
19+
.github/actions/check-todo-usage/
20+
.venv/
21+
docs/
22+
node_modules/

0 commit comments

Comments
 (0)