From cfc0f39bc5a9f9aa2e1c16ea2feba0f801d2b569 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 30 Sep 2026 04:41:27 +0000 Subject: [PATCH] Add CI workflow, guard release tags, fix camera connection note - CI workflow: build and unit tests on every pull request and push to main - Release workflow refuses to run when the tag is not the latest commit of main - CLAUDE.md: the camera no longer needs to be connected before startup (hot plug) - CHANGELOG: new Unreleased section Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01FRZmo7wsZGgxrgkKqib1At --- .github/workflows/build.yml | 13 +++++++++++ .github/workflows/ci.yml | 43 +++++++++++++++++++++++++++++++++++++ CHANGELOG.md | 12 ++++++++++- CLAUDE.md | 2 +- README.md | 4 +++- 5 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8a6f556..4974ad6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,6 +19,19 @@ jobs: ref: main fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} + + # The release is built from main (the workflow commits the version and AutoUpdater XML to it). + # Refuse to release if main is not the tagged commit, so the package always matches the tag. + - name: Check that the tag points to main + run: | + $mainSha = git rev-parse HEAD + $tagSha = "${{ github.sha }}" + if ($mainSha -ne $tagSha) { + Write-Error "Tag ${{ github.ref_name }} points to $tagSha but main is at $mainSha. Tag the latest commit of main." + exit 1 + } + echo "Tag ${{ github.ref_name }} matches main ($mainSha)" + shell: powershell - name: Setup .NET uses: actions/setup-dotnet@v4 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..12f41a3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,43 @@ +name: CI + +on: + pull_request: + push: + branches: + - main + +permissions: + contents: read + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-and-test: + runs-on: windows-latest + + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.x' + + - name: Restore dependencies + run: dotnet restore CanonSDK.sln + + - name: Build solution + run: dotnet build CanonSDK.sln --configuration Release --no-restore + + - name: Run unit tests + run: dotnet test Canon.Core.Tests/Canon.Core.Tests.csproj --configuration Release --no-build --logger trx --results-directory TestResults + + - name: Upload test results + if: always() + uses: actions/upload-artifact@v4 + with: + name: test-results + path: TestResults diff --git a/CHANGELOG.md b/CHANGELOG.md index c1dd3d1..f454262 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ All notable changes to CanonWebAPI are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versions match the Git tags (`v1.0.0.11`) that trigger the release workflow. +## [Unreleased] + +### Changed +- The release workflow refuses to run when the tag does not point to the latest commit of `main`, + so the published package always matches the tag. + +### Added +- CI workflow building the solution and running the unit tests on every pull request and push to `main`. + ## [1.1.0.0] - Unreleased ### Changed @@ -136,7 +145,8 @@ First release. - Automatic updates with AutoUpdater.NET, from GitHub releases. - CI/CD workflow building the release package. -[1.1.0.0]: https://github.com/dansleboby/CanonWebAPI/compare/v1.0.0.11...HEAD +[Unreleased]: https://github.com/dansleboby/CanonWebAPI/compare/v1.1.0.0...HEAD +[1.1.0.0]: https://github.com/dansleboby/CanonWebAPI/compare/v1.0.0.11...v1.1.0.0 [1.0.0.11]: https://github.com/dansleboby/CanonWebAPI/compare/v1.0.0.10...v1.0.0.11 [1.0.0.10]: https://github.com/dansleboby/CanonWebAPI/compare/v1.0.0.9...v1.0.0.10 [1.0.0.9]: https://github.com/dansleboby/CanonWebAPI/compare/v1.0.0.8...v1.0.0.9 diff --git a/CLAUDE.md b/CLAUDE.md index 2aa9b58..9a30437 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -83,7 +83,7 @@ Errors are problem details: 400 invalid value, 409 capture refused, 503 not conn ## Important Notes -- Camera must be connected via USB before starting the application +- The camera can be connected via USB before or after the application starts (automatic connection and reconnection) - Canon EOS Utility must NOT be running (conflicts with EDSDK access) - Requires compatible Canon camera with EDSDK support - All projects target .NET 9 with Windows-specific dependencies diff --git a/README.md b/README.md index 3eb09ac..5179cce 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,7 @@ dotnet run --project Canon.API This project uses automated GitHub Actions for releases: 1. **Changelog**: Move the changes of the `Unreleased` section of [CHANGELOG.md](CHANGELOG.md) under the new version and date, and update the version in `Canon.API/Canon.API.csproj` -2. **Tag-based releases**: Push a tag like `v1.1.0.0` on `main` to trigger automated build and release +2. **Tag-based releases**: Push a tag like `v1.1.0.0` on the latest commit of `main` to trigger automated build and release (the workflow refuses a tag on another commit) 3. **Version synchronization**: The workflow automatically updates project versions to match the tag 4. **Unit tests**: The workflow runs `Canon.Core.Tests` before packaging 5. **Automatic packaging**: Creates release packages and updates the AutoUpdater XML @@ -170,6 +170,8 @@ dotnet run --project Canon.API dotnet test Canon.Core.Tests ``` +The `CI` GitHub Actions workflow builds the solution and runs these tests on every pull request and push to `main`. + The tests cover the value tables, the capture timeout, the file type filter, the SDK thread and the live view broadcaster. They do not need a camera and also run on Linux/macOS. ### Docker (Windows containers)