Skip to content

Commit bbd6ab6

Browse files
authored
Merge pull request #60 from jsburckhardt/copilot/fix-59
feat: add just command runner feature
2 parents 346516e + e4e1350 commit bbd6ab6

10 files changed

Lines changed: 171 additions & 5 deletions

File tree

.github/workflows/test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
- uv
2929
- codex
3030
- bat
31+
- just
3132
baseImage:
3233
- debian:latest
3334
- ubuntu:latest

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ This repository contains a _collection_ of Features.
2121
| Gitleaks | https://gitleaks.io/ | Gitleaks is a SAST tool for detecting and preventing hardcoded secrets like passwords, api keys, and tokens in git repos. Gitleaks is an easy-to-use, all-in-one solution for detecting secrets, past or present, in your code. |
2222
| Zarf | https://zarf.dev/ | Zarf eliminates the complexity of air gap software delivery for Kubernetes clusters and cloud-native workloads using a declarative packaging strategy to support DevSecOps in offline and semi-connected environments. |
2323
| jnv | https://github.com/ynqa/jnv | jnv is designed for navigating JSON, offering an interactive JSON viewer and jq filter editor. |
24+
| just | https://github.com/casey/just | A command runner. Just is a handy way to save and run project-specific commands. |
2425
| UV/UVX | https://docs.astral.sh/uv/ | An extremely fast Python package and project manager, written in Rust. A single tool to replace pip, pip-tools, pipx, poetry, pyenv, virtualenv, and more. |
2526
| Ruff | https://docs.astral.sh/ruff/ | An extremely fast Python linter and code formatter, written in Rust. |
2627
| Codex-cli | https://github.com/openai/codex | Codex CLI is an experimental project under active development. |
@@ -298,3 +299,20 @@ Running `codex` inside the built container will print the help menu of codex.
298299
```bash
299300
codex --version
300301
```
302+
303+
### `just`
304+
305+
Running `just` inside the built container will print the help menu of just.
306+
307+
```jsonc
308+
{
309+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
310+
"features": {
311+
"ghcr.io/jsburckhardt/devcontainer-features/just:1": {}
312+
}
313+
}
314+
```
315+
316+
```bash
317+
just --version
318+
```

src/just/devcontainer-feature.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "just",
3+
"id": "just",
4+
"version": "1.0.0",
5+
"description": "A command runner. Just is a handy way to save and run project-specific commands.",
6+
"options": {
7+
"version": {
8+
"type": "string",
9+
"default": "latest",
10+
"description": "Version of just to install from GitHub releases e.g. 1.22.0"
11+
}
12+
}
13+
}

