Skip to content

Commit 4e61efe

Browse files
Adjective-ObjectMax Huang-Hobbs
and
Max Huang-Hobbs
authored
Merge development branch (caching resolver, devcontainer, deadlock detector, clippy) (#80)
## Major Changes: - updates the `devcontainer` definition to make things more usable: - Bases devcontainer off newer version of ubuntu (24.10) - Fix locale issue causing spacing issue in zsh (https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-see-duplicate-typed-characters-after-i-complete-a-command) - Switches to `gdb` as the default debugger, as it supports hashmap visualization (rust-lang/rust#111868) - Caches rust packages in a persistent volume to avoid re-downloading packages between container rebuilds. - adds a resolver for SWC that is aware of package `exports, to support custom `source` imports within a monorepo - adds a deadlock detector for `dashmap` and wires it into the caching resolver (this is temporary and should be removed in the future) - Adds a CI job to ensure no unused dependencies are included (using `cargo-udeps`). This is not included in the container build as it is _exceptionally_ slow to build from source (~250s on my machine) - Fixes issues discovered by `cargo clippy` --------- Co-authored-by: Max Huang-Hobbs <[email protected]>
1 parent 0446696 commit 4e61efe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+5327
-1085
lines changed

.devcontainer/Dockerfile

Lines changed: 61 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,85 @@
1-
FROM ubuntu:22.10
1+
FROM ubuntu:24.10
22

3-
# Update default packages
4-
RUN apt-get update
3+
# Set locale before any packages are installed,
4+
# since packages are influenced by the current locale on installation
5+
#
6+
# This is necessary to get zsh to work well.
7+
# See: https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-see-duplicate-typed-characters-after-i-complete-a-command
8+
RUN apt-get update && apt-get install -y language-pack-en
9+
RUN echo LC_CTYPE=\"en_US.UTF-8\" "\n" \
10+
LC_ALL=\"en_US.UTF-8\" "\n" \
11+
LANG=\"en_US.UTF-8\" "\n" > /etc/default/locale
12+
13+
# Set locale before any packages are installed,
14+
# since packages are influenced by the current locale on installation
15+
#
16+
# This is necessary to get zsh to work well.
17+
# See: https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-see-duplicate-typed-characters-after-i-complete-a-command
18+
RUN apt-get install -y language-pack-en
19+
RUN echo LC_CTYPE=\"en_US.UTF-8\" "\n" \
20+
LC_ALL=\"en_US.UTF-8\" "\n" \
21+
LANG=\"en_US.UTF-8\" "\n" > /etc/default/locale
522

623
# Get Ubuntu packages
7-
RUN apt-get install -y \
24+
RUN apt-get update && apt-get install -y \
825
build-essential \
26+
gdb \
27+
pkg-config \
928
curl git zsh \
1029
vim
1130

1231
# Update new packages
1332
RUN apt-get update
1433

15-
ARG USERNAME=dev
34+
ARG USERNAME=ubuntu
1635
ARG HOME=/home/${USERNAME}
17-
ARG USER_UID=1000
36+
ARG USER_UID=1010
1837
ARG USER_GID=$USER_UID
1938

20-
# Create the user
21-
RUN groupadd --gid $USER_GID $USERNAME \
22-
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
23-
#
24-
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
25-
&& apt-get update \
39+
# Create the user (disabled: user is default 'ubuntu')
40+
# RUN groupadd --gid $USER_GID $USERNAME \
41+
# && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME
42+
43+
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
44+
RUN apt-get update \
2645
&& apt-get install -y sudo \
2746
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
2847
&& chmod 0440 /etc/sudoers.d/$USERNAME
2948

30-
# setup zsh for the user
31-
RUN mkdir -p ${HOME}/.antigen
32-
RUN curl https://raw.githubusercontent.com/zsh-users/antigen/master/bin/antigen.zsh > ${HOME}/.antigen/antigen.zsh
33-
COPY zshrc.zsh ${HOME}/.zshrc
34-
35-
# Get Rust
36-
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
37-
RUN echo 'source ${HOME}/.cargo/env' >> ${HOME}/.zshrc
38-
3949
# Get Node
40-
RUN curl -fsSL https://deb.nodesource.com/setup_19.x | bash -
50+
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash -
4151
RUN apt install -y nodejs
4252

4353
# Preload yarn with corepack
4454
RUN corepack enable
4555
RUN corepack prepare yarn@stable --activate
4656

47-
# recursively change ownership of the mounted files
48-
# to the "dev" user
49-
RUN chown ${USERNAME}:${USERNAME} ${HOME} -R
57+
# get native dependencies
58+
RUN apt install -y libdw-dev
59+
60+
# Start acting as the container user to avoid permissions issues
61+
USER ${USERNAME}
62+
RUN sudo chown ${USERNAME}:${USERNAME} ${HOME}/.cache -R
63+
64+
# setup zsh for the user
65+
RUN mkdir -p ${HOME}/.antigen
66+
RUN curl -L https://git.io/antigen > ${HOME}/.antigen/antigen.zsh
67+
COPY zshrc.zsh ${HOME}/.zshrc
68+
RUN sudo chown ${USERNAME}:${USERNAME} ${HOME}/.zshrc
69+
# run zsh to install antigen plugins for the first time
70+
RUN zsh ${HOME}/.zshrc
71+
72+
# Make the mount target directories
73+
RUN sudo mkdir -p /cache ${HOME}/.cargo/registry
74+
RUN sudo chown ${USERNAME}:${USERNAME} /cache -R
75+
RUN sudo chown ${USERNAME}:${USERNAME} ${HOME}/.cargo -R
76+
77+
# Install rust
78+
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
79+
RUN sudo chown ${USERNAME}:${USERNAME} ${HOME}/.cargo -R
80+
RUN echo 'source ${HOME}/.cargo/env' >> ${HOME}/.zprofile
81+
RUN echo 'source ${HOME}/.cargo/env' >> ${HOME}/.profile
82+
83+
# Install cargo-udeps
84+
# RUN sudo apt-get update && sudo apt-get install -y libssl-dev
85+
# RUN bash -c "source ${HOME}/.cargo/env && cargo install cargo-udeps"

.devcontainer/devcontainer.json

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,56 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/microsoft/vscode/master/extensions/configuration-editing/schemas/devContainer.schema.json",
3-
"name": "good-fences-rs development container",
3+
"name": "${localWorkspaceFolderBasename} devcontainer",
44
"build": {
55
"dockerfile": "./Dockerfile",
66
"args": {
7-
"USERNAME": "vscode"
7+
"USERNAME": "ubuntu"
88
}
99
},
10-
"remoteUser": "vscode",
10+
// In wsl, we want the acting user to match the user we are launching Docker from,
11+
// which is typically 'ubuntu' in the default WSL configuration.
12+
//
13+
// This is because mounted volumes from Linux retain their original file permissions.
14+
// If the acting user is not the same as the user in the container, the container
15+
// may not have permission to write to the mounted volume, or may mangle the permissions
16+
// of mounted files.
17+
//
18+
// See https://github.com/microsoft/vscode-dev-containers/issues/108
19+
"remoteUser": "ubuntu",
1120
// see https://github.com/microsoft/vscode-remote-release/issues/1333#issuecomment-528234042
12-
"workspaceMount": "",
13-
"runArgs": [
14-
"--init",
15-
"--volume=${localWorkspaceFolder}:/workspaces/ori:Z"
16-
],
1721
"settings": {
18-
"terminal.integrated.shell.linux": "/bin/zsh"
22+
"terminal.integrated.profiles.linux": {
23+
"zsh": {
24+
"path": "/usr/bin/zsh"
25+
}
26+
},
27+
"terminal.integrated.defaultProfile.linux": "zsh"
1928
},
20-
"workspaceFolder": "/workspaces/ori",
21-
"postStartCommand": "/bin/bash .devcontainer/config_fetch.sh",
29+
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind,consistency=delegated",
30+
"mounts": [
31+
// This mounts client-web checked out next to this repo for testing, left checked-in here for convenience.
32+
// Don't commit it, though!
33+
// "source=${localWorkspaceFolder}/../client-web,target=/workspaces/client-web,type=bind,consistency=cached",
34+
// expose the user's ssh credentials to the dev container
35+
"source=${localEnv:HOME}/.ssh,target=/home/ubuntu/.ssh,type=bind,consistency=cached",
36+
// map the .persist directory to /cache so it can be persisted between container rebuilds.
37+
// This persists zsh history as well as downloaded cargo crate sources.
38+
"source=${localWorkspaceFolder}/.persist,target=/cache,type=bind,consistency=cached",
39+
"source=${localWorkspaceFolder}/.persist/cargo-registry,target=/home/ubuntu/.cargo/registry,type=bind,consistency=cached"
40+
],
41+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
42+
// "postStartCommand": "/bin/bash .devcontainer/config_fetch.sh",
2243
"extensions": [
23-
"rust-lang.rust-analyzer"
44+
"ms-vscode.cpptools",
45+
"rust-lang.rust-analyzer",
46+
"tamasfe.even-better-toml",
47+
"vadimcn.vscode-lldb"
2448
],
2549
"remoteEnv": {
26-
"VM_REPO_PATH": "/workspaces/ori"
50+
"VM_REPO_PATH": "/workspaces/${localWorkspaceFolderBasename}"
2751
},
2852
"forwardPorts": [
2953
3000,
30-
30001
54+
3001
3155
]
3256
}

