Skip to content

Commit 9b83bbe

Browse files
committed
docs/ci: add PR template, CONTRIBUTING, Copilot review gate; fix Codecov conditions, quality-gates publish handling, TFM check efficiency; update branch protection guidance
1 parent f569c28 commit 9b83bbe

File tree

7 files changed

+102
-54
lines changed

7 files changed

+102
-54
lines changed

.github/BRANCH_PROTECTION.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Branch Protection Guidance for AiDotNet
22

3-
We recommend enabling branch protection on `master` with these required status checks:
3+
We recommend enabling branch protection on both `merge-dev2-to-master` (active base) and `master` (release) with these required status checks:
44

55
- CI (.NET) / Lint and Format Check
66
- CI (.NET) / Build
@@ -15,5 +15,6 @@ Also enable:
1515
- Dismiss stale approvals on new commits (optional)
1616
- Require status checks to pass before merging
1717
- Require branches to be up to date before merging
18+
- Require CODEOWNERS review
1819

1920
Note: The exact names shown in GitHub’s UI may include the workflow/job prefixes. Use the checks as they appear on a PR to configure the protection rules.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
1-
Please ensure your pull request adheres to the following guidelines:
1+
## User Story / Context
2+
- Reference: [US-XXX] (if applicable)
3+
- Base branch: `merge-dev2-to-master`
24

3-
- [ ] I have built my code and there are no build errors.
4-
- [ ] I have run all unit tests and all unit tests passed.
5-
- [ ] I have included positive flow unit tests for any method or class I added.
6-
- [ ] I have inluded negative flow unit tests for any method or class I added.
5+
## Summary
6+
- What changed and why (scoped strictly to the user story / PR intent)
7+
8+
## Verification
9+
- [ ] Builds succeed (scoped to changed projects)
10+
- [ ] Unit tests pass locally
11+
- [ ] Code coverage ≥ 90% for touched code
12+
- [ ] Codecov upload succeeded (if token configured)
13+
- [ ] TFM verification (net46, net6.0, net8.0) passes (if packaging)
14+
- [ ] No unresolved Copilot comments on HEAD
15+
16+
## Copilot Review Loop (Outcome-Based)
17+
Record counts before/after your last push:
18+
- Comments on HEAD BEFORE: [N]
19+
- Comments on HEAD AFTER (60s): [M]
20+
- Final HEAD SHA: [sha]
21+
22+
## Files Modified
23+
- [ ] List files changed (must align with scope)
24+
25+
## Notes
26+
- Any follow-ups, caveats, or migration details
727

8-
Thanks for contributing!

.github/workflows/ci.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
run: dotnet test AiDotNet.sln -c Release --no-build --collect:"XPlat Code Coverage" --results-directory ./TestResults
6161

6262
- name: Upload coverage to Codecov
63-
if: secrets.CODECOV_TOKEN != ''
63+
if: ${{ secrets.CODECOV_TOKEN != '' }}
6464
uses: codecov/codecov-action@v4
6565
with:
6666
token: ${{ secrets.CODECOV_TOKEN }}
@@ -109,14 +109,15 @@ jobs:
109109
dotnet test AiDotNet.sln --configuration Release --collect:"XPlat Code Coverage" --results-directory ./TestResults
110110
111111
- name: Upload coverage to Codecov (only if token set)
112-
if: ${{ secrets.CODECOV_TOKEN != '' }}
113-
uses: codecov/codecov-action@v4
114-
with:
115-
token: ${{ secrets.CODECOV_TOKEN }}
116-
files: |
117-
./TestResults/**/coverage.cobertura.xml
118-
flags: unittests
119-
fail_ci_if_error: false
112+
run: |
113+
if [ -n "${CODECOV_TOKEN}" ]; then
114+
echo "Uploading coverage to Codecov..."
115+
npx codecov -t "${CODECOV_TOKEN}" -f "./TestResults/**/coverage.cobertura.xml" -F unittests || echo "Codecov upload failed"
116+
else
117+
echo "CODECOV_TOKEN not set; skipping Codecov upload."
118+
fi
119+
env:
120+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
120121

121122
integration-test:
122123
name: Integration Tests
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Copilot Review Gate
2+
3+
on:
4+
pull_request:
5+
branches: [ merge-dev2-to-master ]
6+
7+
permissions:
8+
pull-requests: read
9+
contents: read
10+
11+
jobs:
12+
gate:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check unresolved Copilot comments on HEAD
16+
env:
17+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
run: |
19+
set -e
20+
REPO="${{ github.repository }}"
21+
PR_NUMBER="${{ github.event.pull_request.number }}"
22+
HEAD=$(gh pr view "$PR_NUMBER" --repo "$REPO" --json headRefOid --jq .headRefOid)
23+
COUNT=$(gh api repos/$REPO/pulls/$PR_NUMBER/comments --paginate \
24+
--jq "[ .[] | select((.user.login|test(\"copilot\|advanced\|security\|bot\";\"i\")) and .commit_id == \"$HEAD\") ] | length")
25+
echo "Unresolved Copilot comments on HEAD: $COUNT"
26+
if [ "$COUNT" -gt 0 ]; then
27+
echo "Found $COUNT unresolved Copilot comments on HEAD $HEAD"
28+
exit 1
29+
fi

