Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sh text eol=lf
9 changes: 9 additions & 0 deletions .github/workflows/CI-Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ jobs:
with:
dotnet-version: '8.0.x'

- name: Set up Node.js for package validation tests
uses: actions/setup-node@v6
with:
node-version: '24'
package-manager-cache: false

- name: Test package validation
run: node --test scripts/package.test.mjs

- name: Restore dependencies of cmf-codereviewer
run: dotnet restore cmf-codereview.sln

Expand Down
132 changes: 132 additions & 0 deletions .github/workflows/Package-CodeReview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: Package-CodeReview

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

permissions:
contents: read

defaults:
run:
shell: bash
working-directory: cmf-codereview

jobs:
package:
runs-on: ubuntu-24.04
timeout-minutes: 30
outputs:
version: ${{ steps.prepare.outputs.version }}
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: actions/setup-dotnet@v6
with:
dotnet-version: '8.0.x'
- uses: actions/setup-node@v6
with:
node-version: '24'
cache: npm
cache-dependency-path: cmf-codereview/package-lock.json
- name: Test package validation
run: node --test scripts/package.test.mjs
- name: Read npm version and stamp the executable
id: prepare
run: node scripts/package.mjs prepare
- name: Restore, build and test
run: |
set -Eeuo pipefail
dotnet restore cmf-codereview.sln
dotnet build cmf-codereview.sln -c Release --no-restore
dotnet test cmf-codereview.sln -c Release --no-build
- name: Build Windows, Linux and Intel macOS bundles
run: |
set -Eeuo pipefail
npm ci --ignore-scripts --no-audit --no-fund
npm run build:bundle
- name: Pack and verify the archive
run: |
set -Eeuo pipefail
mkdir -p release
npm pack ./npm --pack-destination ./release --json > release/pack.json
node scripts/package.mjs manifest
# Only used to transfer the archive between jobs; not a ready-to-test package.
- uses: actions/upload-artifact@v7
with:
name: unvalidated-codereview-${{ steps.prepare.outputs.version }}
path: |
cmf-codereview/release/*.tgz
cmf-codereview/release/manifest.json
cmf-codereview/release/pack.json
compression-level: 0
if-no-files-found: error
retention-days: 1

smoke:
needs: package
runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, windows-2025, macos-15-intel]
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: actions/setup-node@v6
with:
node-version: '24'
package-manager-cache: false
- uses: actions/download-artifact@v8
with:
name: unvalidated-codereview-${{ needs.package.outputs.version }}
path: cmf-codereview/release
- name: Install the tgz, check the version and scan a known fixture
run: bash scripts/smoke-package.sh "$GITHUB_WORKSPACE/cmf-codereview/release" "${{ needs.package.outputs.version }}" "$GITHUB_SHA"

ready:
name: Package ready for manual testing
needs: [package, smoke]
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: actions/setup-node@v6
with:
node-version: '24'
package-manager-cache: false
- uses: actions/download-artifact@v8
with:
name: unvalidated-codereview-${{ needs.package.outputs.version }}
path: cmf-codereview/release
- name: Verify the validated archive before making it available
env:
PACKAGE_VERSION: ${{ needs.package.outputs.version }}
run: node scripts/package.mjs archive release "$PACKAGE_VERSION" "$GITHUB_SHA"
- name: Upload package for manual testing
uses: actions/upload-artifact@v7
with:
name: codereview-${{ needs.package.outputs.version }}
path: |
cmf-codereview/release/*.tgz
cmf-codereview/release/manifest.json
cmf-codereview/release/pack.json
compression-level: 0
if-no-files-found: error
retention-days: 30
- name: Record package readiness
env:
PACKAGE_VERSION: ${{ needs.package.outputs.version }}
run: |
printf 'Package codereview-%s is ready for manual testing.\n' "$PACKAGE_VERSION" >> "$GITHUB_STEP_SUMMARY"
printf 'Build, unit tests and Windows/Linux/Intel macOS install-and-scan checks passed.\n' >> "$GITHUB_STEP_SUMMARY"
printf 'Source commit: %s\n' "$GITHUB_SHA" >> "$GITHUB_STEP_SUMMARY"
printf 'Download the codereview artifact from this successful run. Testing in a consuming pipeline and publication are manual.\n' >> "$GITHUB_STEP_SUMMARY"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
*.snupkg
npm-debug.log*
.npmrc
**/release/
1 change: 0 additions & 1 deletion cmf-codereview/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ node_modules/
dist/
npm/dist/
npm/packs/
package-lock.json
npm/package-lock.json
4 changes: 4 additions & 0 deletions cmf-codereview/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,7 @@ baseline (`scan --update-baseline`) so CI gates only fail on new findings. See
```bash
dotnet test
```

