Skip to content

Commit 184eff4

Browse files
authored
Merge pull request #5 from microsoft/sync/ado-main
Initial sync from ADO to GitHub
2 parents d26068e + 92adf82 commit 184eff4

519 files changed

Lines changed: 125543 additions & 7 deletions

File tree

Some content is hidden

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

.cargo/README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Cargo Configuration Strategy
2+
3+
This repository uses a dual-configuration approach to support both CI builds and OSS developers.
4+
5+
## For Developers (Default)
6+
7+
The default `.cargo/config.toml` uses **crates.io** directly:
8+
- No authentication required
9+
- Works seamlessly for OSS developers
10+
- No ADO access needed
11+
12+
```bash
13+
# Just clone and build - works out of the box
14+
git clone <repo>
15+
cd mssql-tds
16+
cargo build
17+
```
18+
19+
## For CI/Pipeline
20+
21+
CI builds use `.cargo/config.ci.toml` which configures:
22+
- **Authenticated Azure Artifacts feeds** (`mssql-rs_Public` and `mssql-rs`)
23+
- Source replacement: `crates.io``mssql-rs_Public` (ADO feed with crates.io as upstream)
24+
- Authentication via `CargoAuthenticate@0` task (sets `CARGO_REGISTRIES_*_TOKEN` env vars)
25+
26+
### How It Works
27+
28+
1. **Apply CI config**: `.pipeline/scripts/apply-ci-cargo-config.{sh,ps1}` copies `config.ci.toml``config.toml`
29+
2. **Authenticate**: `CargoAuthenticate@0` task sets token environment variables
30+
3. **Build**: Cargo uses authenticated ADO feeds
31+
32+
### Pipeline Flow
33+
34+
```yaml
35+
# All build templates include these steps:
36+
- script: bash .pipeline/scripts/apply-ci-cargo-config.sh
37+
displayName: Apply CI cargo configuration
38+
39+
- task: CargoAuthenticate@0
40+
inputs:
41+
configFile: '.cargo/config.toml'
42+
displayName: Authenticate cargo registries
43+
44+
# Now cargo commands use authenticated feeds
45+
- script: cargo build
46+
```
47+
48+
## Files
49+
50+
| File | Purpose |
51+
|------|---------|
52+
| `.cargo/config.toml` | **Default** - Uses crates.io (for developers) |
53+
| `.cargo/config.ci.toml` | **CI override** - Uses authenticated ADO feeds |
54+
| `.pipeline/scripts/apply-ci-cargo-config.sh` | Applies CI config (Linux/Mac) |
55+
| `.pipeline/scripts/apply-ci-cargo-config.ps1` | Applies CI config (Windows) |
56+
57+
## Benefits
58+
59+
✅ **Zero friction for OSS developers** - Just clone and build
60+
✅ **Fast CI builds** - Uses ADO artifact cache
61+
✅ **Secure** - Tokens only exist in CI, not committed to repo
62+
✅ **Flexible** - Easy to switch between modes
63+
64+
## Troubleshooting
65+
66+
### For Developers
67+
If you see authentication errors, ensure you're using the default config:
68+
```bash
69+
git checkout .cargo/config.toml
70+
```
71+
72+
### For CI
73+
Ensure the apply-ci-cargo-config step runs **before** `CargoAuthenticate@0`:
74+
```yaml
75+
- script: bash .pipeline/scripts/apply-ci-cargo-config.sh
76+
- task: CargoAuthenticate@0
77+
inputs:
78+
configFile: '.cargo/config.toml'
79+
```

.cargo/config.ci.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[alias]
2+
bfmt = "fmt -- --check"
3+
bclippy = "clippy --workspace --frozen --all-features --all-targets -- -D warnings"
4+
btest = "llvm-cov nextest --workspace --frozen --no-report --all-targets --no-fail-fast --profile ci --success-output immediate"
5+
6+
# CI Configuration: Uses authenticated Azure Artifacts feeds
7+
# This file is applied in CI pipelines before running cargo commands
8+
# Authentication tokens are provided by CargoAuthenticate@0 task via environment variables:
9+
# - CARGO_REGISTRIES_MSSQL_RS_PUBLIC_TOKEN
10+
# - CARGO_REGISTRIES_MSSQL_RS_TOKEN
11+
12+
[registries]
13+
# Authenticated URLs with ~force-auth to ensure token usage
14+
"mssql-rs_Public" = { index = "sparse+https://pkgs.dev.azure.com/sqlclientdrivers/public/_packaging/mssql-rs_Public~force-auth/Cargo/index/" }
15+
"mssql-rs" = { index = "sparse+https://pkgs.dev.azure.com/sqlclientdrivers/mssql-rs/_packaging/mssql-rs~force-auth/Cargo/index/" }
16+
17+
# Replace crates.io with our Azure Artifacts feed (with crates.io as upstream)
18+
[source.crates-io]
19+
replace-with = "mssql-rs_Public"
20+
21+
[registry]
22+
global-credential-providers = ["cargo:token", "cargo:macos-keychain", "cargo:wincred"]

