Skip to content

Conversation

@e7d
Copy link
Collaborator

@e7d e7d commented Jan 14, 2026

Summary

This PR introduces full CLI argument support, refactors the monolithic diskmark.sh into a clean modular architecture, and reorganizes the test workflow for better structure and concurrency.

Changes

🎯 CLI Argument Support

The container now supports command-line arguments in multiple formats:

Long options with space:

docker run -it --rm e7db/diskmark --size 4G --warmup --loops 2

Long options with equals sign:

docker run -it --rm e7db/diskmark --size=4G --warmup --loops=2

Short options:

docker run -it --rm e7db/diskmark -s 4G -w -l 2

New options added:

  • -h, --help - Show comprehensive help message
  • -v, --version - Show version information
  • All existing environment variables now have CLI equivalents
  • CLI arguments take precedence over environment variables

🏗️ Modular Refactoring

Refactored the ~800 line monolithic script into 8 focused modules:

File Lines Purpose
diskmark.sh 72 Main entry point
lib/args.sh 214 CLI parsing, help, version
lib/utils.sh 153 Color, size conversion, cleanup, errors
lib/validate.sh 137 Input validation functions
lib/benchmark.sh 191 fio execution, warmup, result parsing
lib/output.sh 164 Human/JSON/YAML/XML formatters
lib/detect.sh 99 Filesystem/drive detection
lib/profiles.sh 79 Default/NVMe/custom job profiles
lib/update.sh 17 Update check functionality

🧪 Test Reorganization

Reorganized the test workflow into 6 concurrent jobs for faster execution:

Job Purpose
validation-env ENV variable validation (dry-run)
validation-cli CLI argument validation (dry-run)
benchmark-profiles Profile tests (auto, default, nvme)
benchmark-params Parameter tests (IO, DATA, SIZE, etc.)
benchmark-formats Output format validation (JSON, YAML, XML)
benchmark-edge Edge case tests

Optimizations:

  • Benchmark jobs run concurrently after validation passes
  • Fast tests use RUNTIME=100ms instead of 1s (~3x faster)
  • Profile tests use RUNTIME=500ms for full profile coverage
  • Consistent naming pattern: "<PARAM>: <description>"

📦 Semver-based Versioning

Implemented semantic versioning using git describe:

Scenario Version
Tagged release 1.2.0
5 commits after tag 1.2.0-dev.5+a1b2c3d
No tags (fresh repo) 0.0.0-dev+a1b2c3d

📝 Documentation Updates

  • Added CLI Options section to README with complete options table
  • Updated Advanced usage section to show both CLI and env var syntax
  • Updated all examples to prioritize CLI syntax
  • Created .github/copilot-instructions.md with clean code principles

🐳 Docker Updates

  • Updated Dockerfile to copy lib/ to /usr/lib/diskmark/
  • Updated docker-image.yml workflow with semver version detection

Clean Code Improvements

  • Removed unnecessary "what" comments (functions are self-documenting)
  • Kept only brief file headers describing purpose
  • Each function follows single responsibility principle
  • Consistent naming conventions (validate_*, parse_*, output_*)

Breaking Changes

None. All existing environment variable configurations continue to work. CLI arguments are purely additive.

@github-actions
Copy link

github-actions bot commented Jan 14, 2026

🔍 Vulnerabilities of ghcr.io/e7db/diskmark:sha-0aff088040230dd4f09e41395da8fe0c7708fa63

📦 Image Reference ghcr.io/e7db/diskmark:sha-0aff088040230dd4f09e41395da8fe0c7708fa63
digestsha256:047b4cc85ce184caf27b36f734ac42b2c8dd1112d0e23b5698d56da7f4f06889
vulnerabilitiescritical: 0 high: 0 medium: 0 low: 0
size17 MB
packages1

@github-actions
Copy link

github-actions bot commented Jan 14, 2026

Overview

Image reference ghcr.io/e7db/diskmark:latest ghcr.io/e7db/diskmark:sha-0aff088040230dd4f09e41395da8fe0c7708fa63
- digest 6075e3eafb53 047b4cc85ce1
- tag latest sha-0aff088040230dd4f09e41395da8fe0c7708fa63
- provenance f8ed615 0aff088
- vulnerabilities critical: 0 high: 0 medium: 0 low: 0 critical: 0 high: 0 medium: 0 low: 0
- platform linux/amd64 linux/amd64
- size 17 MB 17 MB (+2.8 kB)
- packages 1 1
Labels (3 changes)
  • ± 3 changed
  • 5 unchanged
-org.opencontainers.image.created=2026-01-12T06:24:34.023Z
+org.opencontainers.image.created=2026-01-14T12:28:09.167Z
 org.opencontainers.image.description=A disk benchmarking tool for Docker
 org.opencontainers.image.licenses=Apache-2.0
-org.opencontainers.image.revision=
+org.opencontainers.image.revision=0aff088040230dd4f09e41395da8fe0c7708fa63
 org.opencontainers.image.source=https://github.com/e7db/docker-diskmark
 org.opencontainers.image.title=docker-diskmark
 org.opencontainers.image.url=https://github.com/e7db/docker-diskmark
-org.opencontainers.image.version=latest
+org.opencontainers.image.version=pr-19

@e7d e7d force-pushed the feat/main/cli-and-modular-refactor branch 4 times, most recently from d04d476 to fedaa44 Compare January 14, 2026 10:30
@e7d e7d changed the title feat: Add CLI arguments and refactor into modular structure feat: Add CLI arguments, modular refactor, and test reorganization Jan 14, 2026
@e7d e7d force-pushed the feat/main/cli-and-modular-refactor branch from fedaa44 to e5ea61e Compare January 14, 2026 11:20
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@e7d e7d force-pushed the feat/main/cli-and-modular-refactor branch from e5ea61e to 5be98e7 Compare January 14, 2026 11:26
@e7d e7d force-pushed the feat/main/cli-and-modular-refactor branch 4 times, most recently from 2c367ec to 356e15d Compare January 14, 2026 12:21
@e7d e7d force-pushed the feat/main/cli-and-modular-refactor branch 2 times, most recently from 3213cf0 to 3fc26a3 Compare January 14, 2026 12:24
@e7d e7d force-pushed the feat/main/cli-and-modular-refactor branch 9 times, most recently from 46a13a4 to abb4d0d Compare January 14, 2026 13:21
…ecurity scanning

- Add CLI support with short/long options (-s/--size, -p/--profile, etc.)
- Split diskmark.sh into lib/ modules (args, validate, utils, profiles, detect, benchmark, output, update)
- Reorganize tests into 6 concurrent jobs with optimized timing (100ms/500ms)
- Integrate Trivy and Grype security scanning into docker-image.yml workflow
@e7d e7d force-pushed the feat/main/cli-and-modular-refactor branch from abb4d0d to d5b43c4 Compare January 14, 2026 13:25
@e7d e7d merged commit b038f78 into main Jan 14, 2026
14 checks passed
@e7d e7d deleted the feat/main/cli-and-modular-refactor branch January 14, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants