-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add GitHub Actions CI/CD workflows and local test runner #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ab1b312
feat: add GitHub Actions CI/CD workflows and local test runner
gragra33 812ccc9
fix: address Copilot PR review feedback
gragra33 7ec0794
fix: prevent parallel test interference on SpanPropertyAccessor cache…
gragra33 23170af
fix: disable parallelization on SpanPropertyAccessorCache collection …
gragra33 9bd1c7d
Merge pull request #6 from gragra33/feature/github-actions
gragra33 01a1c62
fix: address Copilot PR #7 review feedback
gragra33 2c9a13a
Merge pull request #9 from gragra33/hotfix/copilot-pr7-fixes
gragra33 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - develop | ||
| - "feature/**" | ||
| - "fix/**" | ||
| - "hotfix/**" | ||
| pull_request: | ||
| branches: | ||
| - develop | ||
| - master | ||
|
|
||
| # Declared here so actionlint can validate env.RUNNING_LOCALLY references below. | ||
| # ci-cd-test-run.ps1 passes --env RUNNING_LOCALLY=true to act; on real GitHub Actions | ||
| # the variable is empty so upload-artifact runs and failures are fatal. | ||
| env: | ||
| RUNNING_LOCALLY: "" | ||
|
|
||
| jobs: | ||
| validate-branch: | ||
| name: Validate Branch Name | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'pull_request' | ||
| steps: | ||
| - name: Check branch naming convention | ||
| env: | ||
| BRANCH: ${{ github.head_ref }} | ||
| run: | | ||
| if [[ ! "$BRANCH" =~ ^(feature|fix|hotfix)/.+ ]] && [[ "$BRANCH" != "develop" ]]; then | ||
| echo "::error::Branch '$BRANCH' does not follow naming conventions." | ||
| echo "::error::PR source branches must be 'develop' or prefixed with 'feature/', 'fix/', or 'hotfix/'." | ||
| exit 1 | ||
| fi | ||
| echo "Branch '$BRANCH' follows naming conventions." | ||
|
|
||
| build-and-test: | ||
| name: Build & Test | ||
| needs: validate-branch | ||
| # Run on push events (validate-branch skipped) OR on valid PRs (validate-branch succeeded) | ||
| if: always() && (needs.validate-branch.result == 'success' || needs.validate-branch.result == 'skipped') | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
|
|
||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v5 | ||
| with: | ||
| dotnet-version: | | ||
| 10.0.x | ||
|
|
||
| - name: Restore | ||
| run: dotnet restore Blazing.Json.Queryable.slnx | ||
|
|
||
| - name: Build | ||
| run: dotnet build Blazing.Json.Queryable.slnx --no-restore --configuration Release -p:GeneratePackageOnBuild=false | ||
|
|
||
| - name: Test | ||
| run: | | ||
| dotnet test tests/Blazing.Json.Queryable.Tests/Blazing.Json.Queryable.Tests.csproj \ | ||
| --no-build --no-restore \ | ||
| --configuration Release \ | ||
| --logger "trx;LogFileName=test-results.trx" | ||
|
|
||
| - name: Upload test results | ||
| uses: actions/upload-artifact@v7 | ||
| # Skipped when running locally (ci-cd-test-run.ps1 passes --env RUNNING_LOCALLY=true to act). | ||
| # On real GitHub Actions RUNNING_LOCALLY is empty → step runs; upload failures are fatal. | ||
| if: always() && env.RUNNING_LOCALLY == '' | ||
| with: | ||
| name: test-results | ||
| path: "**/*.trx" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| release: | ||
| name: Build, Test & Publish to NuGet | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v5 | ||
| with: | ||
| dotnet-version: | | ||
| 10.0.x | ||
|
|
||
| - name: Restore | ||
| run: dotnet restore Blazing.Json.Queryable.slnx | ||
|
|
||
| - name: Build | ||
| run: dotnet build Blazing.Json.Queryable.slnx --no-restore --configuration Release -p:GeneratePackageOnBuild=false | ||
|
|
||
| - name: Test | ||
| run: | | ||
| dotnet test tests/Blazing.Json.Queryable.Tests/Blazing.Json.Queryable.Tests.csproj \ | ||
| --no-build --no-restore \ | ||
| --configuration Release | ||
|
|
||
| - name: Extract version from project file | ||
| id: version | ||
| run: | | ||
| VERSION=$(grep -m1 '<Version>' src/Blazing.Json.Queryable/Blazing.Json.Queryable.csproj \ | ||
| | sed 's/.*<Version>//;s/<\/Version>.*//' \ | ||
| | tr -d '[:space:]') | ||
| echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
| echo "tag=v$VERSION" >> $GITHUB_OUTPUT | ||
| echo "Resolved version: $VERSION" | ||
|
|
||
| - name: Check if this version was already released | ||
| id: tag_check | ||
| run: | | ||
| if git ls-remote --tags origin "refs/tags/v${{ steps.version.outputs.version }}" | grep -q .; then | ||
| echo "exists=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "exists=false" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
|
gragra33 marked this conversation as resolved.
|
||
| - name: Fail if this version was already released | ||
| if: steps.tag_check.outputs.exists == 'true' | ||
| run: | | ||
| echo "::error::Release tag ${{ steps.version.outputs.tag }} already exists. Bump the project version before pushing to master." | ||
| exit 1 | ||
|
|
||
| - name: Pack NuGet package | ||
| if: steps.tag_check.outputs.exists == 'false' | ||
| run: | | ||
| dotnet pack src/Blazing.Json.Queryable/Blazing.Json.Queryable.csproj \ | ||
| --no-build --no-restore --configuration Release --output ./artifacts | ||
|
|
||
| - name: Create GitHub Release | ||
| if: steps.tag_check.outputs.exists == 'false' | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| gh release create "${{ steps.version.outputs.tag }}" \ | ||
| --title "Release ${{ steps.version.outputs.tag }}" \ | ||
| --generate-notes \ | ||
| ./artifacts/Blazing.Json.Queryable.${{ steps.version.outputs.version }}.nupkg \ | ||
| ./artifacts/Blazing.Json.Queryable.${{ steps.version.outputs.version }}.snupkg | ||
|
|
||
| - name: Push Blazing.Json.Queryable to NuGet.org | ||
| if: steps.tag_check.outputs.exists == 'false' | ||
| run: | | ||
| dotnet nuget push \ | ||
| "./artifacts/Blazing.Json.Queryable.${{ steps.version.outputs.version }}.nupkg" \ | ||
| --api-key ${{ secrets.NUGET_API_KEY }} \ | ||
| --source https://api.nuget.org/v3/index.json \ | ||
| --skip-duplicate | ||
|
|
||
| - name: Push Blazing.Json.Queryable symbols to NuGet.org | ||
| if: steps.tag_check.outputs.exists == 'false' | ||
| run: | | ||
| dotnet nuget push \ | ||
| "./artifacts/Blazing.Json.Queryable.${{ steps.version.outputs.version }}.snupkg" \ | ||
| --api-key ${{ secrets.NUGET_API_KEY }} \ | ||
| --source https://api.nuget.org/v3/index.json \ | ||
| --skip-duplicate | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.