exercism / exercism/java-test-runner

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

Đang mở
#188 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Java
Star
11
Fork
17
Merge trung bình
4 ngày 19 giờ
Pull request đã merge (30 ngày)
4

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Bắt đầu bằng cách đọc bin/run-tests-in-docker.sh và theo dõi các đường dẫn build và run của Docker. Kiểm tra cách nó hoạt động khi được chạy từ một thư mục làm việc khác và cách các lỗi của container được trả về trong CI. Được xem là hoàn tất khi các thay đổi được yêu cầu về tính an toàn của shell, xử lý đường dẫn, khả năng tái lập, cô lập, mount chỉ đọc, truyền mã thoát và logging đã được bao quát mà không thay đổi interface của script.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
bash, docker
Lĩnh vực
devops, infrastructure, testing-qa
Loại issue
Tái cấu trúc
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.