.github/workflows/quality-gates.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,19 @@ jobs:
3131
if [ -f "src/AiDotNet.csproj" ]; then
3232
dotnet publish src/AiDotNet.csproj -c Release -o publish
3333
else
34-
# fallback: publish all projects in src
35-
for p in src/*.csproj; do dotnet publish "$p" -c Release -o publish || true; done
34+
failed_projects=""
35+
shopt -s nullglob
36+
for p in src/*.csproj; do
37+
dotnet publish "$p" -c Release -o publish
38+
if [ $? -ne 0 ]; then
39+
echo "Publish failed for $p"
40+
failed_projects="$failed_projects $p"
41+
fi
42+
done
43+
if [ -n "$failed_projects" ]; then
44+
echo "Error: The following projects failed to publish:$failed_projects"
45+
exit 1
46+
fi
3647
fi
3748
3849
- name: Analyze size vs baseline

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ jobs:
6262
for pkg in "${pkgs[@]}"; do
6363
echo "Inspecting $pkg"
6464
files=$(unzip -Z1 "$pkg")
65-
echo "$files" | grep -qE '^lib/net46/.+\.dll$' || { echo "Missing net46 lib in package"; exit 1; }
66-
echo "$files" | grep -qE '^lib/net6\.0/.+\.dll$' || { echo "Missing net6.0 lib in package"; exit 1; }
67-
echo "$files" | grep -qE '^lib/net8\.0/.+\.dll$' || { echo "Missing net8.0 lib in package"; exit 1; }
65+
for tfm in net46 net6.0 net8.0; do
66+
echo "$files" | grep -qE "^lib/${tfm}/.+\\.dll$" || { echo "Missing ${tfm} lib in package"; exit 1; }
67+
done
6868
done
6969
7070
- name: Upload package artifact

CONTRIBUTING.md

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,26 @@
1-
## Contributing
1+
# Contributing
22

3-
[fork]: /fork
4-
[pr]: /compare
5-
[code-of-conduct]: CODE_OF_CONDUCT.md
3+
## Base Branch
4+
- Use `merge-dev2-to-master` as the working base for CI and PRs.
65

7-
Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
6+
## Copilot Review Loop (Mandatory)
7+
1. Get the PR `headRefOid` (HEAD SHA).
8+
2. Retrieve review comments and filter to those where `commit_id == headRefOid` and author matches "copilot".
9+
3. Apply suggestions exactly (or implement an equivalent real fix).
10+
4. Commit (no force push), wait 30–60s for re-review, re-check unresolved count.
11+
5. Iterate until unresolved count = 0.
812

9-
Please note that this project is released with a [Contributor Code of Conduct][code-of-conduct]. By participating in this project you agree to abide by its terms.
13+
## CI/CD Expectations
14+
- Multi-TFM: net46, net6.0, net8.0.
15+
- Coverage ≥ 90% for modified code paths; upload to Codecov if `CODECOV_TOKEN` is set.
16+
- Release workflow validates packaged TFMs before publishing.
1017

11-
## Issues and PRs
18+
## Scope Discipline
19+
- Only modify files relevant to the user story or bug.
20+
- Don’t introduce unrelated refactors.
1221

13-
If you have suggestions for how this project could be improved, or want to report a bug, open an issue! We'd love all and any contributions. If you have questions, too, we'd love to hear them.
22+
## YAML Hygiene
23+
- No literal `\n` in names; correct indentation; steps under `steps`.
24+
- Shell `if` blocks must close with `fi` before next step.
25+
- Use `${{ ... }}` expression syntax for job/step `if` where supported.
1426

15-
We'd also love PRs. If you're thinking of a large PR, we advise opening up an issue first to talk about it, though! Look at the links below if you're not sure how to open a PR.
16-
17-
## Submitting a pull request
18-
19-
1. [Fork][fork] and clone the repository.
20-
1. Install the .NET 8 SDK if you don't have it installed already.
21-
1. Make sure the unit tests pass on your machine (make sure to run all unit tests inside the unit test project).
22-
1. Create a new branch: `git checkout -b my-branch-name`.
23-
1. Make your change, add tests, and make sure the tests still pass.
24-
1. Push to your fork and [submit a pull request][pr].
25-
1. Pat your self on the back and wait for your pull request to be reviewed and merged.
26-
27-
Here are a few things you can do that will increase the likelihood of your pull request being accepted:
28-
29-
- Write and update unit tests.
30-
- Keep your changes as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
31-
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
32-
33-
Work in Progress pull requests are also welcome to get feedback early on, or if there is something blocked you.
34-
35-
## Resources
36-
37-
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
38-
- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
39-
- [GitHub Help](https://help.github.com)

0 commit comments

Comments
 (0)