Skip to content

Commit 8bd8652

Browse files
author
Lasse Benninga
committed
fix(autograder): tighten base-image check, guard missing src COPY, broaden env-var pattern
- Base-image regex now requires python:3.11-slim (not any 3.11 variant) - Layer-order check now requires src_line < 9999 so a Dockerfile with no source COPY does not falsely pass the cache-order gate - Env-var check now also matches 'from os import (environ|getenv)' so students using import forms are not incorrectly penalised
1 parent 68c39d4 commit 8bd8652

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

.hyf/test.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ pass "Level 1: required files ($l1/15 pts)"
4545
l2=0
4646
df="$REPO_ROOT/Dockerfile"
4747
if [[ -f "$df" ]]; then
48-
if grep -qiE "^FROM\s+python:3\.11" "$df"; then
49-
((l2 += 5)); pass "Dockerfile uses python:3.11 base image"
48+
if grep -qE "^FROM\s+python:3\.11-slim" "$df"; then
49+
((l2 += 5)); pass "Dockerfile uses python:3.11-slim base image"
5050
else
5151
fail "Dockerfile does not use python:3.11-slim base image"
5252
fi
5353

5454
# Dependency copy must appear before source copy (cache-friendly order)
5555
req_line=$(grep -n "COPY.*requirements" "$df" | head -1 | cut -d: -f1 || echo 0)
5656
src_line=$(grep -n "COPY.*src" "$df" | head -1 | cut -d: -f1 || echo 9999)
57-
if [[ "$req_line" -gt 0 && "$req_line" -lt "$src_line" ]]; then
57+
if [[ "$req_line" -gt 0 && "$src_line" -lt 9999 && "$req_line" -lt "$src_line" ]]; then
5858
((l2 += 7)); pass "Dockerfile copies requirements before source (cache-friendly)"
5959
else
6060
fail "Dockerfile does not copy requirements before source code"
@@ -124,7 +124,7 @@ pass "Level 5: CI workflow ($l5/20 pts)"
124124
l6=0
125125
py="$REPO_ROOT/src/pipeline.py"
126126
if [[ -f "$py" ]]; then
127-
if grep -qE "os\.(environ|getenv)" "$py"; then
127+
if grep -qE "os\.(environ|getenv)|from os import (environ|getenv)" "$py"; then
128128
((l6 += 10)); pass "pipeline.py reads config from os.environ/os.getenv"
129129
else
130130
fail "pipeline.py does not read from os.environ or os.getenv"

0 commit comments

Comments
 (0)