Skip to content

Commit 9ad075a

Browse files
thuva4codex
andcommitted
Fix CI runners and web build
Co-authored-by: COdex <codex@openai.com>
1 parent d6e8199 commit 9ad075a

45 files changed

Lines changed: 88 additions & 131 deletions

Some content is hidden

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

.github/workflows/test.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ jobs:
8989
distribution: 'temurin'
9090
java-version: '21'
9191

92+
- name: Install Python dependencies
93+
run: pip install -r tests/runners/requirements.txt
94+
9295
- name: Run Java test runner
9396
run: bash tests/runners/java_runner.sh
9497

@@ -254,6 +257,21 @@ jobs:
254257
with:
255258
scala-version: '3.3.1'
256259

260+
- name: Ensure Scala compiler is available
261+
run: |
262+
if ! command -v scalac >/dev/null 2>&1 || ! command -v scala >/dev/null 2>&1; then
263+
if command -v cs >/dev/null 2>&1; then
264+
cs install --install-dir "$HOME/.local/bin" scala scalac
265+
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
266+
echo "$HOME/.local/share/coursier/bin" >> "$GITHUB_PATH"
267+
else
268+
sudo apt-get update
269+
sudo apt-get install -y scala
270+
fi
271+
fi
272+
command -v scalac
273+
command -v scala
274+
257275
- name: Run Scala test runner
258276
run: bash tests/runners/scala_runner.sh
259277

README.md

Lines changed: 19 additions & 19 deletions
Large diffs are not rendered by default.

tests/runners/go_runner.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
CACHE_DIR = REPO_ROOT / ".cache" / "go-runner"
2424
GO_BUILD_CACHE = REPO_ROOT / ".cache" / "go-build"
2525
RUN_TIMEOUT_SECONDS = float(os.environ.get("GO_RUNNER_TIMEOUT_SECONDS", "10"))
26+
BUILD_TIMEOUT_SECONDS = float(os.environ.get("GO_RUNNER_BUILD_TIMEOUT_SECONDS", "60"))
2627

2728

2829
@dataclass
@@ -982,14 +983,17 @@ def compile_binary(algo_dir: Path, sources: list[Path], wrapper_source: str) ->
982983
env["GOCACHE"] = str(GO_BUILD_CACHE)
983984

984985
cmd = ["go", "build", "-o", str(tmp_dir / "runner")]
985-
proc = subprocess.run(
986-
cmd,
987-
cwd=tmp_dir,
988-
env=env,
989-
text=True,
990-
capture_output=True,
991-
timeout=RUN_TIMEOUT_SECONDS,
992-
)
986+
try:
987+
proc = subprocess.run(
988+
cmd,
989+
cwd=tmp_dir,
990+
env=env,
991+
text=True,
992+
capture_output=True,
993+
timeout=BUILD_TIMEOUT_SECONDS,
994+
)
995+
except subprocess.TimeoutExpired:
996+
return None, f"Build timed out after {BUILD_TIMEOUT_SECONDS:.1f}s"
993997
if proc.returncode != 0:
994998
output = (proc.stdout + proc.stderr).strip()
995999
return None, output

web/src/visualizations/backtracking/ratInMaze.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class RatInMazeVisualization implements AlgorithmVisualization {
77
private steps: VisualizationState[] = [];
88
private currentStepIndex = -1;
99

10-
initialize(data: number[]): VisualizationState {
10+
initialize(_data: number[]): VisualizationState {
1111
this.steps = [];
1212
this.currentStepIndex = -1;
1313
const n = 4;

web/src/visualizations/backtracking/sudokuSolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class SudokuSolverVisualization implements AlgorithmVisualization {
77
private steps: VisualizationState[] = [];
88
private currentStepIndex = -1;
99

10-
initialize(data: number[]): VisualizationState {
10+
initialize(_data: number[]): VisualizationState {
1111
this.steps = [];
1212
this.currentStepIndex = -1;
1313
// Use a simple 4x4 Sudoku for visualization

web/src/visualizations/cryptography/diffieHellman.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class DiffieHellmanVisualization implements AlgorithmVisualization {
1818
return result;
1919
}
2020

21-
initialize(data: number[]): VisualizationState {
21+
initialize(_data: number[]): VisualizationState {
2222
this.steps = [];
2323
this.currentStepIndex = -1;
2424
const p = 23; // prime

web/src/visualizations/data-structures/cuckooHashing.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export class CuckooHashingVisualization implements AlgorithmVisualization {
2727

2828
const tableSize = Math.max(8, data.length * 2);
2929
// Table A occupies indices [0, tableSize-1], Table B occupies [tableSize, 2*tableSize-1]
30-
const combined = new Array(tableSize * 2).fill(0);
3130
const tableA: (number | null)[] = new Array(tableSize).fill(null);
3231
const tableB: (number | null)[] = new Array(tableSize).fill(null);
3332
const maxDisplacements = 10;

web/src/visualizations/data-structures/fibonacciHeap.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ export class FibonacciHeapVisualization implements AlgorithmVisualization {
4343
return result;
4444
};
4545

46-
const getMinIndex = (): number => {
47-
if (!minNode) return -1;
48-
const flat = flattenHeap();
49-
return flat.indexOf(minNode.key);
50-
};
51-
5246
const getRootHighlights = (): { index: number; color: string; label?: string }[] => {
5347
const highlights: { index: number; color: string; label?: string }[] = [];
5448
let idx = 0;

web/src/visualizations/data-structures/moAlgorithm.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ export class MoAlgorithmVisualization implements AlgorithmVisualization {
2424

2525
// Generate queries
2626
const numQueries = Math.min(6, Math.max(2, Math.floor(n / 2)));
27-
const queries: { l: number; r: number; idx: number }[] = [];
27+
const queries: { l: number; r: number }[] = [];
2828
for (let i = 0; i < numQueries; i++) {
2929
const l = Math.floor(Math.random() * Math.floor(n / 2));
3030
const r = Math.min(n - 1, l + Math.floor(Math.random() * Math.floor(n / 2)) + 1);
31-
queries.push({ l, r, idx: i });
31+
queries.push({ l, r });
3232
}
3333

3434
this.steps.push({
@@ -86,7 +86,7 @@ export class MoAlgorithmVisualization implements AlgorithmVisualization {
8686
let totalOps = 0;
8787

8888
for (let qi = 0; qi < queries.length; qi++) {
89-
const { l, r, idx } = queries[qi];
89+
const { l, r } = queries[qi];
9090

9191
this.steps.push({
9292
data: [...arr],

web/src/visualizations/data-structures/ropeDataStructure.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,6 @@ export class RopeDataStructureVisualization implements AlgorithmVisualization {
2828
return this.totalLength(node.left) + this.totalLength(node.right);
2929
}
3030

31-
private flatten(node: RopeNode | null): number[] {
32-
if (!node) return [];
33-
if (node.value !== null) {
34-
return node.value.split('').map(c => c.charCodeAt(0) - 64); // A=1, B=2, etc.
35-
}
36-
return [...this.flatten(node.left), ...this.flatten(node.right)];
37-
}
38-
3931
private treeToArray(node: RopeNode | null): number[] {
4032
// BFS order of weights for visualization
4133
if (!node) return [];

0 commit comments

Comments
 (0)