-
Notifications
You must be signed in to change notification settings - Fork 571
120 lines (103 loc) · 3.48 KB
/
ci.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
name: CI
on:
workflow_dispatch: {}
push:
branches:
- master
- beta
- sdk-release/**
- feature/**
tags:
- v[0-9]+.[0-9]+.[0-9]+*
pull_request:
branches:
- master
- beta
- sdk-release/**
- feature/**
jobs:
build:
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
2.1.x
3.1.x
5.0.x
6.0.x
7.0.x
- name: Install tools
run: |
dotnet tool restore
- name: Build Release
run: dotnet build src -c Release /p:ContinuousIntegrationBuild=true
- name: Build Debug
run: dotnet build src -c Debug
- uses: stripe/openapi/actions/stripe-mock@master
- name: Run test suite
run: dotnet test --no-build src/StripeTests/StripeTests.csproj -c Release
- name: Run test suite (Debug)
run: make ci-test
- name: Collect coverage
run: dotnet test --no-build -c Debug -f netcoreapp3.1 src/StripeTests/StripeTests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:ExcludeByAttribute=CompilerGenerated
- name: Get branch name (merge)
if: github.event_name != 'pull_request'
run: echo "commitBranch=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
- name: Get branch name (pull request)
if: github.event_name == 'pull_request'
run: echo "commitBranch=$(echo ${GITHUB_HEAD_REF} | tr / -)" >> $GITHUB_ENV
- name: Send code coverage report to coveralls.io
if: env.COVERALLS_REPO_TOKEN
run: |
export ARGS="--opencover \
-i src/StripeTests/coverage.netcoreapp3.1.opencover.xml \
--repoToken $COVERALLS_REPO_TOKEN \
--useRelativePaths \
--commitId $commitId \
--commitBranch $commitBranch \
--commitAuthor $commitAuthor \
--jobId $jobId"
if [ ! -z "${pullRequestId}" ];
then
export ARGS="$ARGS \
--pullRequest $pullRequestId"
fi
dotnet tool run csmacnz.Coveralls $ARGS
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
commitId: ${{ github.sha }}
commitAuthor: ${{ github.actor }}
jobId: ${{ github.run_id }}
pullRequestId: ${{ github.event.pull_request.number }}
- name: Pack
run: dotnet pack src/Stripe.net -c Release --no-build --output nuget
- name: 'Upload Artifact'
uses: actions/upload-artifact@v2
with:
name: nuget
path: nuget/
publish:
name: Publish
if: (((github.event_name == 'push') || (github.event_name == 'workflow_dispatch')) && startsWith(github.ref, 'refs/tags/v') && endsWith(github.actor, '-stripe'))
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Download all workflow run artifacts
uses: actions/download-artifact@v2
with:
name: nuget
path: nuget
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Publish NuGet packages to NuGet
run: dotnet nuget push nuget/*.nupkg --api-key ${{ secrets.NUGET_KEY }} --source "nuget.org"
- uses: stripe/openapi/actions/notify-release@master
if: always()
with:
bot_token: ${{ secrets.SLACK_BOT_TOKEN }}