From 20b8e94b3cf69f500179c2b9d8a7bd9e7c5db23e Mon Sep 17 00:00:00 2001 From: Phuong Nguyen Date: Thu, 11 Dec 2025 13:44:21 +0200 Subject: [PATCH 1/3] feat: Alternative unix power tools --- Dockerfile | 26 +++++++++++++++++++++++++- README.md | 12 ++++++++++++ tests/specs.yaml | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index cc182e4..ec7c3e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1 -FROM ubuntu:24.04 AS base +FROM ubuntu:25.10 AS base ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 @@ -29,6 +29,30 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ jq \ zsh \ postgresql-client \ + # Better alternative to grep + ripgrep \ + # Better alternative to find + fd-find \ + # Better alternative to top/htop + btop \ + # Better alternative to ls + eza \ + # Better alternative to du + du-dust \ + # Better alternative to cat + bat \ + # Pager for bat + less \ + # Fuzzy finder + fzf \ + # Code counter + tokei \ + # Benchmarking tool + hyperfine \ + # Linking preferred alternatives + && ln -s /usr/bin/eza /usr/local/bin/ls \ + && ln -s /usr/bin/batcat /usr/local/bin/bat \ + && ln -s /usr/bin/fdfind /usr/local/bin/fd \ # Install uv: && curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR="/usr/local/bin" sh \ # Install Pulumi: diff --git a/README.md b/README.md index c55b138..de9d4ed 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,18 @@ It contains the necessary dependencies for running various linters and type chec - `hadolint` - for linting Dockerfile - `actionlint` - static checker for GitHub Actions workflow files +Alternative unix power tools: + +- `rg` (ripgrep) - better alternative to `grep` +- `fd` - better alternative to `find` +- `btop` - better alternative to `top`/`htop` +- `eza` - better alternative to `ls` *(symlinked to replace `ls`)* +- `dust` - better alternative to `du` +- `bat` - better alternative to `cat` +- `fzf` - fuzzy finder +- `tokei` - code counter +- `hyperfine` - benchmarking tool + Other tools: - `pulumi` - Pulumi CLI for infrastructure as code diff --git a/tests/specs.yaml b/tests/specs.yaml index 514166a..213f576 100644 --- a/tests/specs.yaml +++ b/tests/specs.yaml @@ -64,3 +64,44 @@ commandTests: - name: "psql is installed in path" command: "psql" args: ["--version"] + + - name: "ripgrep is installed in path" + command: "rg" + args: ["--version"] + + - name: "fd is installed in path" + command: "fd" + args: ["--version"] + + - name: "btop is installed in path" + command: "btop" + args: ["--version"] + + - name: "eza is installed in path" + command: "eza" + args: ["--version"] + + - name: "ls is overridden by eza" + command: "ls" + args: ["--version"] + expectedOutput: ["eza"] + + - name: "dust is installed in path" + command: "dust" + args: ["--version"] + + - name: "bat is installed in path" + command: "bat" + args: ["--version"] + + - name: "fzf is installed in path" + command: "fzf" + args: ["--version"] + + - name: "tokei is installed in path" + command: "tokei" + args: ["--version"] + + - name: "hyperfine is installed in path" + command: "hyperfine" + args: ["--version"] From efb1f7a9e90e5f07eb79875bf5b80ef9b24e7cdb Mon Sep 17 00:00:00 2001 From: Phuong Nguyen Date: Thu, 11 Dec 2025 13:54:12 +0200 Subject: [PATCH 2/3] feat: Add github workflow to run docker image test --- .github/workflows/test.yaml | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..e83a1e9 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,40 @@ +name: Test Docker image + +on: + pull_request: + branches: + - latest + push: + branches: + - latest + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + platform: [linux/amd64, linux/arm64] + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Install container-structure-test + run: | + if [ "${{ matrix.platform }}" == "linux/arm64" ]; then + ARCH="arm64" + else + ARCH="amd64" + fi + curl -LO "https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-${ARCH}" + chmod +x "container-structure-test-linux-${ARCH}" + sudo mv "container-structure-test-linux-${ARCH}" /usr/local/bin/container-structure-test + + - name: Run tests + run: ./test.sh "${{ matrix.platform }}" From bc80b40e216e4062cf246017d33de49461ea9032 Mon Sep 17 00:00:00 2001 From: Phuong Nguyen Date: Thu, 11 Dec 2025 14:11:50 +0200 Subject: [PATCH 3/3] fix: Case when container-structure-test does not support --platform flag --- test.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/test.sh b/test.sh index 977892c..1c43891 100755 --- a/test.sh +++ b/test.sh @@ -14,6 +14,14 @@ TEST_IMAGE="python-dev-test-image" platforms="${1:-linux/amd64 linux/arm64}" +# Check if container-structure-test supports --platform flag +# Linux binaries of container-structure-test may not support --platform flag +# and thus can only run tests for the local architecture. +PLATFORM_FLAG="" +if container-structure-test test --help 2>&1 | grep -q -- '--platform'; then + PLATFORM_FLAG="--platform" +fi + # Build and test function that takes platform as parameter build_and_test() { local platform=$1 @@ -32,14 +40,20 @@ build_and_test() { docker run --platform "$platform" --rm "$TEST_PLATFORM_IMAGE" uname -m + # Conditionally add --platform flag + PLATFORM_ARG="" + if [ -n "$PLATFORM_FLAG" ]; then + PLATFORM_ARG="--platform $platform" + fi + if [ "$platform" == "linux/amd64" ]; then - container-structure-test test --platform "$platform" --image "$TEST_PLATFORM_IMAGE" --config tests/amd64.yaml + container-structure-test test "$PLATFORM_ARG" --image "$TEST_PLATFORM_IMAGE" --config tests/amd64.yaml else - container-structure-test test --platform "$platform" --image "$TEST_PLATFORM_IMAGE" --config tests/arm64.yaml + container-structure-test test "$PLATFORM_ARG" --image "$TEST_PLATFORM_IMAGE" --config tests/arm64.yaml fi # Run the tests - container-structure-test test --platform "$platform" --image "$TEST_PLATFORM_IMAGE" --config tests/specs.yaml + container-structure-test test "$PLATFORM_ARG" --image "$TEST_PLATFORM_IMAGE" --config tests/specs.yaml # Clean up docker rmi $TEST_IMAGE:"$tag" || true