exercism / exercism/java-test-runner

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

未关闭
#188 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Java
星标
11
派生
17
平均合并
4 天 19 小时
30 天内合并 PR
4

描述

## 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.

贡献指南

这个仓库没有索引到贡献指南

调研方向

首先阅读 bin/run-tests-in-docker.sh,并跟踪其 Docker build 和 run 路径。检查从不同工作目录运行时的行为,以及 CI 中如何返回容器失败。完成的标准是:在不改变脚本接口的情况下,涵盖所要求的 shell 安全性、路径处理、可复现性、隔离、只读挂载、退出代码传播和日志记录变更。

由索引模型根据 Issue 内容生成。

评估

技术栈
bash, docker
领域
devops, infrastructure, testing-qa
Issue 类型
重构
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。