Skip to content

Commit 6b66e4b

Browse files
committed
Add a better setup for copilot
1 parent 83d149f commit 6b66e4b

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed

.github/copilot-instructions.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# GitHub Copilot Instructions
2+
3+
## Code Writing Standards
4+
- Follow established code-writing standards for your language (spacing, comments, naming).
5+
- Consider internal coding rules for folder and function naming.
6+
- Follow the "boy scout rule": Always leave the codebase cleaner than you found it.
7+
8+
## Comment Usage
9+
- Use comments sparingly and make them meaningful.
10+
- Avoid commenting on obvious things; use comments to explain "why" or unusual behavior.
11+
12+
## Conditional Encapsulation
13+
- Encapsulate nested if/else statements into functions with descriptive names for clarity.
14+
15+
## DRY Principle
16+
- Avoid code duplication; reuse code via functions, classes, modules, or libraries.
17+
- Modify code in one place if updates are needed.
18+
19+
## Function Length & Responsibility
20+
- Write short, focused functions (single responsibility principle).
21+
- Break up long or complex functions into smaller ones.
22+
23+
## General Code Style & Readability
24+
- Write readable, understandable, and maintainable code.
25+
- Prioritize clarity and adhere to coding standards.
26+
- Regularly review and refactor code for structure and maintainability.
27+
- Use version control (e.g., Git) for collaboration.
28+
29+
## Naming Conventions
30+
- Use meaningful, descriptive names for variables, functions, and classes.
31+
- Names should reflect purpose and behavior; avoid names that require comments to explain intent.
32+
33+
## Making your changes pass CI
34+
- Before submitting any changes, make sure to run the following commands:
35+
- `cargo fmt` to format all code according to the style guidelines.
36+
- `RUSTFLAGS="-D dead-code -D nonstandard-style -D unused-imports -D unused-mut -D unused-variables -D unused-unsafe -D unreachable-patterns -D bad-style -D improper-ctypes -D unused-allocation -D unused-comparisons -D while-true -D unconditional-recursion -D bare-trait-objects -D function_item_references -D clippy::uninlined_format_args " cargo clippy --all --exclude wasmer-swift --locked --fix --allow-dirty -- -D clippy::all` to check for common mistakes and improve code quality.
37+
- If these commands don't pass, CI will reject your changes.
38+
- Run the tests for the code you changed and everything that depends on it.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: "Copilot Setup Steps"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- .github/workflows/copilot-setup-steps.yml
8+
pull_request:
9+
paths:
10+
- .github/workflows/copilot-setup-steps.yml
11+
12+
env:
13+
RUST_BACKTRACE: 1
14+
MSRV: "1.90"
15+
16+
jobs:
17+
# The job MUST be called `copilot-setup-steps`
18+
copilot-setup-steps:
19+
runs-on: ubuntu-latest
20+
21+
permissions:
22+
contents: read
23+
24+
steps:
25+
- uses: actions/checkout@v6
26+
- name: Set up libstdc++ on Linux
27+
run: |
28+
sudo apt-get update -y
29+
sudo apt-get install -y --allow-downgrades libstdc++6
30+
sudo apt-get install --reinstall g++
31+
32+
- name: Install Rust
33+
uses: dtolnay/rust-toolchain@stable
34+
with:
35+
toolchain: ${{ env.MSRV }}
36+
target: x86_64-unknown-linux-gnu
37+
components: rustc,cargo,rust-std,rust-src,clippy,rustfmt,rust-analyzer,rust-docs
38+
39+
- name: Install Nextest
40+
uses: taiki-e/install-action@nextest
41+
42+
- name: Install LLVM
43+
shell: bash
44+
run: |
45+
curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" --retry 3 --proto '=https' --tlsv1.2 -sSf ${{ env.LLVM_URL }} -L -o llvm.tar.xz
46+
LLVM_DIR=$(pwd)/${{ env.LLVM_DIR }}
47+
mkdir ${LLVM_DIR}
48+
tar xf llvm.tar.xz --strip-components=1 -C ${LLVM_DIR}
49+
echo "${LLVM_DIR}/bin" >> $GITHUB_PATH
50+
echo "${LLVM_DIR}/usr/bin" >> $GITHUB_PATH
51+
echo "LLVM_SYS_211_PREFIX=${LLVM_DIR}" >> $GITHUB_ENV
52+
echo "ENABLE_LLVM=1" >> $GITHUB_ENV
53+
env:
54+
LLVM_DIR: .llvm
55+
LLVM_URL: https://github.com/wasmerio/llvm-custom-builds/releases/download/21.x/llvm-linux-amd64.tar.xz
56+
57+
- name: Install wasixcc
58+
uses: wasix-org/wasixcc@main
59+
with:
60+
github_token: ${{ secrets.GITHUB_TOKEN }}
61+
sysroot-tag: v2025-12-22.1
62+
63+
- name: Ensure the setup works
64+
run: |
65+
cargo fmt --check || true
66+
RUSTFLAGS="-D dead-code -D nonstandard-style -D unused-imports -D unused-mut -D unused-variables -D unused-unsafe -D unreachable-patterns -D bad-style -D improper-ctypes -D unused-allocation -D unused-comparisons -D while-true -D unconditional-recursion -D bare-trait-objects -D function_item_references -D clippy::uninlined_format_args " cargo clippy --all --exclude wasmer-swift --locked --allow-dirty -- -D clippy::all || true

0 commit comments

Comments
 (0)