Skip to content

Commit c49f0e5

Browse files
Merge pull request #150 from NHSDigital/CCM-14029_CentralisePrecommitGHAs
CCM-14029 centralise precommit gh as
2 parents c0d351d + 55f7499 commit c49f0e5

220 files changed

Lines changed: 272 additions & 1243 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/check-english-usage/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ runs:
77
shell: bash
88
run: |
99
export BRANCH_NAME=origin/${{ github.event.repository.default_branch }}
10-
check=branch ./scripts/githooks/check-english-usage.sh
10+
check=branch ${{ github.action_path }}/check-english-usage.sh
File renamed without changes.

.github/actions/check-file-format/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ runs:
77
shell: bash
88
run: |
99
export BRANCH_NAME=origin/${{ github.event.repository.default_branch }}
10-
check=branch ./scripts/githooks/check-file-format.sh
10+
check=branch ${{ github.action_path }}/check-file-format.sh
File renamed without changes.

.github/actions/check-markdown-format/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ runs:
77
shell: bash
88
run: |
99
export BRANCH_NAME=origin/${{ github.event.repository.default_branch }}
10-
check=branch ./scripts/githooks/check-markdown-format.sh
10+
check=branch ${{ github.action_path }}/check-markdown-format.sh

scripts/githooks/check-markdown-format.sh renamed to .github/actions/check-markdown-format/check-markdown-format.sh

File renamed without changes.

.github/actions/check-todo-usage/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ runs:
77
shell: bash
88
run: |
99
export BRANCH_NAME=origin/${{ github.event.repository.default_branch }}
10-
check=branch ./scripts/githooks/check-todos.sh
10+
check=branch ${{ github.action_path }}/check-todos.sh

scripts/githooks/check-todos.sh renamed to .github/actions/check-todo-usage/check-todos.sh

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

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

28-
EXCLUDED_FILES=(
29-
".devcontainer/devcontainer.json"
30-
".tool-versions"
31-
".vscode/extensions.json"
32-
"infrastructure/terraform/bin/terraform.sh"
33-
"Makefile"
34-
"project.code-workspace"
35-
"src/jekyll-devcontainer/src/.devcontainer/devcontainer.json"
36-
)
37-
38-
EXCLUDED_DIRS=(
39-
".git/"
40-
".venv/"
41-
"docs/"
42-
"node_modules/"
43-
)
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+
}
4461

4562

4663
# Get files to check based on mode
@@ -68,12 +85,7 @@ function get_files_to_check() {
6885

6986

7087
function build_exclude_args() {
71-
local args=(
72-
--exclude=".github/actions/check-todo-usage/action.yaml"
73-
--exclude=".github/workflows/stage-1-commit.yaml"
74-
--exclude="scripts/config/pre-commit.yaml"
75-
--exclude="scripts/githooks/check-todos.sh"
76-
) # 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
7789

7890
if [ ${#EXCLUDED_DIRS[@]} -gt 0 ]; then
7991
for dir in "${EXCLUDED_DIRS[@]}"; do
@@ -203,6 +215,9 @@ function print_output() {
203215
function main() {
204216
cd "$(git rev-parse --show-toplevel)"
205217

218+
# Load exclusions from config file
219+
load_exclusions_from_config "$CONFIG_FILE"
220+
206221
local check_mode="${check:-working-tree-changes}"
207222
local exclude_args=$(build_exclude_args)
208223
local todos=$(search_todos "$check_mode" $exclude_args)

.github/actions/lint-terraform/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ runs:
1515
- name: "Check Terraform format"
1616
shell: bash
1717
run: |
18-
check_only=true scripts/githooks/check-terraform-format.sh
18+
check_only=true ${{ github.action_path }}/check-terraform-format.sh
1919
- name: "Validate Terraform"
2020
shell: bash
2121
run: |
File renamed without changes.

0 commit comments

Comments
 (0)