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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
21 changes: 12 additions & 9 deletions .github/scripts/verify-concept.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,35 @@ set -uo pipefail
project="$1"; start_pass="$2"; total="$3"
failed=0

# Logs go to a private temp folder, so two runs from one checkout do not mix their output.
logs="$(mktemp -d)"
trap 'rm -rf "$logs"' EXIT

count() { grep -c -F "$1" "$2" || true; }

echo "== $project/start: expecting $start_pass of $total, and a failing exit code"
(cd "$project/start" && ./check) > start.log 2>&1
(cd "$project/start" && ./check) > "$logs/start.log" 2>&1
start_exit=$?
pass=$(count "[PASS]" start.log); fail=$(count "[FAIL]" start.log)
pass=$(count "[PASS]" "$logs/start.log"); fail=$(count "[FAIL]" "$logs/start.log")
echo " got $pass of $((pass + fail)), exit code $start_exit"
if [ "$pass" != "$start_pass" ] || [ "$((pass + fail))" != "$total" ] || [ "$start_exit" = "0" ]; then
echo " WRONG. Output of ./check in start/:"; cat start.log; failed=1
echo " WRONG. Output of ./check in start/:"; cat "$logs/start.log"; failed=1
fi

echo "== $project/solution: expecting $total of $total, and exit code 0"
(cd "$project/solution" && ./check) > solution.log 2>&1
(cd "$project/solution" && ./check) > "$logs/solution.log" 2>&1
solution_exit=$?
pass=$(count "[PASS]" solution.log); fail=$(count "[FAIL]" solution.log)
pass=$(count "[PASS]" "$logs/solution.log"); fail=$(count "[FAIL]" "$logs/solution.log")
echo " got $pass of $((pass + fail)), exit code $solution_exit"
if [ "$pass" != "$total" ] || [ "$fail" != "0" ] || [ "$solution_exit" != "0" ]; then
echo " WRONG. Output of ./check in solution/:"; cat solution.log; failed=1
echo " WRONG. Output of ./check in solution/:"; cat "$logs/solution.log"; failed=1
fi

echo "== $project/solution: ./mvnw verify"
if (cd "$project/solution" && ./mvnw -B -q verify) > verify.log 2>&1; then
if (cd "$project/solution" && ./mvnw -B -q verify) > "$logs/verify.log" 2>&1; then
echo " green"
else
echo " FAILED:"; tail -n 80 verify.log; failed=1
echo " FAILED:"; tail -n 80 "$logs/verify.log"; failed=1
fi

rm -f start.log solution.log verify.log
exit $failed
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ A collection of hands-on coding interview projects organized by language. Each p
> **Backend concepts:** [java/concepts/](java/concepts/) is a different kind of project: not a timed
> round, but one concept taught step by step. Each is broken first (you run it and watch the problem
> happen), has challenge tasks and a guided version, tests as acceptance criteria, and `start/` and
> `solution/` folders side by side. There are eight so far, numbered in the suggested order from
> `01-transactional` to `08-idempotency`: see the [list](java/concepts/README.md).
> `solution/` folders side by side. There are eleven so far, numbered in the suggested order from
> `01-transactional` to `11-pagination`: see the [list](java/concepts/README.md).

## Structure

Expand Down Expand Up @@ -97,7 +97,7 @@ interview-prep/
│ ├── karat-drills/
│ ├── secret-storage/
│ ├── concepts/
│ │ └── junior-mid/ (01-transactional ... 08-idempotency)
│ │ └── junior-mid/ (01-transactional ... 11-pagination)
│ ├── DELIVERY_HERO.md
│ └── KARAT.md
├── python/
Expand Down
3 changes: 3 additions & 0 deletions java/concepts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ under [`java/`](../).
| 06 | Junior / mid | [Thread safety](junior-mid/06-thread-safety/) | 1,000 requests are answered, the counter says 915 |
| 07 | Junior / mid | [Locking](junior-mid/07-locking/) | Two buyers both get the last item in stock |
| 08 | Junior / mid | [Idempotency](junior-mid/08-idempotency/) | One payment is retried and the customer is charged twice |
| 09 | Junior / mid | [Isolation levels](junior-mid/09-isolation-levels/) | A bank statement whose lines add up to 1000 and whose total says 1100 |
| 10 | Junior / mid | [Constraints and races](junior-mid/10-constraints-and-races/) | Two signups with the same email both succeed |
| 11 | Junior / mid | [Pagination](junior-mid/11-pagination/) | Page 5,000 reads 100,000 rows to return 20 |

The numbers are the suggested order. Each project stands on its own, so you can start anywhere.

Expand Down
5 changes: 4 additions & 1 deletion java/concepts/ci-projects.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
{ "path": "java/concepts/junior-mid/05-rest-and-error-handling", "startPass": 13, "total": 56 },
{ "path": "java/concepts/junior-mid/06-thread-safety", "startPass": 18, "total": 29 },
{ "path": "java/concepts/junior-mid/07-locking", "startPass": 7, "total": 18 },
{ "path": "java/concepts/junior-mid/08-idempotency", "startPass": 15, "total": 32 }
{ "path": "java/concepts/junior-mid/08-idempotency", "startPass": 15, "total": 32 },
{ "path": "java/concepts/junior-mid/09-isolation-levels", "startPass": 22, "total": 31 },
{ "path": "java/concepts/junior-mid/10-constraints-and-races", "startPass": 19, "total": 35 },
{ "path": "java/concepts/junior-mid/11-pagination", "startPass": 15, "total": 35 }
]
Loading
Loading