Improve robustness, security, and CI-friendliness of run-tests-in-docker.sh

未關閉
#188 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

@AyushInKC 已經在處理了。

開始於 2026年2月5日。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
45/100
Issue 類型
重構
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
bash, docker

研究方向

先閱讀 bin/run-tests-in-docker.sh,並追蹤其 Docker build 和 run 路徑。檢查從不同工作目錄執行時的行為,以及 CI 中如何回傳容器失敗。完成的標準是:在不變更腳本介面的情況下,涵蓋所要求的 shell 安全性、路徑處理、可重現性、隔離、唯讀掛載、退出代碼傳遞和日誌記錄變更。

由索引模型根據 Issue 內容生成。

描述

Description

The bin/run-tests-in-docker.sh script currently works well for local testing, but it can be made more robust, secure, and CI-friendly with a few targeted improvements. These changes align the script more closely with production-grade container execution and common best practices for infrastructure scripts.

Motivation

Improve failure detection and error handling in CI environments

Make the script resilient to being executed from any working directory

Strengthen container sandboxing to better mirror Exercism’s production runner

Improve reproducibility and debuggability for contributors

Proposed Improvements

Stricter shell safety

Use #!/usr/bin/env bash with set -Eeuo pipefail instead of relying solely on -e

Path robustness

Resolve the project root dynamically instead of relying on $PWD

Ensures the script works correctly when executed from any directory or CI runner

More reproducible Docker builds

Add --pull and --no-cache to docker build to avoid stale base images

Stronger container isolation

Add resource limits and security flags:

--pids-limit

--memory

--cpus

--security-opt no-new-privileges

Better reflects the sandboxing used in production test runners

Read-only bind mounts

Mount test data and scripts as read-only to prevent accidental mutation

Explicit exit-code handling

Capture and propagate the container exit code to ensure CI fails correctly on test errors

Lightweight logging

Add clear, minimal log messages to improve traceability during CI failures

Benefits

More reliable CI behavior

Clearer failure modes and logs

Improved security posture of the Docker execution

Easier local and automated testing for contributors

Better alignment with Exercism’s production environment

Backwards Compatibility

These changes do not alter the external behavior of the script or its interface.
They only improve safety, clarity, and reliability.

主要語言
Java
星號
11
分支
17
平均合併
17 小時 17 分鐘
30 天內合併 PR
4

環境準備

  • 提供 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 沒有貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

相似的 Issue

更多 Java Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。