.cargo/config.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[alias]
2+
bfmt = "fmt -- --check"
3+
bclippy = "clippy --workspace --frozen --all-features --all-targets -- -D warnings"
4+
btest = "llvm-cov nextest --workspace --frozen --no-report --all-targets --no-fail-fast --profile ci --success-output immediate"
5+
6+
[registries]
7+
"mssql-rs_Public" = { index = "sparse+https://pkgs.dev.azure.com/sqlclientdrivers/public/_packaging/mssql-rs_Public/Cargo/index/" }
8+
9+
[source.crates-io]
10+
replace-with = "mssql-rs_Public"

.config/nextest.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[profile.ci.junit] # this can be some other profile, too
2+
path = "junit.xml"
3+
4+
[profile.ci]
5+
retries = 5
6+
7+
# Test groups for tests that need to run sequentially
8+
# TLS tests have race conditions with macOS Security.framework when creating
9+
# PKCS12 identities in parallel, so they must run one at a time.
10+
[test-groups]
11+
tls-tests = { max-threads = 1 }
12+
13+
[[profile.default.overrides]]
14+
filter = "test(mock_server_tls_tests::)"
15+
test-group = "tls-tests"
16+
17+
[[profile.ci.overrides]]
18+
filter = "test(mock_server_tls_tests::)"
19+
test-group = "tls-tests"

.devcontainer/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
4+
FROM mcr.microsoft.com/devcontainers/rust:1-1-bullseye
5+
6+
USER vscode
7+
8+
# Install nightly toolchain to give access to nightly features for docs-site build.
9+
RUN rustup toolchain install nightly
10+
11+
# Install cargo dependencies
12+
RUN cargo install cargo-llvm-cov --version 0.6.16 --locked && cargo install cargo-nextest --version 0.9.99 --locked

.devcontainer/devcontainer.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
{
3+
"name": "Rust Ubuntu 2404",
4+
"build": {
5+
"dockerfile": "Dockerfile"
6+
},
7+
8+
// Features to add to the dev container. More info: https://containers.dev/features.
9+
"features": {
10+
"ghcr.io/devcontainers/features/azure-cli:1": {},
11+
"ghcr.io/devcontainers/features/git:1": {},
12+
"ghcr.io/devcontainers/features/github-cli:1": {},
13+
"ghcr.io/devcontainers/features/sshd:1": {},
14+
"ghcr.io/devcontainers/features/node:1": {},
15+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
16+
"ghcr.io/devcontainers/features/python:1": {
17+
"version": "3.12"
18+
}
19+
},
20+
21+
"customizations": {
22+
"vscode": {
23+
"settings": {},
24+
"extensions": [
25+
"rust-lang.rust-analyzer",
26+
"vadimcn.vscode-lldb",
27+
"ms-vscode.cpptools",
28+
"ms-mssql.mssql",
29+
"ms-python.python"
30+
]
31+
}
32+
},
33+
34+
"postCreateCommand": "/bin/bash .devcontainer/post-create.sh"
35+
}

.devcontainer/post-create.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
# This script is executed after the devcontainer is created
4+
cargo fetch
5+
6+
curl -o- https://fnm.vercel.app/install | bash
7+
8+
FNM_PATH="/home/vscode/.local/share/fnm"
9+
if [ -d "$FNM_PATH" ]; then
10+
export PATH="$FNM_PATH:$PATH"
11+
eval "`fnm env`"
12+
fi
13+
fnm install 20
14+
fnm use 20
15+
16+
corepack enable
17+
18+
# Setup Python virtual environment for mssql-py-core development
19+
echo "Setting up Python virtual environment..."
20+
python3 -m venv /workspaces/mssql-tds/myvenv
21+
source /workspaces/mssql-tds/myvenv/bin/activate
22+
23+
# Install maturin (build tool) and dev dependencies from pyproject.toml
24+
pip install --upgrade pip
25+
pip install maturin
26+
pip install -e "/workspaces/mssql-tds/mssql-py-core[dev]"
27+
28+
echo "Python venv ready at /workspaces/mssql-tds/myvenv"
29+
echo "Run 'source /workspaces/mssql-tds/myvenv/bin/activate' to activate"

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.githooks/pre-commit-checks.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
cargo clippy -- -D warnings
3+
4+
cargo fmt --check

.githooks/pre-commit-checks.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
echo " Running Clippy "
4+
cargo clippy -- -D warnings
5+
6+
echo "Running format checker"
7+
8+
cargo fmt --check

0 commit comments

Comments
 (0)