.devcontainer/zshrc.zsh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# Source Antigen
2-
source ~/.antigen/antigen.zsh
3-
autoload -U colors && colors
4-
setopt promptsubst
5-
# Set up oh-my-zsh
2+
source ${HOME}/.antigen/antigen.zsh;
63
antigen use oh-my-zsh
7-
# Set up plugins
84
antigen bundle git
9-
antigen bundle docker
10-
# Set up our preferred theme
11-
antigen theme cloud
12-
# Run all that config
5+
antigen bundle heroku
6+
antigen bundle pip
7+
antigen bundle lein
8+
antigen bundle command-not-found
9+
antigen bundle zsh-users/zsh-syntax-highlighting
10+
antigen theme awesomepanda
1311
antigen apply
1412

1513
# Set up Ctrl + Backspace and Ctrl + Del so you can move around and backspace faster (try it!)
1614
bindkey '^H' backward-kill-word
17-
bindkey -M emacs '^[[3;5~' kill-word
15+
bindkey '5~' kill-word
16+
17+
export HISTFILE="/cache/.zsh_history"

.github/workflows/unittest.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ jobs:
1919
run: yarn install
2020
- name: Check changefile
2121
run: yarn check-changefile
22+
- uses: actions/checkout@v4
23+
- uses: dtolnay/rust-toolchain@stable
24+
with:
25+
components: clippy
26+
- uses: giraffate/clippy-action@v1
27+
with:
28+
reporter: 'github-pr-review'
29+
github_token: ${{ secrets.GITHUB_TOKEN }}
30+
clippy_flags: -- --all-targets -Dwarnings
2231
tests-linux:
2332
runs-on: ubuntu-20.04
2433
steps:
@@ -28,6 +37,11 @@ jobs:
2837
run: yarn install && yarn build
2938
- name: cargo test
3039
run: cargo test --release
40+
- name: Run cargo-udeps
41+
uses: aig787/cargo-udeps-action@v1
42+
with:
43+
version: 'latest'
44+
args: '--all-targets'
3145
- name: run napi tests
3246
run: yarn test
3347
- name: upload-artifacts

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
/target
2+
/rust-analyzer-target
23

