-
Notifications
You must be signed in to change notification settings - Fork 0
184 lines (159 loc) · 5.09 KB
/
build_and_test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: Build, Test, Release
on:
workflow_dispatch:
push:
tags:
- '*'
branches:
- 'main'
- 'gh-actions*'
pull_request:
branches:
- '*'
env:
TIMEZONE: 'America/Chicago'
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
ArtifactDirectory: ${{ github.workspace}}/artifacts
defaults:
run:
shell: pwsh
jobs:
build_and_test:
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8
dotnet-quality: ga
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration:Release
- name: Test Core
if: ${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' }}
run: |
dotnet test 'tests\Ephemerally.Tests\' `
--no-build `
--configuration:Release `
--logger:trx `
--results-directory ${{ env.ArtifactDirectory }}
- name: Test Redis
if: ${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' }}
run: |
dotnet test 'tests\Ephemerally.Redis.Tests\' `
--no-build `
--configuration:Release `
--logger:trx `
--results-directory ${{ env.ArtifactDirectory }}
- name: Upload Test Results
if: ${{ always() && github.event_name == 'pull_request' || github.ref == 'refs/heads/main' }}
uses: actions/upload-artifact@v4
with:
name: test-results
path: ${{ env.ArtifactDirectory }}/**/*.trx
# Cosmos DB Emulator is broken on Ubuntu
# https://github.com/Azure/azure-cosmos-db-emulator-docker/issues/56
build_and_test_cosmos:
runs-on: windows-2022
permissions:
checks: write
pull-requests: write
# Reenable when Ubuntu is fixed
# services:
# cosmos:
# image: mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator
# ports:
# - 8081:8081
# - 10250-10255:10250-10255
# env:
# AZURE_COSMOS_EMULATOR_PARTITION_COUNT: 3
# AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE: true
steps:
- uses: actions/checkout@v2
# Remove when Ubuntu is fixed
- name: Start Cosmos DB Emulator
if: ${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' }}
uses: southpolesteve/cosmos-emulator-github-action@v1
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8
dotnet-quality: ga
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration:Release
# Reenable when Ubuntu is fixed
# - name: Wait for Cosmos Emulator
# uses: cygnetdigital/[email protected]
# with:
# url: 'https://localhost:8081/_explorer/index.html'
# responseCode: '200,500'
# timeout: 5000
# interval: 500
- name: Test Cosmos
if: ${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' }}
run: |
dotnet test 'tests\Ephemerally.Azure.Cosmos.Tests\' `
--no-build `
--configuration:Release `
--logger:trx `
--results-directory ${{ env.ArtifactDirectory }}
- name: Upload Test Results
if: ${{ always() && github.event_name == 'pull_request' || github.ref == 'refs/heads/main' }}
uses: actions/upload-artifact@v4
with:
name: cosmos-test-results
path: ${{ env.ArtifactDirectory }}/**/*.trx
test_results_comment:
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
needs:
- build_and_test
- build_and_test_cosmos
steps:
- name: Download Test Results
uses: actions/download-artifact@v4
with:
path: ${{ env.ArtifactDirectory }}
- name: Test Results Comment
if: always()
uses: im-open/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
timezone: ${{ env.TIMEZONE }}
create-status-check: false
create-pr-comment: true
comment-identifier: 'TestResults'
tag:
if: ${{ github.event_name != 'pull_request' }}
uses: ./.github/workflows/tag.yml
test-tag-output:
runs-on: ubuntu-latest
needs:
- tag
steps:
- name: Echo tag output
run: |
echo version: "${{ needs.tag.outputs.version }}"
echo prerelease-depth: "${{ fromJSON(needs.tag.outputs.prerelease-depth) }}"
echo is-prerelease: "${{ fromJSON(needs.tag.outputs.is-prerelease) }}"
release:
needs:
- tag
- build_and_test
- build_and_test_cosmos
if: ${{ github.ref_type == 'tag' || github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && fromJSON(needs.tag.outputs.prerelease-depth) < 2 }}
uses: ./.github/workflows/release.yml
with:
version: ${{ needs.tag.outputs.version }}
is-prerelease: ${{ fromJSON(needs.tag.outputs.is-prerelease) }}
secrets: inherit