diff --git a/.github/actions/setup-dotnet/action.yml b/.github/actions/setup-dotnet/action.yml new file mode 100644 index 00000000..01a84e32 --- /dev/null +++ b/.github/actions/setup-dotnet/action.yml @@ -0,0 +1,38 @@ +name: 'Setup .NET Environment' +description: 'Set up .NET SDK, configure dependency caching, restore, and optionally build' +inputs: + build: + description: 'Whether to run dotnet build after restore' + required: false + default: 'true' +runs: + using: 'composite' + steps: + - name: Setup dotnet SDK + uses: actions/setup-dotnet@v5 + with: + dotnet-version: | + 6.0.x + 7.0.x + 8.0.x + + - name: Set up dependency caching for faster builds + uses: actions/cache@v4 + id: nuget-cache + with: + path: | + ~/.nuget/packages + ${{ github.workspace }}/**/obj/project.assets.json + key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} + restore-keys: | + ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} + ${{ runner.os }}-nuget- + + - name: Restore dependencies + shell: bash + run: dotnet restore + + - name: Build + if: ${{ inputs.build == 'true' }} + shell: bash + run: dotnet build --no-restore \ No newline at end of file diff --git a/.github/workflows/Code-Analysis.yml b/.github/workflows/Code-Analysis.yml index 305672f0..a5560e8e 100644 --- a/.github/workflows/Code-Analysis.yml +++ b/.github/workflows/Code-Analysis.yml @@ -14,24 +14,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - - name: Setup dotnet SDK - uses: actions/setup-dotnet@v5 + - name: Setup .NET environment + uses: ./.github/actions/setup-dotnet with: - global-json-file: global.json - - name: Set up dependency caching for faster builds - uses: actions/cache@v4 - id: nuget-cache - with: - path: | - ~/.nuget/packages - ${{ github.workspace }}/**/obj/project.assets.json - key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} - restore-keys: | - ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} - ${{ runner.os }}-nuget- - # Run NuGet restore for the solution at repo root - - name: Run NuGet restore - run: dotnet restore + build: 'false' # Run code analysis for the solution at repo root - name: Run .NET Code Analysis diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 9cd5b7d5..aae9293e 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -30,28 +30,8 @@ jobs: os: [ubuntu-latest, windows-latest, macOS-latest] steps: - uses: actions/checkout@v5 - - name: Setup dotnet SDK - uses: actions/setup-dotnet@v5 - with: - dotnet-version: | - 6.0.x - 7.0.x - 8.0.x - - name: Set up dependency caching for faster builds - uses: actions/cache@v4 - id: nuget-cache - with: - path: | - ~/.nuget/packages - ${{ github.workspace }}/**/obj/project.assets.json - key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} - restore-keys: | - ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} - ${{ runner.os }}-nuget- - - name: Restore dependencies - run: dotnet restore - - name: Build - run: dotnet build --no-restore + - name: Setup .NET environment + uses: ./.github/actions/setup-dotnet - name: Test run: dotnet test --no-build --no-restore --verbosity normal --logger trx --results-directory ${{ runner.temp }} diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml new file mode 100644 index 00000000..8775f1c6 --- /dev/null +++ b/.github/workflows/copilot-setup-steps.yml @@ -0,0 +1,25 @@ +name: Copilot Setup Steps + +on: + push: + paths: + - '.github/workflows/copilot-setup-steps.yml' + pull_request: + paths: + - '.github/workflows/copilot-setup-steps.yml' + workflow_dispatch: + +jobs: + copilot-setup-steps: + name: copilot-setup-steps + runs-on: ubuntu-latest + + permissions: + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@v5 + + - name: Setup .NET environment + uses: ./.github/actions/setup-dotnet \ No newline at end of file