src/just/install.sh

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#!/usr/bin/env bash
2+
3+
# Variables
4+
REPO_OWNER="casey"
5+
REPO_NAME="just"
6+
BINARY_NAME="just"
7+
JUST_VERSION="${VERSION:-"latest"}"
8+
9+
set -e
10+
11+
if [ "$(id -u)" -ne 0 ]; then
12+
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
13+
exit 1
14+
fi
15+
16+
# Clean up
17+
rm -rf /var/lib/apt/lists/*
18+
19+
# Checks if packages are installed and installs them if not
20+
check_packages() {
21+
if ! dpkg -s "$@" >/dev/null 2>&1; then
22+
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
23+
echo "Running apt-get update..."
24+
apt-get update -y
25+
fi
26+
apt-get -y install --no-install-recommends "$@"
27+
fi
28+
}
29+
30+
# Make sure we have curl and ca-certificates
31+
check_packages curl ca-certificates
32+
33+
# Check if a version is passed as an argument
34+
# If latest, use a known recent version as fallback since API access may be limited
35+
if [ -z "$JUST_VERSION" ] || [ "$JUST_VERSION" == "latest" ]; then
36+
# Use a recent known version as fallback when "latest" is requested
37+
JUST_VERSION="1.42.4"
38+
echo "No version provided or 'latest' specified, using version: $JUST_VERSION"
39+
else
40+
echo "Installing version from environment variable: $JUST_VERSION"
41+
fi
42+
43+
# Determine the OS and architecture
44+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
45+
ARCH=$(uname -m)
46+
47+
case "$ARCH" in
48+
x86_64)
49+
ARCH="x86_64"
50+
;;
51+
i686)
52+
ARCH="i686"
53+
;;
54+
aarch64)
55+
ARCH="aarch64"
56+
;;
57+
armv7l)
58+
ARCH="armv7"
59+
;;
60+
*)
61+
echo "ERROR: Unsupported architecture: $ARCH"
62+
exit 1
63+
;;
64+
esac
65+
66+
case "$OS" in
67+
linux)
68+
TARGET="${ARCH}-unknown-linux-musl"
69+
;;
70+
*)
71+
echo "ERROR: Unsupported OS: $OS"
72+
exit 1
73+
;;
74+
esac
75+
76+
# Construct download URL based on just's release pattern
77+
DOWNLOAD_URL="https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/download/${JUST_VERSION}/just-${JUST_VERSION}-${TARGET}.tar.gz"
78+
79+
echo "Downloading just from: ${DOWNLOAD_URL}"
80+
81+
# Create temporary directory
82+
TMP_DIR=$(mktemp -d)
83+
cd "$TMP_DIR"
84+
85+
# Download and extract
86+
curl -L -o "just.tar.gz" "${DOWNLOAD_URL}"
87+
tar -xzf "just.tar.gz"
88+
89+
# The just release usually has the binary directly in the archive
90+
if [ -f "just" ]; then
91+
echo "Installing just..."
92+
mv "just" /usr/local/bin/
93+
chmod +x /usr/local/bin/just
94+
else
95+
echo "ERROR: Could not find just binary in archive"
96+
exit 1
97+
fi
98+
99+
# Cleanup
100+
cd - || exit
101+
rm -rf "$TMP_DIR"
102+
103+
# Clean up
104+
rm -rf /var/lib/apt/lists/*
105+
106+
# Verify installation
107+
echo "Verifying installation..."
108+
just --version
109+
110+
echo "Done!"

test/_global/all-tools.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ check "ruff" ruff --version
1616
check "jnv" jnv -V
1717
check "zarf" zarf version
1818
check "codex" codex --version
19+
check "just" just --version
1920

2021
reportResults
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
set -e
4+
source dev-container-features-test-lib
5+
check "just with specific version" /bin/bash -c "just --version | grep '1.42.0'"
6+
7+
reportResults

test/_global/kyverno-specific-version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
set -e
44
source dev-container-features-test-lib
5-
check "kyverno with specific version" /bin/bash -c "kyverno version | grep '1.12.6'"
5+
check "kyverno with specific version" /bin/bash -c "kyverno version | grep '1.15.2'"
66

77
reportResults

test/_global/scenarios.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"skopeo": {},
1818
"uv": {},
1919
"zarf": {},
20-
"codex": {}
20+
"codex": {},
21+
"just": {}
2122
}
2223
},
2324
"flux-specific-version": {
@@ -48,7 +49,7 @@
4849
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
4950
"features": {
5051
"kyverno": {
51-
"version": "v1.12.6"
52+
"version": "v1.15.2"
5253
}
5354
}
5455
},
@@ -110,7 +111,7 @@
110111
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
111112
"features": {
112113
"zarf": {
113-
"version": "v0.41.0"
114+
"version": "v0.61.2"
114115
}
115116
}
116117
},
@@ -129,5 +130,13 @@
129130
"version": "v0.25.0"
130131
}
131132
}
133+
},
134+
"just-specific-version": {
135+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
136+
"features": {
137+
"just": {
138+
"version": "1.42.0"
139+
}
140+
}
132141
}
133142
}

test/_global/zarf-specific-version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
set -e
44
source dev-container-features-test-lib
5-
check "zarf with specific version" /bin/bash -c "zarf version | grep 'v0.41.0'"
5+
check "zarf with specific version" /bin/bash -c "zarf version | grep 'v0.61.2'"
66

77
reportResults

test/just/test.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
source dev-container-features-test-lib
6+
check "just" just --version
7+
reportResults

0 commit comments

Comments
 (0)