-
Notifications
You must be signed in to change notification settings - Fork 21
178 lines (154 loc) · 6.84 KB
/
Copy pathmain.yaml
File metadata and controls
178 lines (154 loc) · 6.84 KB
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
name: Build PostHog .NET SDK
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
PackageDirectory: ${{ github.workspace }}/build/packages/Release
DOTNET_VERSION: 9.0.102
permissions:
checks: write
contents: read
jobs:
detect-markdown-only:
uses: PostHog/.github/.github/workflows/detect-markdown-only.yml@ec25337d9fae0100622cbfea1bd5bd88284ac10b
permissions:
pull-requests: read
build:
needs: detect-markdown-only
name: Build and package
runs-on: ubuntu-latest
steps:
- name: Complete markdown-only PR check
if: needs.detect-markdown-only.outputs.markdown_only == 'true'
run: echo "Only Markdown files changed; no additional work is required for this check."
- name: Checkout main branch
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup .NET Core
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore NuGet Packages
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
run: dotnet restore --locked-mode
shell: bash
# This builds the solution, creates NuGet packages, and runs PublicApiAnalyzers.
# If a public API change is intentional, run `dotnet build --configuration Release`
# locally and commit the relevant PublicAPI.Shipped.txt/PublicAPI.Unshipped.txt updates.
- name: Build
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
run: dotnet build --configuration Release --no-restore --nologo
shell: bash
package:
needs: detect-markdown-only
name: Package (${{ matrix.name }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: PostHog
project: src/PostHog/PostHog.csproj
- name: PostHog.AI
project: src/PostHog.AI/PostHog.AI.csproj
- name: PostHog.AspNetCore
project: src/PostHog.AspNetCore/PostHog.AspNetCore.csproj
steps:
- name: Complete markdown-only PR check
if: needs.detect-markdown-only.outputs.markdown_only == 'true'
run: echo "Only Markdown files changed; no additional work is required for this check."
- name: Checkout main branch
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup .NET Core
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore NuGet Packages
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
run: dotnet restore --locked-mode
shell: bash
- name: Pack ${{ matrix.name }}
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
run: dotnet pack "${{ matrix.project }}" --configuration Release --no-restore --nologo --output "${{ env.PackageDirectory }}" /p:GeneratePackageOnBuild=false
shell: bash
test:
needs: detect-markdown-only
name: Test
runs-on: ubuntu-latest
# Run tests independently so build, test, and format feedback can complete in parallel.
steps:
- name: Complete markdown-only PR check
if: needs.detect-markdown-only.outputs.markdown_only == 'true'
run: echo "Only Markdown files changed; no additional work is required for this check."
- name: Checkout main branch
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup .NET Core
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore NuGet Packages
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
run: dotnet restore --locked-mode
shell: bash
- name: Run Tests
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
run: dotnet test --logger "trx;LogFileName=test-results.trx" --configuration Release --no-restore --nologo
shell: bash
- name: Collect Test Results
if: ${{ needs.detect-markdown-only.outputs.markdown_only != 'true' && (github.actor != 'dependabot[bot]' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)) }}
uses: dorny/test-reporter@a53e41438c2381e621dc719a47a57180e30c7075 # v1
with:
name: "xUnit Tests"
path: "tests/*/TestResults/test-results.trx"
reporter: 'dotnet-trx'
- name: Upload Test Snapshots
if: ${{ needs.detect-markdown-only.outputs.markdown_only != 'true' && (failure()) }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: verify-test-results
retention-days: 7
path: |
**/*.received.*
format:
needs: detect-markdown-only
name: Format
runs-on: ubuntu-latest
steps:
- name: Complete markdown-only PR check
if: needs.detect-markdown-only.outputs.markdown_only == 'true'
run: echo "Only Markdown files changed; no additional work is required for this check."
- name: Checkout main branch
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup .NET
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore NuGet Packages
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
run: dotnet restore --locked-mode
shell: bash
- name: Set up dotnet-format problem matcher
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
run: echo "::add-matcher::$GITHUB_WORKSPACE/.github/problemMatchers/dotnet-format.json"
shell: bash
- name: Format!
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
run: bin/fmt --check
shell: bash