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
223 changes: 113 additions & 110 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,120 +1,123 @@
name: Build and Test

on:
push:
branches:
- main
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches:
- main
workflow_dispatch:

permissions:
contents: read
packages: read
actions: read

jobs:
build:
runs-on: windows-latest
timeout-minutes: 10

outputs:
VERSION: ${{ steps.get_version.outputs.VERSION }}

steps:
- name: Checkout repository
name: Build and Test

on:
push:
branches:
- main
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches:
- main
workflow_dispatch:

permissions:
contents: read
packages: read
actions: read

env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true

jobs:
build:
runs-on: windows-latest
timeout-minutes: 10

outputs:
VERSION: ${{ steps.get_version.outputs.VERSION }}

steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 1
- name: Setup .NET Core SDK
with:
fetch-depth: 1

- name: Setup .NET Core SDK
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5
with:
dotnet-version: '9.0.x'
- name: Set version
id: get_version
shell: pwsh
run: |
$TAG = if ($env:GITHUB_REF -like "refs/tags/v*") {
$env:GITHUB_REF -replace 'refs/tags/v', ''
} else {
""
}
if ($TAG -ne "") {
$VERSION = $TAG
} else {
# Fallback to commit hash if no tag
$COMMIT_HASH = git rev-parse --short HEAD
$VERSION = "0.0.1-$COMMIT_HASH"
}
echo "VERSION=$VERSION" >> $env:GITHUB_OUTPUT
- name: Generate SBOM for the project
with:
dotnet-version: '9.0.x'

- name: Set version
id: get_version
shell: pwsh
run: |
$TAG = if ($env:GITHUB_REF -like "refs/tags/v*") {
$env:GITHUB_REF -replace 'refs/tags/v', ''
} else {
""
}

if ($TAG -ne "") {
$VERSION = $TAG
} else {
# Fallback to commit hash if no tag
$COMMIT_HASH = git rev-parse --short HEAD
$VERSION = "0.0.1-$COMMIT_HASH"
}

echo "VERSION=$VERSION" >> $env:GITHUB_OUTPUT

- name: Generate SBOM for the project
uses: advanced-security/generate-sbom-action@67c5cda0176c46ce546d2fee672f72cee7fd620f # v1
id: gensbom
- name: Build AggregateConfigBuildTask solution in Release mode
run: dotnet build src/dirs.proj --configuration Release -warnaserror -p:Version=${{ steps.get_version.outputs.VERSION }}
- name: Run tests for AggregateConfigBuildTask solution
run: dotnet test src/dirs.proj --configuration Release -warnaserror -p:Version=${{ steps.get_version.outputs.VERSION }} -p:CollectCoverage=true --no-build
- name: Upload SBOM artifact
id: gensbom

- name: Build AggregateConfigBuildTask solution in Release mode
run: dotnet build src/dirs.proj --configuration Release -warnaserror -p:Version=${{ steps.get_version.outputs.VERSION }}

- name: Run tests for AggregateConfigBuildTask solution
run: dotnet test src/dirs.proj --configuration Release -warnaserror -p:Version=${{ steps.get_version.outputs.VERSION }} -p:CollectCoverage=true --no-build

- name: Upload SBOM artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: sbom
path: ${{ steps.gensbom.outputs.fileName }}
- name: Upload NuGetPackage artifact
with:
name: sbom
path: ${{ steps.gensbom.outputs.fileName }}

- name: Upload NuGetPackage artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: NuGetPackage
path: |
src/Task/bin/Release/AggregateConfigBuildTask.${{ steps.get_version.outputs.VERSION }}.nupkg
src/Task/bin/Release/AggregateConfigBuildTask.${{ steps.get_version.outputs.VERSION }}.snupkg
integration_tests:
needs: build
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 10
steps:
- name: Checkout repository
with:
name: NuGetPackage
path: |
src/Task/bin/Release/AggregateConfigBuildTask.${{ steps.get_version.outputs.VERSION }}.nupkg
src/Task/bin/Release/AggregateConfigBuildTask.${{ steps.get_version.outputs.VERSION }}.snupkg

integration_tests:
needs: build
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 10

steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 1
- name: Setup .NET Core SDK
with:
fetch-depth: 1

- name: Setup .NET Core SDK
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5
with:
dotnet-version: '9.0.x'
- name: Download NuGetPackage artifact
with:
dotnet-version: '9.0.x'

- name: Download NuGetPackage artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: NuGetPackage
path: ./nuget/local
- name: Add local NuGet source
run: dotnet nuget add source ${{ github.workspace }}/nuget/local --name AggregateConfigBuildTask
- name: Build IntegrationTests in Release mode
run: dotnet build test/dirs.proj --configuration Release -warnaserror -p:Version=${{ needs.build.outputs.VERSION }} -p:UseLocalPackageVersion=true
- name: Run IntegrationTests
run: dotnet test test/dirs.proj --configuration Release -warnaserror -p:Version=${{ needs.build.outputs.VERSION }} -p:CollectCoverage=true -p:UseLocalPackageVersion=true
- name: Upload integration results artifact
with:
name: NuGetPackage
path: ./nuget/local

- name: Add local NuGet source
run: dotnet nuget add source ${{ github.workspace }}/nuget/local --name AggregateConfigBuildTask

- name: Build IntegrationTests in Release mode
run: dotnet build test/dirs.proj --configuration Release -warnaserror -p:Version=${{ needs.build.outputs.VERSION }} -p:UseLocalPackageVersion=true

- name: Run IntegrationTests
run: dotnet test test/dirs.proj --configuration Release -warnaserror -p:Version=${{ needs.build.outputs.VERSION }} -p:CollectCoverage=true -p:UseLocalPackageVersion=true

- name: Upload integration results artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: IntegrationTestResults-${{ matrix.os }}
with:
name: IntegrationTestResults-${{ matrix.os }}
path: test/IntegrationTests/out/
Loading
Loading