diff --git a/.github/.force-nuget-push b/.github/.force-nuget-push new file mode 100644 index 000000000..1e8b31496 --- /dev/null +++ b/.github/.force-nuget-push @@ -0,0 +1 @@ +6 diff --git a/.github/workflows/CI-CD-Docs.yml b/.github/workflows/CI-CD-Docs.yml index e5aae134b..d5eb3a9cd 100644 --- a/.github/workflows/CI-CD-Docs.yml +++ b/.github/workflows/CI-CD-Docs.yml @@ -18,9 +18,16 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v2 with: - persist-credentials: false + fetch-depth: 0 # avoid shallow clone so nbgv can do its work. + - uses: dotnet/nbgv@master + with: + setAllVars: true + - name: Setting VERSION and BRANCH env + run: | + echo "::set-env name=VERSION::$NBGV_NuGetPackageVersion" + echo "::set-env name=BRANCH::$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//_/g')" - name: Update tokens in project files uses: cschleiden/replace-tokens@v1 with: @@ -30,11 +37,11 @@ jobs: dotnet-version: '3.1.202' - name: Building library and docs run: | - dotnet restore - dotnet build src/bunit.core --no-restore -p:version=$VERSION - dotnet build src/bunit.web --no-restore -p:version=$VERSION - dotnet build src/bunit.xunit --no-restore -p:version=$VERSION - dotnet build docs/docs.csproj --no-restore + dotnet restore src + dotnet build src/bunit.core/ --no-restore -p:version=$VERSION + dotnet build src/bunit.web/ --no-restore -p:version=$VERSION + dotnet build src/bunit.xunit/ --no-restore -p:version=$VERSION + dotnet build docs/docs.csproj - name: Deploy uses: JamesIves/github-pages-deploy-action@releases/v3 with: diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9ed7fd651..8711e6b2e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -32,10 +32,7 @@ jobs: files: '["*.csproj", "**/*.csproj"]' - uses: actions/setup-dotnet@v1 with: - dotnet-version: '3.1.202' - source-url: https://nuget.pkg.github.com/egil/index.json - env: - NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + dotnet-version: '3.1.202' - name: Building library run: | dotnet restore src @@ -62,5 +59,12 @@ jobs: dotnet new bunit --no-restore -o ${GITHUB_WORKSPACE}/Test dotnet restore ${GITHUB_WORKSPACE}/Test/Test.csproj --source ${GITHUB_WORKSPACE}/packages dotnet test ${GITHUB_WORKSPACE}/Test - - name: Push packages to GitHub Packages - run: dotnet nuget push ${GITHUB_WORKSPACE}/packages/'*.nupkg' --skip-duplicate \ No newline at end of file + - name: Push packages to GitHub Package Registry + run: | + for f in ${GITHUB_WORKSPACE}/packages/*.nupkg + do + curl -vX PUT -u "egil:${{ secrets.GITHUB_TOKEN }}" -F package=@$f https://nuget.pkg.github.com/egil/ + done + shell: bash +# - name: Push packages to GitHub Package Registry +# run: dotnet nuget push ${GITHUB_WORKSPACE}/packages/'*.nupkg' --skip-duplicate \ No newline at end of file diff --git a/.github/workflows/NUGET-PUSH.yml b/.github/workflows/NUGET-PUSH.yml new file mode 100644 index 000000000..b9ccac2c6 --- /dev/null +++ b/.github/workflows/NUGET-PUSH.yml @@ -0,0 +1,70 @@ +name: NUGET-PUSH + +on: + push: + branches: + - master + paths: + - '.github/.force-nuget-push' + +env: + VERSION: '' + BRANCH: 'master' + +jobs: + build: + name: Build and verify library + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # avoid shallow clone so nbgv can do its work. + - uses: dotnet/nbgv@master + with: + setAllVars: true + - name: Setting VERSION and BRANCH env + run: echo "::set-env name=VERSION::$NBGV_NuGetPackageVersion" + - name: Update tokens in project files + uses: cschleiden/replace-tokens@v1 + with: + files: '["*.csproj", "**/*.csproj"]' + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: '3.1.202' + - name: Building library + run: | + dotnet restore src + dotnet build src/bunit.core/ -c Release --no-restore -p:RepositoryBranch=$BRANCH -p:ContinuousIntegrationBuild=true -p:DeterministicSourcePaths=true + dotnet build src/bunit.web/ -c Release --no-restore -p:RepositoryBranch=$BRANCH -p:ContinuousIntegrationBuild=true -p:DeterministicSourcePaths=true + dotnet build src/bunit.xunit/ -c Release --no-restore -p:RepositoryBranch=$BRANCH -p:ContinuousIntegrationBuild=true -p:DeterministicSourcePaths=true + dotnet build src/bunit.testassets/ -c Release --no-restore + - name: Running unit tests + run: | + dotnet test src/bunit.core.tests/ -c Release --no-restore --verbosity normal /nowarn:CS1591 + dotnet test src/bunit.web.tests/ -c Release --no-restore --verbosity normal /nowarn:CS1591 + dotnet test src/bunit.xunit.tests/ -c Release --no-restore --verbosity normal /nowarn:CS1591 + - name: Creating library package + run: | + dotnet pack src/bunit.core/ -c Release -o ${GITHUB_WORKSPACE}/packages -p:RepositoryBranch=$BRANCH -p:ContinuousIntegrationBuild=true -p:DeterministicSourcePaths=true + dotnet pack src/bunit.web/ -c Release -o ${GITHUB_WORKSPACE}/packages -p:RepositoryBranch=$BRANCH -p:ContinuousIntegrationBuild=true -p:DeterministicSourcePaths=true + dotnet pack src/bunit.xunit/ -c Release -o ${GITHUB_WORKSPACE}/packages -p:RepositoryBranch=$BRANCH -p:ContinuousIntegrationBuild=true -p:DeterministicSourcePaths=true + dotnet pack src/bunit/ -c Release -o ${GITHUB_WORKSPACE}/packages -p:RepositoryBranch=$BRANCH -p:ContinuousIntegrationBuild=true -p:DeterministicSourcePaths=true + - name: Buidling template package + run: dotnet pack src/bunit.template/ -c Release -o ${GITHUB_WORKSPACE}/packages + - name: Verifying template + run: | + dotnet new --install ${GITHUB_WORKSPACE}/packages/bunit.template.$VERSION.nupkg + dotnet new bunit --no-restore -o ${GITHUB_WORKSPACE}/Test + dotnet restore ${GITHUB_WORKSPACE}/Test/Test.csproj --source ${GITHUB_WORKSPACE}/packages + dotnet test ${GITHUB_WORKSPACE}/Test + - name: Push packages to NuGet + run: dotnet nuget push ${GITHUB_WORKSPACE}/packages/'*.nupkg' -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate + - name: Push packages to GitHub Package Registry + run: | + for f in ${GITHUB_WORKSPACE}/packages/*.nupkg + do + curl -vX PUT -u "egil:${{ secrets.GITHUB_TOKEN }}" -F package=@$f https://nuget.pkg.github.com/egil/ + done + shell: bash + #- name: Push packages to GitHub Package Registry + # run: dotnet nuget push ${GITHUB_WORKSPACE}/packages/'*.nupkg' -k ${{ secrets.GITHUB_TOKEN }} -s https://nuget.pkg.github.com/egil/index.json --skip-duplicate \ No newline at end of file diff --git a/.github/workflows/RELEASE.yml b/.github/workflows/RELEASE.yml index b0e5e89ac..5cbb77648 100644 --- a/.github/workflows/RELEASE.yml +++ b/.github/workflows/RELEASE.yml @@ -7,7 +7,7 @@ on: - edited env: - VERSION: 0.0.0 + VERSION: '' BRANCH: '' jobs: @@ -61,5 +61,7 @@ jobs: dotnet new bunit --no-restore -o ${GITHUB_WORKSPACE}/Test dotnet restore ${GITHUB_WORKSPACE}/Test/Test.csproj --source ${GITHUB_WORKSPACE}/packages dotnet test ${GITHUB_WORKSPACE}/Test - - name: Push packages to GitHub Packages - run: dotnet nuget push ${GITHUB_WORKSPACE}/packages/'*.nupkg' --skip-duplicate \ No newline at end of file + # - name: Push packages to NuGet + # run: dotnet nuget push ${GITHUB_WORKSPACE}/packages/'*.nupkg' -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate + # - name: Push packages to GitHub Package Registry + # run: dotnet nuget push ${GITHUB_WORKSPACE}/packages/'*.nupkg' -k ${{ secrets.GITHUB_TOKEN }} -s https://nuget.pkg.github.com/egil/index.json --skip-duplicate \ No newline at end of file diff --git a/README.md b/README.md index a5a3f8493..54d24a3d6 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,20 @@ The library's goal is to make it easy to write _comprehensive, stable unit tests **Go to [bUnit.egilhansen.com](https://bunit.egilhansen.com) to learn more.** +### NuGet downloads + +bUnit is available on NuGet in various incarnations. If you are using xUnit as your general purpose testing framework, you can use `bunit`, which includes everything in one package. If you want to use NUnit or MStest, then pick `bunit.core` and `bunit.web`: + +| Name | Type | NuGet Download Link | +| ----- | ----- | ---- | +| bUnit | Library, includes core, web, and xUnit | [![Nuget](https://img.shields.io/nuget/dt/bunit?logo=nuget&style=flat-square)](https://www.nuget.org/packages/bunit/) | +| bUnit.core | Library, only core | [![Nuget](https://img.shields.io/nuget/dt/bunit.core?logo=nuget&style=flat-square)](https://www.nuget.org/packages/bunit.core/) | +| bUnit.web | Library, web and core | [![Nuget](https://img.shields.io/nuget/dt/bunit.web?logo=nuget&style=flat-square)](https://www.nuget.org/packages/bunit.web/) | +| bUnit.xUnit |Library, xUnit and core | [![Nuget](https://img.shields.io/nuget/dt/bunit.xunit?logo=nuget&style=flat-square)](https://www.nuget.org/packages/bunit.xunit/) | +| bUnit.template | Template, which currently creates an xUnit based bUnit test projects only | [![Nuget](https://img.shields.io/nuget/dt/bunit.template?logo=nuget&style=flat-square)](https://www.nuget.org/packages/bunit.template/) | + +To get started, head to the documentation on [bUnit.egilhansen.com/docs](https://bunit.egilhansen.com/docs) to learn more. + ## Milestones to v1.0.0 These are the current goals that should be reached before v1.0.0 is ready: @@ -36,4 +50,4 @@ In the post v1.0.0 to v1.0.x time frame, focus will be on improving performance. ## Contributors -Shout outs and a big thank you [to all the contributors](https://github.com/egil/bunit/graphs/contributors) to the library, both those that raise issues, provide input to issues, and those who send pull requests. +Shout outs and a big thank you [to all the contributors](https://github.com/egil/bunit/graphs/contributors) to the library, both those that raise issues, provide input to issues, and those who send pull requests. Thank you! diff --git a/docs/index.md b/docs/index.md index f692d1e88..9d6f82804 100644 --- a/docs/index.md +++ b/docs/index.md @@ -41,6 +41,18 @@ public void CounterShouldIncrementWhenClicked() **Go to [Documentation](/docs) to learn more.** +### NuGet downloads + +bUnit is available on NuGet in various incarnations. If you are using xUnit as your general purpose testing framework, you can use `bunit`, which includes everything in one package. If you want to use NUnit or MStest, then pick `bunit.core` and `bunit.web`: + +| Name | Type | NuGet Download Link | +| ----- | ----- | ---- | +| bUnit | Library, includes core, web, and xUnit | [![Nuget](https://img.shields.io/nuget/dt/bunit?logo=nuget&style=flat-square)](https://www.nuget.org/packages/bunit/) | +| bUnit.core | Library, only core | [![Nuget](https://img.shields.io/nuget/dt/bunit.core?logo=nuget&style=flat-square)](https://www.nuget.org/packages/bunit.core/) | +| bUnit.web | Library, web and core | [![Nuget](https://img.shields.io/nuget/dt/bunit.web?logo=nuget&style=flat-square)](https://www.nuget.org/packages/bunit.web/) | +| bUnit.xUnit |Library, xUnit and core | [![Nuget](https://img.shields.io/nuget/dt/bunit.xunit?logo=nuget&style=flat-square)](https://www.nuget.org/packages/bunit.xunit/) | +| bUnit.template | Template, which currently creates an xUnit based bUnit test projects only | [![Nuget](https://img.shields.io/nuget/dt/bunit.template?logo=nuget&style=flat-square)](https://www.nuget.org/packages/bunit.template/) | + ## Milestones to v1.0.0 These are the current goals that should be reached before v1.0.0 is ready: @@ -61,4 +73,4 @@ Shout outs and a big thank you [to all the contributors](https://github.com/egil - Provide feedback and input through [issues](https://github.com/egil/bunit/issues), [Twitter](https://twitter.com/egilhansen) or [bUnit Gitter chat room](https://gitter.im/egil/bunit). - Help build the library, just pick an issue and submit pull-requests. - Help write documentation. -- Create blog posts, presentations or video tutorials. If you do, I will be happy to showcase them in the related section on this site. \ No newline at end of file +- Create blog posts, presentations or video tutorials. If you do, I will be happy to showcase them in the related section on this site. diff --git a/docs/templates/bunit/styles/main.css b/docs/templates/bunit/styles/main.css new file mode 100644 index 000000000..1732f168f --- /dev/null +++ b/docs/templates/bunit/styles/main.css @@ -0,0 +1,27 @@ +.navbar-brand { + line-height: 50px; + margin-right: 15px !important; +} +.navbar-brand>img { + display: inline-block; + margin-top: -8px; + margin-right: 5px; +} + +.navbar-brand>span { + font-weight: 600; + font-size: 16px; + color: #fff; +} + +.body-content { + font-size: 1.6rem; +} + +.article { + margin-top: 80px; +} + +.sideaffix { + margin-top: 0; +} \ No newline at end of file diff --git a/src/bunit.core/TestContextBase.cs b/src/bunit.core/TestContextBase.cs index d68c222ab..3ccfff964 100644 --- a/src/bunit.core/TestContextBase.cs +++ b/src/bunit.core/TestContextBase.cs @@ -41,7 +41,7 @@ public TestContextBase() } /// - public void Dispose() + public virtual void Dispose() { // The service provider should dispose of any // disposable object it has created, when it is disposed.