diff --git a/.github/workflows/grade-assignment.yml b/.github/workflows/grade-assignment.yml index d06dc2d..3fd4b9c 100644 --- a/.github/workflows/grade-assignment.yml +++ b/.github/workflows/grade-assignment.yml @@ -8,6 +8,7 @@ on: jobs: grade: permissions: + contents: read issues: write pull-requests: write uses: HackYourFuture/github-actions/.github/workflows/auto-grade.yml@main diff --git a/.hyf/test.sh b/.hyf/test.sh index 72d151d..f3fe07a 100755 --- a/.hyf/test.sh +++ b/.hyf/test.sh @@ -47,14 +47,21 @@ fi ((score += l1)) pass "Level 1: required files ($l1/10 pts)" -# Helper: returns true when a file is non-empty and all TODO placeholders have -# been removed. The assignment instruction is "replace every TODO" — any -# remaining occurrence of the word TODO (case-insensitive) means the file is -# still a scaffold stub. +# Helper: returns true when a file has real content and no *unreplaced* TODO +# placeholder remains. A completed query left below the scaffold's "-- TODO:" +# guide comment still counts as filled: SQL line-comments are stripped before +# the check, and only a line whose content *begins* with TODO (an unreplaced +# markdown placeholder) marks the file a stub. The instruction line +# "...Replace every TODO." (TODO not at line start) is fine. file_is_filled() { local f="$1" [[ -s "$f" ]] || return 1 - grep -qiE "\bTODO\b" "$f" && return 1 + local body + body="$(sed -E 's/--.*$//' "$f" | grep -vE '^[[:space:]]*$')" + [[ -n "$body" ]] || return 1 + if printf '%s\n' "$body" | grep -qiE '^[[:space:]]*([#>*-]+[[:space:]]*)?TODO\b'; then + return 1 + fi return 0 } @@ -105,14 +112,14 @@ if file_is_filled "$ss"; then ((l3 += 4)); pass "schema_setup.sql: file filled (no stub TODOs)" # 3a: creates vw_dim_zones - if grep -qiE "VIEW[[:space:]]+vw_dim_zones" "$ss"; then + if grep -qiE "VIEW[[:space:]]+([a-zA-Z_][a-zA-Z0-9_]*\.)?vw_dim_zones\b" "$ss"; then ((l3 += 5)); pass "schema_setup.sql: vw_dim_zones view defined" else fail "schema_setup.sql: vw_dim_zones view not found — check spelling (Task 2)" fi # 3b: creates vw_fact_trips - if grep -qiE "VIEW[[:space:]]+vw_fact_trips" "$ss"; then + if grep -qiE "VIEW[[:space:]]+([a-zA-Z_][a-zA-Z0-9_]*\.)?vw_fact_trips\b" "$ss"; then ((l3 += 5)); pass "schema_setup.sql: vw_fact_trips view defined" else fail "schema_setup.sql: vw_fact_trips view not found — check spelling (Task 2)"