Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This repository compiles the checks mandated by the MLS spec and their status of
- `views/` contains the dhall code generating the visual representations
- `views/dashboad.dhall`: generates the dashboard
- `views/bookmarkletPage.dhall` generates the page containing the bookmarklet for highlighting the RFC
- `views/gen-check-ids-script.dhall`: generates a shell script to check for missing validation check IDs in the codebase

## Reference

Expand Down
102 changes: 102 additions & 0 deletions views/gen-check-ids-script.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
let Prelude =
https://prelude.dhall-lang.org/v22.0.0/package.dhall
sha256:1c7622fdc868fe3a23462df3e6f533e50fdc12ecf3b42c0bb45c328ec8c4293e

let Types = ../types.dhall

let CheckSets = ../checksets.dhall

let Natural/digits
: Natural -> Natural
= \(num : Natural) ->
if Prelude.Natural.lessThan 10000 num
then 5
else if Prelude.Natural.lessThan 1000 num
then 4
else if Prelude.Natural.lessThan 100 num
then 3
else if Prelude.Natural.lessThan 10 num
then 2
else 1

let Natural/padToText
: Natural -> Natural -> Text
= \(padTo : Natural) ->
\(num : Natural) ->
let digits = Natural/digits num

let padCount = Natural/subtract digits padTo

let zeroes = Prelude.Text.replicate padCount "0"

let actualNumber = Natural/show num

in zeroes ++ actualNumber

let Check/toId
: Types.Check -> Text
= \(check : Types.Check) -> "valn" ++ Natural/padToText 4 check.id

let Status/isComplete
: Types.Status -> Bool
= \(status : Types.Status) ->
merge
{ Unknown = False, Missing = False, Partial = False, Complete = True }
status

let allChecks =
Prelude.List.concatMap
Types.CheckSet
Types.Check
(\(cs : Types.CheckSet) -> cs.checks)
CheckSets

let completeChecks =
Prelude.List.filter
Types.Check
(\(check : Types.Check) -> Status/isComplete check.implStatus)
allChecks

let checkIds = Prelude.List.map Types.Check Text Check/toId completeChecks

let generateCheckCommand
: Text -> Text
= \(id : Text) -> "if ! rg -q '${id}' .; then missing+=(\"${id}\"); fi"

let checkCommands = Prelude.List.map Text Text generateCheckCommand checkIds

let script =
''
#!/bin/bash

# Parse arguments
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
cat <<'HELP'
Usage: $0 [-h]

Checks for missing validation check IDs in the codebase.

This script searches for validation check IDs (e.g., valn0001, valn0002) that are
marked as "Complete" in the validation.dhall repository but are not referenced
in the current codebase.

Exit codes:
0 - All expected validation check IDs are present
1 - One or more validation check IDs are missing

Options:
-h, --help Show this help message
HELP
exit 0
fi

missing=()
${Prelude.Text.concatSep "\n" checkCommands}
if [ ''${#missing[@]} -gt 0 ]; then
echo "Missing check IDs:"
printf '%s\n' "''${missing[@]}"
exit 1
fi
''

in script