From 20b8e94b3cf69f500179c2b9d8a7bd9e7c5db23e Mon Sep 17 00:00:00 2001 From: Phuong Nguyen Date: Thu, 11 Dec 2025 13:44:21 +0200 Subject: [PATCH 1/6] 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/6] 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/6] 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 From 5518631664e05df66fa56b3df14f4e9e193b721e Mon Sep 17 00:00:00 2001 From: Phuong Nguyen Date: Thu, 11 Dec 2025 14:35:57 +0200 Subject: [PATCH 4/6] fix: Redundant test workflow --- .github/workflows/publish.yaml | 13 ++++++----- .github/workflows/test.yaml | 40 ---------------------------------- 2 files changed, 8 insertions(+), 45 deletions(-) delete mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index dd50232..84bdbf1 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -71,11 +71,14 @@ jobs: - name: Install container-structure-test run: | - if [[ "${{ matrix.platform }}" == *"arm64"* ]]; then - curl -LO https://github.com/GoogleContainerTools/container-structure-test/releases/latest/download/container-structure-test-linux-arm64 && chmod +x container-structure-test-linux-arm64 && sudo mv container-structure-test-linux-arm64 /usr/local/bin/container-structure-test - else - curl -LO https://github.com/GoogleContainerTools/container-structure-test/releases/latest/download/container-structure-test-linux-amd64 && chmod +x container-structure-test-linux-amd64 && sudo mv container-structure-test-linux-amd64 /usr/local/bin/container-structure-test - fi + 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: | diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml deleted file mode 100644 index e83a1e9..0000000 --- a/.github/workflows/test.yaml +++ /dev/null @@ -1,40 +0,0 @@ -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 cddbb8553a5f03a960e465267777e71137ba592b Mon Sep 17 00:00:00 2001 From: Phuong Nguyen Date: Thu, 11 Dec 2025 15:32:47 +0200 Subject: [PATCH 5/6] fix: hadolint maybe has bad casing? --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index ec7c3e4..4cd621f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -69,12 +69,12 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ && export SHFMT_VERSION=$(curl -s https://api.github.com/repos/mvdan/sh/releases/latest | jq -r '.tag_name') \ && if [ "$(uname -m)" = "aarch64" ]; then \ curl -o /usr/local/bin/snyk -L https://static.snyk.io/cli/latest/snyk-linux-arm64 \ - && curl -o /usr/local/bin/hadolint -L https://github.com/hadolint/hadolint/releases/download/${HADOLINT_VERSION}/hadolint-Linux-arm64 \ + && curl -o /usr/local/bin/hadolint -L https://github.com/hadolint/hadolint/releases/download/${HADOLINT_VERSION}/hadolint-linux-arm64 \ && curl -o /usr/local/bin/shfmt -L https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/shfmt_${SHFMT_VERSION}_linux_arm64 \ && curl -sL "https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION}_linux_arm64.tar.gz" | tar -xzf - -C /usr/local/bin actionlint ; \ else \ curl -o /usr/local/bin/snyk -L https://static.snyk.io/cli/latest/snyk-linux \ - && curl -o /usr/local/bin/hadolint -L https://github.com/hadolint/hadolint/releases/download/${HADOLINT_VERSION}/hadolint-Linux-x86_64 \ + && curl -o /usr/local/bin/hadolint -L https://github.com/hadolint/hadolint/releases/download/${HADOLINT_VERSION}/hadolint-linux-x86_64 \ && curl -o /usr/local/bin/shfmt -L https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/shfmt_${SHFMT_VERSION}_linux_amd64 \ && curl -sL "https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz" | tar -xzf - -C /usr/local/bin actionlint ; \ fi \ From 1bd00d8c34878b214cc18a57988460d3de4b3cca Mon Sep 17 00:00:00 2001 From: Phuong Nguyen Date: Thu, 11 Dec 2025 15:45:42 +0200 Subject: [PATCH 6/6] fix: maybe flaky test? --- test.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test.sh b/test.sh index 1c43891..b8a4581 100755 --- a/test.sh +++ b/test.sh @@ -41,19 +41,19 @@ build_and_test() { docker run --platform "$platform" --rm "$TEST_PLATFORM_IMAGE" uname -m # Conditionally add --platform flag - PLATFORM_ARG="" + PLATFORM_ARG=() if [ -n "$PLATFORM_FLAG" ]; then - PLATFORM_ARG="--platform $platform" + PLATFORM_ARG=(--platform "$platform") fi if [ "$platform" == "linux/amd64" ]; then - container-structure-test test "$PLATFORM_ARG" --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_ARG" --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_ARG" --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