Skip to content

Commit 615cbb9

Browse files
authored
Add GitHub Actions workflow for Copilot environment setup and consolidate .NET setup across all workflows (#830)
1 parent 3fc1009 commit 615cbb9

File tree

4 files changed

+68
-39
lines changed

4 files changed

+68
-39
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: 'Setup .NET Environment'
2+
description: 'Set up .NET SDK, configure dependency caching, restore, and optionally build'
3+
inputs:
4+
build:
5+
description: 'Whether to run dotnet build after restore'
6+
required: false
7+
default: 'true'
8+
runs:
9+
using: 'composite'
10+
steps:
11+
- name: Setup dotnet SDK
12+
uses: actions/setup-dotnet@v5
13+
with:
14+
dotnet-version: |
15+
6.0.x
16+
7.0.x
17+
8.0.x
18+
19+
- name: Set up dependency caching for faster builds
20+
uses: actions/cache@v4
21+
id: nuget-cache
22+
with:
23+
path: |
24+
~/.nuget/packages
25+
${{ github.workspace }}/**/obj/project.assets.json
26+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
27+
restore-keys: |
28+
${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
29+
${{ runner.os }}-nuget-
30+
31+
- name: Restore dependencies
32+
shell: bash
33+
run: dotnet restore
34+
35+
- name: Build
36+
if: ${{ inputs.build == 'true' }}
37+
shell: bash
38+
run: dotnet build --no-restore

.github/workflows/Code-Analysis.yml

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,10 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v5
17-
- name: Setup dotnet SDK
18-
uses: actions/setup-dotnet@v5
17+
- name: Setup .NET environment
18+
uses: ./.github/actions/setup-dotnet
1919
with:
20-
global-json-file: global.json
21-
- name: Set up dependency caching for faster builds
22-
uses: actions/cache@v4
23-
id: nuget-cache
24-
with:
25-
path: |
26-
~/.nuget/packages
27-
${{ github.workspace }}/**/obj/project.assets.json
28-
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
29-
restore-keys: |
30-
${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
31-
${{ runner.os }}-nuget-
32-
# Run NuGet restore for the solution at repo root
33-
- name: Run NuGet restore
34-
run: dotnet restore
20+
build: 'false'
3521

3622
# Run code analysis for the solution at repo root
3723
- name: Run .NET Code Analysis

.github/workflows/build-and-test.yml

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,8 @@ jobs:
3030
os: [ubuntu-latest, windows-latest, macOS-latest]
3131
steps:
3232
- uses: actions/checkout@v5
33-
- name: Setup dotnet SDK
34-
uses: actions/setup-dotnet@v5
35-
with:
36-
dotnet-version: |
37-
6.0.x
38-
7.0.x
39-
8.0.x
40-
- name: Set up dependency caching for faster builds
41-
uses: actions/cache@v4
42-
id: nuget-cache
43-
with:
44-
path: |
45-
~/.nuget/packages
46-
${{ github.workspace }}/**/obj/project.assets.json
47-
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
48-
restore-keys: |
49-
${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
50-
${{ runner.os }}-nuget-
51-
- name: Restore dependencies
52-
run: dotnet restore
53-
- name: Build
54-
run: dotnet build --no-restore
33+
- name: Setup .NET environment
34+
uses: ./.github/actions/setup-dotnet
5535
- name: Test
5636
run: dotnet test --no-build --no-restore --verbosity normal --logger trx --results-directory ${{ runner.temp }}
5737

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Copilot Setup Steps
2+
3+
on:
4+
push:
5+
paths:
6+
- '.github/workflows/copilot-setup-steps.yml'
7+
pull_request:
8+
paths:
9+
- '.github/workflows/copilot-setup-steps.yml'
10+
workflow_dispatch:
11+
12+
jobs:
13+
copilot-setup-steps:
14+
name: copilot-setup-steps
15+
runs-on: ubuntu-latest
16+
17+
permissions:
18+
contents: read
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v5
23+
24+
- name: Setup .NET environment
25+
uses: ./.github/actions/setup-dotnet

0 commit comments

Comments
 (0)