Skip to content

Commit 0884c43

Browse files
Merge pull request #7 from michaeldeongreen/test
Promote test to main
2 parents cb39a3a + b606e7f commit 0884c43

21 files changed

Lines changed: 1707 additions & 1070 deletions

.env.sample

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copy this file to .env (gitignored) and paste in your feature workspace
2+
# IDs. The workspace_swap.py bootstrap script reads them so you don't have to
3+
# type GUIDs at a prompt.
4+
#
5+
# Find these in Fabric:
6+
# - Workspace ID: open the workspace, gear icon (Workspace settings),
7+
# "About" -> "Workspace ID".
8+
# - Lakehouse ID: open the lakehouse item, copy the GUID from the URL
9+
# (the segment after /lakehouses/), or from the lakehouse details pane.
10+
#
11+
# These values are per-developer and per-feature-branch. Once workspace_swap.py
12+
# bootstraps a branch, the IDs are cached in the value set on disk and the
13+
# .env file is no longer consulted for that branch.
14+
15+
FEATURE_WORKSPACE_ID=00000000-0000-0000-0000-000000000000
16+
FEATURE_LAKEHOUSE_ID=00000000-0000-0000-0000-000000000000

.github/copilot-instructions.md

Lines changed: 61 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,61 @@
1-
# Project Guidelines
2-
3-
## Overview
4-
5-
Reference implementation for CI/CD in Microsoft Fabric. Demonstrates version control, deployment, and environment-specific configuration for Fabric workspace items using GitHub Actions and [fabric-cicd](https://microsoft.github.io/fabric-cicd).
6-
7-
## Project Layout
8-
9-
```
10-
scripts/ Python CLI scripts (stdlib-only, Python 3.10+)
11-
tests/ pytest unit tests
12-
data/fabric/ Fabric item definitions (git-synced from Fabric workspaces)
13-
.github/workflows/ GitHub Actions CI/CD pipelines
14-
.github/instructions/ Path-specific Copilot instructions (Python, Actions)
15-
```
16-
17-
## Build and Test
18-
19-
```bash
20-
pip install -r requirements-dev.txt
21-
python -m pytest tests/ -v
22-
```
23-
24-
No build step — scripts are standalone CLI tools, not an installable package. `pyproject.toml` configures pytest only (`pythonpath = ["scripts"]`).
25-
26-
## Key Scripts
27-
28-
- `scripts/branch_env.py` — Manages feature branch workspace bindings (bootstrap, reset, validate). Uses an **item type registry** pattern — new Fabric item types are added as config entries, not new functions.
29-
- `scripts/branch_env.py --validate` — CI check for PR readiness (dev IDs present, no stray value sets).
30-
31-
## Fabric Item Types
32-
33-
Items fall into two categories based on how they reference environment resources:
34-
35-
- **Actual IDs** (SemanticModel, Notebook): Embed real workspace/lakehouse GUIDs. Must be rewritten by `branch_env.py` for feature branches and reverted before PR.
36-
- **Logical IDs** (Ontology, DataAgent): Reference items via `.platform` `logicalId`, resolved by Fabric at runtime. Portable across Branch Out workspaces — no rewriting needed.
37-
38-
## CI/CD Configuration
39-
40-
- `data/fabric/parameter.yml` — Deploy-time `find_replace` rules for fabric-cicd. Maps dev IDs to dynamic placeholders (`$workspace.$id`, `$items.Lakehouse.*.$id`).
41-
- `data/fabric/Patterns_Variables.VariableLibrary/` — Runtime configuration via value sets (Test, Prod, feature branches).
42-
43-
## Conventions
44-
45-
- Path-specific instructions in `.github/instructions/` govern Python and Actions code style — follow them.
46-
- Never commit notebook META blocks containing internal metadata (security).
47-
- Validate GUIDs from external sources before using them.
48-
- Pin GitHub Actions to commit SHAs, not version tags.
49-
- All file I/O must specify `encoding="utf-8"`.
50-
51-
## Workflows
52-
53-
| Workflow | Trigger | Purpose |
54-
|----------|---------|---------|
55-
| `validate-branch-env.yml` | PR to `dev` | Blocks merge if dev IDs not restored |
56-
| `run-tests.yml` | PR (any branch) | Runs pytest when scripts/tests change |
57-
58-
## Documentation
59-
60-
See `fabric-development-process.md` for the Branch Out workflow, item type reference table, and step-by-step bootstrap/reset guides. See `fabric-hybrid-cicd-guide.md` for the deployment architecture.
1+
# Project Guidelines
2+
3+
## Overview
4+
5+
Reference implementation for CI/CD in Microsoft Fabric. Demonstrates version control, deployment, and environment-specific configuration for Fabric workspace items using GitHub Actions and [fabric-cicd](https://microsoft.github.io/fabric-cicd).
6+
7+
## Project Layout
8+
9+
```
10+
scripts/ Python CLI scripts (stdlib-only, Python 3.10+)
11+
tests/ pytest unit tests
12+
data/fabric/ Fabric item definitions (git-synced from Fabric workspaces)
13+
.github/workflows/ GitHub Actions CI/CD pipelines
14+
.github/instructions/ Path-specific Copilot instructions (Python, Actions)
15+
```
16+
17+
## Build and Test
18+
19+
```bash
20+
pip install -r requirements-dev.txt
21+
python -m pytest tests/ -v
22+
```
23+
24+
No build step — scripts are standalone CLI tools, not an installable package. `pyproject.toml` configures pytest only (`pythonpath = ["scripts"]`).
25+
26+
## Key Scripts
27+
28+
- `scripts/workspace_swap.py` — Swaps Fabric workspace IDs in tracked files between dev and a feature workspace, and provides a CI readiness check (`--check-ready`). Uses an **item type registry** pattern — new Fabric item types are added as config entries, not new functions.
29+
- `scripts/workspace_swap.py --check-ready` — CI check for PR readiness (dev IDs present, no stray value sets).
30+
31+
## Fabric Item Types
32+
33+
Items fall into two categories based on how they reference environment resources:
34+
35+
- **Actual IDs** (SemanticModel, Notebook): Embed real workspace/lakehouse GUIDs. Must be rewritten by `workspace_swap.py` for feature branches and reverted before PR.
36+
- **Logical IDs** (Ontology, DataAgent): Reference items via `.platform` `logicalId`, resolved by Fabric at runtime. Portable across Branch Out workspaces — no rewriting needed.
37+
38+
## CI/CD Configuration
39+
40+
- `data/fabric/parameter.yml` — Deploy-time `find_replace` rules for fabric-cicd. Maps dev IDs to dynamic placeholders (`$workspace.$id`, `$items.Lakehouse.*.$id`).
41+
- `data/fabric/Patterns_Variables.VariableLibrary/` — Runtime configuration via value sets (Test, Prod, feature branches).
42+
43+
## Conventions
44+
45+
- Path-specific instructions in `.github/instructions/` govern Python and Actions code style — follow them.
46+
- Never commit notebook META blocks containing internal metadata (security).
47+
- Validate GUIDs from external sources before using them.
48+
- Pin GitHub Actions to commit SHAs, not version tags.
49+
- All file I/O must specify `encoding="utf-8"`.
50+
- Local developer config goes in `.env` (gitignored). A committed `.env.sample` documents the expected keys. `scripts/workspace_swap.py` reads feature workspace IDs from `.env` when swapping to a feature workspace.
51+
52+
## Workflows
53+
54+
| Workflow | Trigger | Purpose |
55+
|----------|---------|---------|
56+
| `check-pr-ready.yml` | PR to `dev` | Blocks merge if dev IDs not restored |
57+
| `run-tests.yml` | PR (any branch) | Runs pytest when scripts/tests change |
58+
59+
## Documentation
60+
61+
See `fabric-development-process.md` for the Branch Out workflow, item type reference table, and step-by-step swap-to-feature / swap-to-dev guides. See `fabric-hybrid-cicd-guide.md` for the deployment architecture.

.github/instructions/python.instructions.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ When generating or improving Python code in this repository:
2525

2626
## Dependencies
2727
- Keep scripts stdlib-only when possible; gate optional imports with try/except
28-
- When external packages are needed, prefer: `requests`, `azure-identity`
28+
- For environment-specific config in CLI scripts, prefer `.env` files (parsed with stdlib) over external libraries like `python-dotenv`
29+
- When external packages are unavoidable, justify in the script docstring; add a `>=` minimum bound to the relevant requirements file
2930
- Never pin to exact versions in scripts; use `>=` minimum bounds in requirements files
3031

3132
## Security
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
description: Run the CI-style readiness check locally — verifies dev IDs are restored and no stray feature value sets remain.
3+
mode: agent
4+
---
5+
Run `python scripts/workspace_swap.py --check-ready` from the repo root and report the output to me. This is the same check the `check-pr-ready.yml` GitHub Actions workflow runs on every PR to `dev`. It does not modify any files.
6+
7+
If the check fails, the output will tell you which files still contain feature IDs. The fix is usually to run `/swap-to-dev`.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
description: Preview what swap-to-dev would change without writing any files.
3+
mode: agent
4+
---
5+
Run `python scripts/workspace_swap.py --swap-to-dev --dry-run` from the repo root and report the output to me. This is a preview — no files will be modified. Use this before running `/swap-to-dev` to verify the planned revert looks correct.
6+
7+
After the script finishes, summarize what would have been changed.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
description: Swap the IDs back to dev and remove the feature value set (run before opening a PR).
3+
mode: agent
4+
---
5+
Run `python scripts/workspace_swap.py --swap-to-dev` from the repo root and report the output to me. The script will revert tracked Fabric files (semantic model, notebooks) back to the dev workspace IDs, delete the feature value set for the current branch, and remove the feature entry from settings.json. It reads the feature IDs from the existing value set on disk — `.env` is not consulted.
6+
7+
After the script finishes, summarize what changed and remind me to commit and push the changes before opening a PR to `dev`.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
description: Preview what swap-to-feature would change without writing any files.
3+
mode: agent
4+
---
5+
Run `python scripts/workspace_swap.py --dry-run` from the repo root and report the output to me. This is a preview — no files will be modified. Use this before running `/swap-to-feature` to verify the planned changes look correct.
6+
7+
After the script finishes, summarize what would have been changed.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
description: Swap the repo's IDs to your feature workspace and create the value set for the current branch.
3+
mode: agent
4+
---
5+
Run `python scripts/workspace_swap.py` from the repo root and report the output to me. The script will rewrite tracked Fabric files (semantic model, notebooks) so they point at your feature workspace instead of dev, create a feature value set, and update settings.json. It reads the feature workspace and lakehouse GUIDs from `.env` at the repo root — if `.env` is missing or empty, it will fall back to an interactive prompt.
6+
7+
After the script finishes, summarize what changed and remind me to commit and push the changes, then sync the workspace from the Fabric UI.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Validate Branch Environment
1+
name: Check PR Ready
22

33
on:
44
pull_request:
@@ -9,7 +9,7 @@ permissions:
99
contents: read
1010

1111
jobs:
12-
validate-branch-env:
12+
check-pr-ready:
1313
name: Check for non-dev IDs in Fabric items
1414
runs-on: ubuntu-latest
1515
timeout-minutes: 5
@@ -23,5 +23,5 @@ jobs:
2323
with:
2424
python-version: "3.12"
2525

26-
- name: Validate branch environment
27-
run: python scripts/branch_env.py --validate
26+
- name: Check PR ready
27+
run: python scripts/workspace_swap.py --check-ready

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
11
*.pyc
2+
__pycache__/
3+
4+
# Python virtual environments
5+
.venv/
6+
venv/
7+
8+
# Local developer config (copied from .env.sample)
9+
.env

0 commit comments

Comments
 (0)