34

45
# Added by cargo
56
#
67
# already existing elements were commented out
78

8-
#/target
99
node_modules
1010
*.node
1111
index.js
1212
index.d.ts
1313
good-fences-violations.json
14+
.yarn/*
15+
!.yarn/releases
16+
!.yarn/plugins
17+
.pnp.*
1418

1519
# Previous accidentally committed files
1620
token

.persist/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*
2+
!README.md
3+
!.gitignore
4+
!cargo-registry/
5+
cargo-registry/*
6+
!cargo-registry/README.md

.persist/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# .persist
2+
This directory is used to persist state between machine builds (e.g. zsh_history)

.vscode/extensions.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"recommendations": [
3+
"rust-lang.rust-analyzer",
4+
"vadimcn.vscode-lldb",
5+
"ms-vscode-remote.remote-containers",
6+
"tamasfe.even-better-toml",
7+
"ms-vscode.cpptools"
8+
]
9+
}

.vscode/launch.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@
1717
"args": [
1818
"--config-path=${file}"
1919
],
20-
"cwd": "${workspaceFolder}"
20+
"cwd": "${workspaceFolder}",
21+
"initCommands": [
22+
"settings set target.disable-aslr false"
23+
],
24+
"env": {
25+
"RUST_BACKTRACE": "1"
26+
}
2127
}
2228
]
2329
}

.vscode/settings.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"rust-analyzer.checkOnSave": true,
3+
"rust-analyzer.check.command": "clippy",
4+
// runs rust-analyzer against a separate target directory than the normal rust compiler.
5+
// this is a workaround for the following issue: https://github.com/rust-lang/rust-analyzer/issues/17482
6+
"rust-analyzer.cargo.targetDir": "./rust-analyzer-target",
7+
// prefer using GDB over lldb because lldb's debug visualizations are worse.
8+
// See https://github.com/rust-lang/rust/issues/111868
9+
"rust-analyzer.debug.engine": "ms-vscode.cpptools",
10+
"rust-analyzer.debug.engineSettings": {
11+
"cppdbg": {
12+
"miDebuggerPath": "${env:HOME}/.cargo/bin/rust-gdb",
13+
"setupCommands": [
14+
{
15+
"description": "Enable pretty-printing for gdb",
16+
"text": "-enable-pretty-printing",
17+
"ignoreFailures": false
18+
}
19+
],
20+
}
21+
},
22+
"editor.formatOnSave": true,
23+
"files.autoSaveWorkspaceFilesOnly": true,
24+
"lldb.cargo": "/home/ubuntu/.cargo/bin/cargo",
25+
"terminal.integrated.shellIntegration.decorationsEnabled": "never",
26+
}

.yarn/install-state.gz

-197 KB
Binary file not shown.

0 commit comments

Comments
 (0)