## Packages for manual testing

The `Package-CodeReview` GitHub Actions workflow automatically builds and tests an all-platform package on pull requests and pushes to `main`. After the .NET tests and Windows/Linux/Intel macOS package checks pass, download the `codereview-<version>` artifact for manual testing. Set the next version in `npm/package.json`; the workflow reads it automatically for each run. See [the package guide](docs/Releases.md) for the workflow and download instructions. Integration testing and publication are manual.
43 changes: 43 additions & 0 deletions cmf-codereview/docs/Releases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Build a package for manual testing

The `Package-CodeReview` GitHub Actions workflow automatically builds and validates an npm package on every pull request targeting `main` and every push to `main`. It can also be rerun with **Actions > Package-CodeReview > Run workflow**, without any inputs.

## Choose the next version

Edit `version` in **`cmf-codereview/npm/package.json`** when preparing a release. Use an exact npm version without a `v` prefix, such as `2.4.7` or `7.0.0-rc.2`. The workflow supports stable and prerelease versions and has no fixed target version. The automation change itself does not bump the distributed package version; prepare the next release version separately after merging it.

This manifest is the workflow's source for the package version. The workflow reads it and sets the same version in `src/cmf-codereview.csproj` before building, so the executable and npm package agree. There is no workflow version input, automatic version bump, source commit, Git tag or GitHub release. The root `cmf-codereview/package.json` belongs to the build tooling and does not set the distributed plugin's version.

Multiple runs can build the same version while it is being tested. Each artifact belongs to its own workflow run; `manifest.json` records the exact source commit and SHA-512 integrity. Use those values to distinguish builds of the same version. For a PR run, the commit is the GitHub checkout commit, normally the PR test merge commit.

## What must pass

1. Package helper tests validate version handling, executable stamping, archive contents and integrity checks.
2. The .NET solution is restored, built in Release configuration and tested.
3. Self-contained Windows x64, Linux x64 and Intel macOS x64 executables are bundled into one npm `.tgz`.
4. The archive is checked for all three executables, and its version, source commit and SHA-512 integrity are saved in `manifest.json`.
5. Separate native jobs on Windows, Linux and Intel macOS install that exact archive, check the executable version and scan a small fixture containing an expected `LoadInsideLoop` finding.
6. Only after all those jobs pass does **Package ready for manual testing** verify the archive again and upload the final **`codereview-<version>`** artifact.

No approval, publishing environment, registry credential or release switch is needed. Normal NuGet restore and public npm dependency access must be available to the runners. The workflow does not publish to RepoFlow, change `next`/`latest`, or run a consuming project's integration pipeline.

## Download and test

1. Open the PR's **Package-CodeReview** check or select the run under **Actions > Package-CodeReview**.
2. Confirm the workflow completed successfully, including **Package ready for manual testing**. The separate `CI-Build` check should also pass before merging the PR.
3. Download **`codereview-<version>`** from the run's **Artifacts** section, where `<version>` is the value in `npm/package.json` for that run. Extract the downloaded ZIP to obtain the `.tgz`, `manifest.json` and `pack.json`.
4. Install the extracted `.tgz` in your manual test environment. For example, from a temporary npm project:

