Skip to content

Commit fef5aae

Browse files
authored
feat: cache build outputs (#2212)
1 parent 1a60596 commit fef5aae

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed

.github/workflows/build-dev.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ jobs:
4444
Directory.Packages.props
4545
**/*.csproj
4646
47+
- name: Restore bin/obj cache
48+
id: cache
49+
uses: actions/cache/restore@v3
50+
with:
51+
path: |
52+
**/bin
53+
**/obj
54+
key: ${{ hashFiles('**/*.csproj', 'Directory.Packages.props') }}
55+
4756
- name: Restore dependencies
4857
run: dotnet restore ProtoActor.sln
4958

@@ -53,6 +62,15 @@ jobs:
5362
ConnectionStrings__Redis: localhost:${{ job.services.redis.ports[6379] }},syncTimeout=10000
5463
run: |
5564
dotnet test ${{ matrix.test }} -c Release -f ${{ matrix.dotnet }} --logger GitHubActions
65+
66+
- name: Save bin/obj cache
67+
if: steps.cache.outputs.cache-hit != 'true'
68+
uses: actions/cache/save@v3
69+
with:
70+
path: |
71+
**/bin
72+
**/obj
73+
key: ${{ steps.cache.outputs.cache-primary-key }}
5674

5775
test-fast: # fast tests where setting up a parallel job run is more overhead than just running the tests side by side
5876
runs-on: ubuntu-latest
@@ -79,13 +97,31 @@ jobs:
7997
Directory.Packages.props
8098
**/*.csproj
8199
100+
- name: Restore bin/obj cache
101+
id: cache
102+
uses: actions/cache/restore@v3
103+
with:
104+
path: |
105+
**/bin
106+
**/obj
107+
key: ${{ hashFiles('**/*.csproj', 'Directory.Packages.props') }}
108+
82109
- name: Restore dependencies
83110
run: dotnet restore ProtoActor.sln
84111
- name: Run tests ${{ matrix.test }}
85112
timeout-minutes: 15
86113
run: |
87114
dotnet test ${{ matrix.test }} -c Release --logger GitHubActions
88115
116+
- name: Save bin/obj cache
117+
if: steps.cache.outputs.cache-hit != 'true'
118+
uses: actions/cache/save@v3
119+
with:
120+
path: |
121+
**/bin
122+
**/obj
123+
key: ${{ steps.cache.outputs.cache-primary-key }}
124+
89125
nuget:
90126
runs-on: ubuntu-latest
91127
needs: [test-slow, test-fast]
@@ -103,10 +139,28 @@ jobs:
103139
Directory.Packages.props
104140
**/*.csproj
105141
142+
- name: Restore bin/obj cache
143+
id: cache
144+
uses: actions/cache/restore@v3
145+
with:
146+
path: |
147+
**/bin
148+
**/obj
149+
key: ${{ hashFiles('**/*.csproj', 'Directory.Packages.props') }}
150+
106151
- name: Restore dependencies
107152
run: dotnet restore ProtoActor.sln
108153

109154
- name: Create and push NuGet package
110155
run: |
111156
dotnet pack ProtoActor.sln -c Release -o nuget -p:SymbolPackageFormat=snupkg -p:GenerateDocumentationFile=true -p:NoWarn=CS1591
112157
dotnet nuget push nuget/**/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
158+
159+
- name: Save bin/obj cache
160+
if: steps.cache.outputs.cache-hit != 'true'
161+
uses: actions/cache/save@v3
162+
with:
163+
path: |
164+
**/bin
165+
**/obj
166+
key: ${{ steps.cache.outputs.cache-primary-key }}

.github/workflows/pull-request.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,30 @@ jobs:
3434
Directory.Packages.props
3535
**/*.csproj
3636
37+
- name: Restore bin/obj cache
38+
id: cache
39+
uses: actions/cache/restore@v3
40+
with:
41+
path: |
42+
**/bin
43+
**/obj
44+
key: ${{ hashFiles('**/*.csproj', 'Directory.Packages.props') }}
45+
3746
- name: Restore dependencies
3847
run: dotnet restore ProtoActor.sln
3948

4049
- name: Build
4150
run: dotnet build ProtoActor.sln -c Release
4251

52+
- name: Save bin/obj cache
53+
if: steps.cache.outputs.cache-hit != 'true'
54+
uses: actions/cache/save@v3
55+
with:
56+
path: |
57+
**/bin
58+
**/obj
59+
key: ${{ steps.cache.outputs.cache-primary-key }}
60+
4361
test-slow: # slow tests that should run in parallel
4462
runs-on: ubuntu-latest
4563

@@ -73,6 +91,15 @@ jobs:
7391
Directory.Packages.props
7492
**/*.csproj
7593
94+
- name: Restore bin/obj cache
95+
id: cache
96+
uses: actions/cache/restore@v3
97+
with:
98+
path: |
99+
**/bin
100+
**/obj
101+
key: ${{ hashFiles('**/*.csproj', 'Directory.Packages.props') }}
102+
76103
- name: Restore dependencies
77104
run: dotnet restore ProtoActor.sln
78105

@@ -83,6 +110,15 @@ jobs:
83110
run: |
84111
dotnet test ${{ matrix.test }} -c Release -f ${{ matrix.dotnet }} --logger GitHubActions
85112
113+
- name: Save bin/obj cache
114+
if: steps.cache.outputs.cache-hit != 'true'
115+
uses: actions/cache/save@v3
116+
with:
117+
path: |
118+
**/bin
119+
**/obj
120+
key: ${{ steps.cache.outputs.cache-primary-key }}
121+
86122
test-fast: # fast tests where setting up a parallel job run is more overhead than just running the tests side by side
87123
runs-on: ubuntu-latest
88124

@@ -108,9 +144,27 @@ jobs:
108144
Directory.Packages.props
109145
**/*.csproj
110146
147+
- name: Restore bin/obj cache
148+
id: cache
149+
uses: actions/cache/restore@v3
150+
with:
151+
path: |
152+
**/bin
153+
**/obj
154+
key: ${{ hashFiles('**/*.csproj', 'Directory.Packages.props') }}
155+
111156
- name: Restore dependencies
112157
run: dotnet restore ProtoActor.sln
113158
- name: Run tests ${{ matrix.test }}
114159
timeout-minutes: 15
115160
run: |
116161
dotnet test ${{ matrix.test }} -c Release --logger GitHubActions
162+
163+
- name: Save bin/obj cache
164+
if: steps.cache.outputs.cache-hit != 'true'
165+
uses: actions/cache/save@v3
166+
with:
167+
path: |
168+
**/bin
169+
**/obj
170+
key: ${{ steps.cache.outputs.cache-primary-key }}

0 commit comments

Comments
 (0)