mirror of
https://github.com/Smaug123/WoofWare.Expect
synced 2025-10-07 05:28:40 +00:00
Publish to NuGet (#5)
This commit is contained in:
64
.github/workflows/dotnet.yaml
vendored
64
.github/workflows/dotnet.yaml
vendored
@@ -194,3 +194,67 @@ jobs:
|
||||
- uses: G-Research/common-actions/check-required-lite@2b7dc49cb14f3344fbe6019c14a31165e258c059
|
||||
with:
|
||||
needs-context: ${{ toJSON(needs) }}
|
||||
|
||||
github-release:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ !github.event.repository.fork && github.ref == 'refs/heads/main' }}
|
||||
needs: [all-required-checks-complete]
|
||||
environment: main-deploy
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Download NuGet artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: nuget-package
|
||||
- name: Compute package path
|
||||
id: compute-path
|
||||
run: |
|
||||
find . -maxdepth 1 -type f -name 'WoofWare.Expect.*.nupkg' -exec sh -c 'echo "output=$(basename "$1")" >> $GITHUB_OUTPUT' shell {} \;
|
||||
- name: Compute tag name
|
||||
id: compute-tag
|
||||
env:
|
||||
NUPKG_PATH: ${{ steps.compute-path.outputs.output }}
|
||||
run: echo "output=$(basename "$NUPKG_PATH" .nupkg)" >> $GITHUB_OUTPUT
|
||||
- name: Tag and release
|
||||
uses: G-Research/common-actions/github-release@19d7281a0f9f83e13c78f99a610dbc80fc59ba3b
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
target-commitish: ${{ github.sha }}
|
||||
tag: ${{ steps.compute-tag.outputs.output }}
|
||||
binary-contents: ${{ steps.compute-path.outputs.output }}
|
||||
|
||||
nuget-publish:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ !github.event.repository.fork && github.ref == 'refs/heads/main' }}
|
||||
needs: [all-required-checks-complete]
|
||||
environment: main-deploy
|
||||
permissions:
|
||||
id-token: write
|
||||
attestations: write
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@v31
|
||||
with:
|
||||
extra_nix_config: |
|
||||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Download NuGet artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: nuget-package
|
||||
path: packed
|
||||
- name: Identify `dotnet`
|
||||
id: dotnet-identify
|
||||
run: nix develop --command bash -c 'echo "dotnet=$(which dotnet)" >> $GITHUB_OUTPUT'
|
||||
- name: Publish to NuGet
|
||||
id: publish-success
|
||||
uses: G-Research/common-actions/publish-nuget@2b7dc49cb14f3344fbe6019c14a31165e258c059
|
||||
with:
|
||||
package-name: WoofWare.Expect
|
||||
nuget-key: ${{ secrets.NUGET_API_KEY }}
|
||||
nupkg-dir: packed/
|
||||
dotnet: ${{ steps.dotnet-identify.outputs.dotnet }}
|
||||
|
||||
|
33
README.md
33
README.md
@@ -36,6 +36,39 @@ let ``This test fails: plain text comparison of ToString`` () =
|
||||
}
|
||||
```
|
||||
|
||||
If a snapshot is failing, add a `'` to the `expect` builder and rerun.
|
||||
The rerun will throw, but it will update the snapshot; then remove the `'` again to put the test back into "assert snapshot" mode.
|
||||
|
||||
```fsharp
|
||||
[<Test>]
|
||||
let ``Example of automatically updating`` () =
|
||||
// This test fails...
|
||||
expect {
|
||||
snapshotJson "123"
|
||||
return 124
|
||||
}
|
||||
|
||||
// so make this change:
|
||||
expect' {
|
||||
snapshotJson "123"
|
||||
return 124
|
||||
}
|
||||
|
||||
// and rerunning converts the result to this:
|
||||
expect' {
|
||||
snapshotJson @"124"
|
||||
return 124
|
||||
}
|
||||
|
||||
// That test will always throw, because it's not in "assertion" mode but in "update" mode;
|
||||
// so finally, remove the `'` again. This test now passes!
|
||||
expect {
|
||||
snapshotJson @"124"
|
||||
return 124
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
# Limitations
|
||||
|
||||
* The snapshot updating mechanism *requires* you to use verbatim string literals. While the test assertions will work correctly if you do `snapshot ("foo" + "bar" + f 3)`, for example, the updating code is liable to do something undefined in that case. Also do not use format strings (`$"blah"`).
|
||||
|
Reference in New Issue
Block a user