```bash
npm install /path/to/criticalmanufacturing-codereview-<version>.tgz
npx --no-install cmf-codereview --version
npx --no-install cmf-codereview scan --repository-root /path/to/customization --output findings.json
```

Replace `<version>` with the version in the downloaded archive's filename before running these commands.

5. Test the package in a consuming project's PR validation pipeline, including dependency restoration and inline PR comments. Use the same archive and keep the source commit/integrity with your test results.

The final artifact is kept for 30 days. An **`unvalidated-codereview-<version>`** artifact is used to transfer the archive between jobs and is kept for one day. It can exist even if a platform test fails; it is not ready for manual testing. If the workflow fails, fix the failure and use the final artifact from a successful run.

All integration testing, publication and npm tag changes are manual for now. The previously encountered RepoFlow upload limit must be handled as part of any manual publication; this workflow does not exercise or resolve it. Publish the exact tested archive and use a new version after a version has already been published.
6 changes: 3 additions & 3 deletions cmf-codereview/docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ metadata the CM Framework build/pack tooling reads:
sibling subfolders as Orchestration roots.
- Every manifest with `"packageType": "Data"` contributes a DEE root for each `contentToPack` entry
whose `"contentType": "DEE"`, resolved from that entry's own `source` glob (e.g. `"DEEs/*"` under
the manifest's directory) — so both the nested Micron-style `Cmf.<Project>.Data.Packages/DEEs` shape
the manifest's directory) — so both the nested `Cmf.<Project>.Data.Packages/DEEs` shape
and a flat `Cmf.<Project>.Data/DEEs` shape resolve correctly, and a repository with more than one
Data package (e.g. a Tests package bundling its own DEE fixtures) gets every one of them.

Expand Down Expand Up @@ -222,10 +222,10 @@ a separately configured consumer; no pipeline generation or scaffolding is perfo
## Reviewing Process Rules

Process Rule diagnostics run automatically as part of the DEEs/Both scope. No guideline file
or additional validation flag is required. To focus on the Micron deployment rules:
or additional validation flag is required. To focus on a customization project's deployment rules:

```powershell
cmf-codereview scan --repository-root C:\workspaces\Micron --roots Cmf.Custom.Data/Cmf.Custom.Data.Packages/DEEs/ProcessRules --fail-on High --output findings.json
cmf-codereview scan --repository-root C:\workspaces\Project --roots Cmf.Custom.Data/Cmf.Custom.Data.Packages/DEEs/ProcessRules --fail-on High --output findings.json
cmf-codereview report --findings-path findings.json --report-mode Detailed --report-format Html --report-path process-rules.html
```

Expand Down
7 changes: 4 additions & 3 deletions cmf-codereview/docs/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ Guards recognize `HasProperty`, `TryGetEntityTypeProperty`, `ObjectExists`, `Try
negation/comparisons, applicable branches, and early returns. Checks on another property or target
do not protect an operation. Reachable local functions are analyzed, including guards at their
call sites; dormant local functions and callbacks are excluded. Raw metadata changes recognize
`GenerateSchema` and `GenerateEntityTypeDBSchema` after the update. The normal
`IMicronEntityTypeService.UpdateEntityTypeProperties` route does not require a duplicate schema
call. A guarded removal followed by recreation supports deliberate attribute-definition repairs;
`GenerateSchema` and `GenerateEntityTypeDBSchema` after the update. The supported
`UpdateEntityTypeProperties` helper pattern is treated as schema-aware and does not require a
duplicate schema call; verify that the project's helper performs regeneration. A guarded removal
followed by recreation supports deliberate attribute-definition repairs;
the removal still needs value cleanup.

Schema context is read once per scan from the same Data package's versioned MasterData. It tracks
Expand Down
Loading
Loading