Skip to content

Commit 7f4da0e

Browse files
CopilotKSXGitHubCopilot
authored
chore(devcontainer): configuration (#353)
Adds `.devcontainer/` to enable first-class GitHub Codespaces support with all required tooling pre-installed, with two configuration variants to balance build speed against feature completeness. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: KSXGitHub <11488886+KSXGitHub@users.noreply.github.com> Co-authored-by: khai96_ <hvksmr1996@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 462be71 commit 7f4da0e

6 files changed

Lines changed: 118 additions & 0 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "parallel-disk-usage (Rust only)",
3+
"image": "mcr.microsoft.com/devcontainers/rust:1",
4+
"customizations": {
5+
"vscode": {
6+
"extensions": [
7+
"rust-lang.rust-analyzer",
8+
"timonwong.shellcheck",
9+
"mkhl.shfmt"
10+
]
11+
}
12+
},
13+
"postCreateCommand": "bash .devcontainer/post-create.sh"
14+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "parallel-disk-usage (full)",
3+
"image": "mcr.microsoft.com/devcontainers/rust:1",
4+
"features": {
5+
"ghcr.io/devcontainers/features/node:1": {
6+
"version": "lts",
7+
"nodeGypDependencies": true
8+
},
9+
"ghcr.io/devcontainers/features/python:1": {
10+
"version": "3.12",
11+
"installTools": true
12+
},
13+
"ghcr.io/devcontainers-contrib/features/shellcheck:1": {},
14+
"ghcr.io/devcontainers-contrib/features/shfmt:1": {}
15+
},
16+
"customizations": {
17+
"vscode": {
18+
"extensions": [
19+
"rust-lang.rust-analyzer",
20+
"timonwong.shellcheck",
21+
"mkhl.shfmt"
22+
]
23+
}
24+
},
25+
"postCreateCommand": "bash .devcontainer/full/post-create.sh"
26+
}

.devcontainer/full/post-create.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
echo "Installing Python dependencies..." >&2
5+
python3 -m pip install --user toml
6+
7+
echo "Installing pnpm and project Node dependencies..." >&2
8+
npm install -g pnpm@7.9.0
9+
(cd ci/github-actions && pnpm install --frozen-lockfile)
10+
11+
bash "$(dirname "$0")/../install-rust-toolchain.sh"
12+
bash "$(dirname "$0")/../install-hyperfine.sh"

.devcontainer/install-hyperfine.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
# Shared helper: install hyperfine binary from GitHub releases into ~/.local/bin
3+
set -euo pipefail
4+
5+
arch="$(uname -m)"
6+
case "$arch" in
7+
x86_64) hyperfine_target="x86_64-unknown-linux-musl" ;;
8+
aarch64) hyperfine_target="aarch64-unknown-linux-musl" ;;
9+
*)
10+
echo "ERROR: Unsupported architecture for hyperfine prebuilt binary: $arch" >&2
11+
exit 1
12+
;;
13+
esac
14+
15+
mkdir -p "$HOME/.local/bin"
16+
17+
echo "Installing hyperfine from GitHub release..." >&2
18+
hyperfine_version="1.20.0"
19+
hyperfine_archive="hyperfine-v${hyperfine_version}-${hyperfine_target}"
20+
hyperfine_url="https://github.com/sharkdp/hyperfine/releases/download/v${hyperfine_version}/${hyperfine_archive}.tar.gz"
21+
curl -fsSL "$hyperfine_url" | tar -xz --strip-components=1 -C "$HOME/.local/bin" "${hyperfine_archive}/hyperfine"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
5+
6+
echo "Installing Rust toolchain from rust-toolchain..." >&2
7+
rustup toolchain install "$(<"$REPO_ROOT/rust-toolchain")"
8+
rustup component add clippy rustfmt rust-analyzer

.devcontainer/post-create.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
mkdir -p "$HOME/.local/bin"
5+
6+
bash "$(dirname "$0")/install-rust-toolchain.sh"
7+
bash "$(dirname "$0")/install-hyperfine.sh"
8+
9+
arch="$(uname -m)"
10+
11+
echo "Installing shellcheck from GitHub release..." >&2
12+
shellcheck_version="0.11.0"
13+
case "$arch" in
14+
x86_64) shellcheck_arch="linux.x86_64" ;;
15+
aarch64) shellcheck_arch="linux.aarch64" ;;
16+
*)
17+
echo "ERROR: Unsupported architecture for shellcheck prebuilt binary: $arch" >&2
18+
exit 1
19+
;;
20+
esac
21+
shellcheck_archive="shellcheck-v${shellcheck_version}.${shellcheck_arch}"
22+
shellcheck_url="https://github.com/koalaman/shellcheck/releases/download/v${shellcheck_version}/${shellcheck_archive}.tar.gz"
23+
curl -fsSL "$shellcheck_url" | tar -xz --strip-components=1 -C "$HOME/.local/bin" "shellcheck-v${shellcheck_version}/shellcheck"
24+
25+
echo "Installing shfmt from GitHub release..." >&2
26+
shfmt_version="3.13.0"
27+
case "$arch" in
28+
x86_64) shfmt_arch="linux_amd64" ;;
29+
aarch64) shfmt_arch="linux_arm64" ;;
30+
*)
31+
echo "ERROR: Unsupported architecture for shfmt prebuilt binary: $arch" >&2
32+
exit 1
33+
;;
34+
esac
35+
shfmt_url="https://github.com/mvdan/sh/releases/download/v${shfmt_version}/shfmt_v${shfmt_version}_${shfmt_arch}"
36+
curl -fsSL "$shfmt_url" -o "$HOME/.local/bin/shfmt"
37+
chmod +x "$HOME/.local/bin/shfmt"

0 commit comments

Comments
 (0)