Skip to content

Commit 5fdd6af

Browse files
Improve setup for GitHub Copilot coding agent (#170)
By default, the coding agent doesn't seem to know that it should set up (say) the TUN device, or install nextest, and it needs to spend time figuring it out, or failing to do so. The `.github/workflows/copilot-setup-steps.yml` sets these things up in advance. Additionally, it noticeably seems to forget to format code, so I've added `.github/copilot-instructions.md` that tells it to do this for each commit. I also gave it some more information, which should hopefully send it down a nicer path that better matches workflow within our repo.
1 parent 6a534c5 commit 5fdd6af

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

.github/copilot-instructions.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
This repository contains a Rust-based, security-focused sandboxing library OS. To maintain high code quality and consistency, please adhere to the following guidelines when contributing.
2+
3+
## Code Standards
4+
5+
### Required Before Each Commit
6+
- Run `cargo fmt` to format all Rust files using `rustfmt`.
7+
- This ensures consistent code style across the codebase.
8+
9+
### Development Workflow
10+
The recommended sequence during development is:
11+
1. **Format**: `cargo fmt`
12+
2. **Build**: `cargo build`
13+
3. **Lint**: `cargo clippy --all-targets --all-features`
14+
4. **Test**: `cargo nextest run`
15+
16+
- Full CI checks are defined in `.github/workflows/ci.yml`.
17+
18+
## Key Guidelines
19+
20+
1. Follow Rust best practices and idiomatic patterns.
21+
2. Preserve the existing code structure and organization.
22+
3. Minimize use of `unsafe` code. Every `unsafe` block **must** include a clear safety comment explaining why it's sound. Always prefer safe abstractions and code where possible.
23+
4. Write unit tests for new functionality, especially if it affects public interfaces.
24+
- Extremely simple changes do not require explicit unit tests.
25+
5. Document all public APIs and non-trivial implementation details.
26+
6. Avoid introducing new dependencies unless strictly necessary. If a dependency is added:
27+
- It must be justified.
28+
- Prefer `default-features = false` in `Cargo.toml`.
29+
7. Favor `no_std` compatibility wherever feasible.
30+
- Some crates in the workspace may use `std`, but this should be deliberate and justified.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Customize GitHub Copilot coding agent development environment
2+
name: "Copilot Setup Steps"
3+
4+
# Automatically run the setup steps when they are changed to allow for easy validation, and
5+
# allow manual testing through the repository's "Actions" tab
6+
on:
7+
workflow_dispatch:
8+
push:
9+
paths:
10+
- .github/workflows/copilot-setup-steps.yml
11+
pull_request:
12+
paths:
13+
- .github/workflows/copilot-setup-steps.yml
14+
15+
jobs:
16+
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
17+
copilot-setup-steps:
18+
runs-on: ubuntu-latest
19+
20+
# Set the permissions to the lowest permissions possible needed for your steps.
21+
# Copilot will be given its own token for its operations.
22+
permissions:
23+
# Needed to clone the repository
24+
contents: read
25+
26+
# You can define any steps you want, and they will run before the agent starts.
27+
# If you do not check out your code, Copilot will do this for you.
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v4
31+
- name: Set up Rust
32+
run: |
33+
rustup toolchain install $(awk -F'"' '/channel/{print $2}' rust-toolchain.toml) --profile minimal --no-self-update --component rustfmt,clippy
34+
- name: Set up Nextest
35+
run: |
36+
curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
37+
- name: Set up tun device for Linux userland testing
38+
run: |
39+
sudo ./litebox_platform_linux_userland/scripts/tun-setup.sh

0 commit comments

Comments
 (0)