diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 6cd210e5a..8918de61b 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -24,6 +24,7 @@ jobs:
runs-on: ubuntu-latest
steps:
+ - uses: extractions/setup-just@v2
- uses: actions/checkout@master
- name: Setup .NET
@@ -47,46 +48,11 @@ jobs:
- uses: stripe/openapi/actions/stripe-mock@master
- name: Run test suite
- run: make ci-test
-
- - name: Collect coverage
- run: dotnet test --no-build -c Release -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 }}
+ run: just ci-test
- name: Pack
run: dotnet pack src/Stripe.net -c Release --no-build --output nuget
- - name: 'Upload Artifact'
+ - name: "Upload Artifact"
uses: actions/upload-artifact@v4
with:
name: nuget
@@ -97,13 +63,13 @@ jobs:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@master
- - name: Setup .NET
- uses: actions/setup-dotnet@v1
- with:
- dotnet-version: 8.0.x
- - name: Run backcompat check
- run: dotnet pack src/Stripe.net -p:RunBaselineCheck=true
+ - uses: actions/checkout@master
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: 8.0.x
+ - name: Run backcompat check
+ run: dotnet pack src/Stripe.net -p:RunBaselineCheck=true
publish:
name: Publish
@@ -111,18 +77,18 @@ jobs:
needs: [build]
runs-on: ubuntu-latest
steps:
- - name: Download all workflow run artifacts
- uses: actions/download-artifact@v4
- with:
- name: nuget
- path: nuget
- - name: Setup .NET
- uses: actions/setup-dotnet@v1
- with:
- dotnet-version: 8.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 }}
+ - name: Download all workflow run artifacts
+ uses: actions/download-artifact@v4
+ with:
+ name: nuget
+ path: nuget
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: 8.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 }}
diff --git a/Makefile b/Makefile
index 9a135b112..200011fc3 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,5 @@
+# NOTE: this file is deprecated and slated for deletion; prefer using the equivalent `just` commands.
+
.PHONY: update-version codegen-format test ci-test
update-version:
@echo "$(VERSION)" > VERSION
diff --git a/README.md b/README.md
index 83a1df9b5..31eb1aaf2 100644
--- a/README.md
+++ b/README.md
@@ -30,10 +30,10 @@ From within Visual Studio:
1. Open the Solution Explorer.
2. Right-click on a project within your solution.
-3. Click on *Manage NuGet Packages...*
-4. Click on the *Browse* tab and search for "Stripe.net".
+3. Click on _Manage NuGet Packages..._
+4. Click on the _Browse_ tab and search for "Stripe.net".
5. Click on the Stripe.net package, select the appropriate version in the
- right-tab and click *Install*.
+ right-tab and click _Install_.
## Documentation
@@ -49,7 +49,7 @@ Stripe authenticates API requests using your account’s secret key, which you c
Use `StripeConfiguration.ApiKey` property to set the secret key.
-``` C#
+```C#
StripeConfiguration.ApiKey = "sk_test_...";
```
@@ -57,7 +57,7 @@ StripeConfiguration.ApiKey = "sk_test_...";
The `Create` method of the service class can be used to create a new resource:
-``` C#
+```C#
var options = new CustomerCreateOptions
{
Email = "customer@example.com"
@@ -74,7 +74,7 @@ Console.WriteLine(customer.Email);
The `Retrieve` method of the service class can be used to retrieve a resource:
-``` C#
+```C#
var service = new CustomerService();
Customer customer = service.Get("cus_1234");
@@ -320,10 +320,13 @@ go install github.com/stripe/stripe-mock@latest
stripe-mock
```
+Lastly, we use [just](https://github.com/casey/just) for running common development tasks. You can also read the `justfile` and run those commands directly.
+
Run all tests from the `src/StripeTests` directory:
```sh
-dotnet test src
+just test
+# or: dotnet test src
```
Run some tests, filtering by name:
@@ -343,7 +346,8 @@ must be formatted before PRs are submitted, otherwise CI will fail. Run the
formatter with:
```sh
-dotnet format src/Stripe.net.sln
+just format
+# or: dotnet format src/Stripe.net.sln
```
For any requests, bug or comments, please [open an issue][issues] or [submit a
diff --git a/justfile b/justfile
new file mode 100644
index 000000000..87c26cf39
--- /dev/null
+++ b/justfile
@@ -0,0 +1,37 @@
+set quiet
+
+import? '../sdk-codegen/justfile'
+
+_default:
+ just --list --unsorted
+
+# base test command that other, more specific commands use
+[no-quiet]
+[no-exit-message]
+_test no_build framework config:
+ dotnet test {{no_build}} {{framework}} src/StripeTests/StripeTests.csproj -c {{config}}
+
+# ⭐ run tests in debug mode
+test: (_test "" "-f net8.0" "Debug")
+
+# skip build and don't specify the dotnet framework
+ci-test: (_test "--no-build" "" "Release")
+
+# ⭐ format all files
+format *args:
+ # This sets TargetFramework because of a race condition in dotnet format when it tries to format to multiple targets at a time, which could lead to code with compiler errors after it completes
+ TargetFramework=net5.0 dotnet format src/Stripe.net/Stripe.net.csproj --severity warn {{args}}
+
+# for backwards compatibility; ideally removed later
+[private]
+alias codegen-format := format
+
+# verify, but don't modify, the project's formatting
+format-check: (format "--verify-no-changes")
+
+# called by tooling
+[private]
+update-version version:
+ echo "{{ version }}" > VERSION
+ perl -pi -e 's|[.\-\d\w]+|{{ version }}|' src/Stripe.net/Stripe.net.csproj
+ perl -pi -e 's|Current = "[.\-\d\w]+";|Current = "{{ version }}";|' src/Stripe.net/Constants/Version.cs