Skip to content

Commit 8645fbf

Browse files
committed
chore: enable devcontainer, rust-toolchain and Makefile
1 parent 87ac922 commit 8645fbf

File tree

4 files changed

+114
-0
lines changed

4 files changed

+114
-0
lines changed

.devcontainer/devcontainer.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/rust
3+
{
4+
"name": "Rust",
5+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
"image": "mcr.microsoft.com/devcontainers/rust:1-1-bullseye",
7+
"features": {
8+
"ghcr.io/devcontainers/features/common-utils:2": {
9+
"installZsh": true,
10+
"configureZshAsDefaultShell": true,
11+
"installOhMyZsh": true,
12+
"installOhMyZshConfig": true,
13+
"upgradePackages": true,
14+
"username": "root"
15+
}
16+
},
17+
18+
// Use 'mounts' to make the cargo cache persistent in a Docker Volume.
19+
// "mounts": [
20+
// {
21+
// "source": "devcontainer-cargo-cache-${devcontainerId}",
22+
// "target": "/usr/local/cargo",
23+
// "type": "volume"
24+
// }
25+
// ]
26+
27+
// Features to add to the dev container. More info: https://containers.dev/features.
28+
// "features": {},
29+
30+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
31+
// "forwardPorts": [],
32+
33+
// Use 'postCreateCommand' to run commands after the container is created.
34+
"postCreateCommand": "rustc --version",
35+
36+
// Configure tool-specific properties.
37+
"customizations": {
38+
"vscode": {
39+
"extensions": [
40+
"ms-vscode.makefile-tools",
41+
"ms-vscode-remote.remote-containers",
42+
"rust-lang.rust-analyzer",
43+
"eamodio.gitlens",
44+
"redhat.vscode-yaml"
45+
]
46+
}
47+
},
48+
49+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
50+
"remoteUser": "root"
51+
}

.github/dependabot.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/dependabot-2.0.json
2+
3+
# To get started with Dependabot version updates, you'll need to specify which
4+
# package ecosystems to update and where the package manifests are located.
5+
# Please see the documentation for more information:
6+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
7+
# https://containers.dev/guide/dependabot
8+
9+
version: 2
10+
updates:
11+
- package-ecosystem: "devcontainers"
12+
directory: "/"
13+
schedule:
14+
interval: weekly
15+
16+
- package-ecosystem: "cargo"
17+
directories:
18+
- "/"
19+
- "/hpfile"
20+
- "/qmdb"
21+
- "/bench"
22+
schedule:
23+
interval: weekly

Makefile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Marks targets as phony to ensure commands are executed regardless of whether files with matching names exist
2+
# This prevents conflicts with any files of the same names and ensures the commands always run.
3+
.PHONY: install-deps build test
4+
5+
# Sets 'build' as the default target that will be executed when running 'make'
6+
# without specifying a target. This means `make` and `make build` are equivalent.
7+
.DEFAULT_GOAL := build
8+
9+
# List of packages to install
10+
PACKAGES = g++ linux-libc-dev libclang-dev unzip libjemalloc-dev make
11+
12+
# Determines if sudo is needed based on the current user's UID
13+
SUDO := $(if $(filter 0,$(shell id -u)),,$(word 1,$(MAKEFLAGS))sudo)
14+
15+
install-deps:
16+
@if ! $(SUDO) apt-get -s install $(PACKAGES) > /dev/null 2>&1; then \
17+
echo "Package database is outdated or missing. Running apt-get update..."; \
18+
$(SUDO) apt-get update; \
19+
$(SUDO) apt-get install -y $(PACKAGES); \
20+
else \
21+
$(SUDO) apt-get install -y $(PACKAGES); \
22+
fi
23+
24+
build: install-deps
25+
cargo build --release
26+
27+
test: install-deps
28+
cargo test --release
29+
30+
format:
31+
cargo fmt --all
32+
33+
lint:
34+
cargo clippy --all -- -D warnings
35+
36+
clean:
37+
cargo clean

rust-toolchain.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[toolchain]
2+
channel = "1.83.0"
3+
components = ["rustc", "cargo", "clippy", "rustfmt"]

0 commit comments

Comments
 (0)