[Refactor
] Test Projects
#8309
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: .NET Core Test and Publish | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
env: | |
DOTNET_VERSION: 8.0.202 | |
jobs: | |
Test: | |
timeout-minutes: 15 | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Check format | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
dotnet format --verify-no-changes --verbosity diagnostic | |
- name: Test | |
if: matrix.os != 'ubuntu-latest' | |
run: | | |
dotnet test | |
- name: Test for coverall | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
dotnet test ./tests/Neo.Cryptography.BLS12_381.Tests /p:CollectCoverage=true /p:CoverletOutput='${{ github.workspace }}/TestResults/coverage/' | |
dotnet test ./tests/Neo.ConsoleService.Tests /p:CollectCoverage=true /p:CoverletOutput='${{ github.workspace }}/TestResults/coverage/' /p:MergeWith='${{ github.workspace }}/TestResults/coverage/coverage.net8.0.json' | |
dotnet test ./tests/Neo.UnitTests /p:CollectCoverage=true /p:CoverletOutput='${{ github.workspace }}/TestResults/coverage/' /p:MergeWith='${{ github.workspace }}/TestResults/coverage/coverage.net8.0.json' | |
dotnet test ./tests/Neo.VM.Tests /p:CollectCoverage=true /p:CoverletOutput='${{ github.workspace }}/TestResults/coverage/' /p:MergeWith='${{ github.workspace }}/TestResults/coverage/coverage.net8.0.json' | |
dotnet test ./tests/Neo.Json.UnitTests /p:CollectCoverage=true /p:CoverletOutput='${{ github.workspace }}/TestResults/coverage/' /p:MergeWith='${{ github.workspace }}/TestResults/coverage/coverage.net8.0.json' /p:CoverletOutputFormat='lcov' | |
- name: Coveralls | |
if: matrix.os == 'ubuntu-latest' | |
uses: coverallsapp/[email protected] | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
format: lcov | |
file: ${{ github.workspace }}/TestResults/coverage/coverage.net8.0.info | |
PublishPackage: | |
if: github.ref == 'refs/heads/master' && startsWith(github.repository, 'neo-project/') | |
needs: Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Set Version | |
run: git rev-list --count HEAD | xargs printf 'CI%05d' | xargs -I{} echo 'VERSION_SUFFIX={}' >> $GITHUB_ENV | |
- name : Pack (Neo) | |
run: | | |
dotnet pack \ | |
--configuration Release \ | |
--output ./out \ | |
--version-suffix ${{ env.VERSION_SUFFIX }} | |
- name: Remove Unwanted Files | |
working-directory: ./out | |
run: | | |
rm -v Neo.CLI* | |
rm -v Neo.GUI* | |
- name: Publish to Github Packages | |
working-directory: ./out | |
run: | | |
dotnet nuget push * \ | |
--source https://nuget.pkg.github.com/neo-project/index.json \ | |
--api-key "${{ secrets.GITHUB_TOKEN }}" \ | |
--disable-buffering \ | |
--no-service-endpoint; | |
- name: Publish to myGet | |
working-directory: ./out | |
run: | | |
dotnet nuget push * \ | |
--source https://www.myget.org/F/neo/api/v3/index.json \ | |
--api-key "${{ secrets.MYGET_TOKEN }}" \ | |
--disable-buffering \ | |
--no-service-endpoint; | |
Release: | |
if: github.ref == 'refs/heads/master' && startsWith(github.repository, 'neo-project/') | |
needs: Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get version | |
id: get_version | |
run: | | |
sudo apt install xmlstarlet | |
find src -name Directory.Build.props | xargs xmlstarlet sel -N i=http://schemas.microsoft.com/developer/msbuild/2003 -t -v "concat('::set-output name=version::v',//i:VersionPrefix/text())" | xargs echo | |
- name: Check tag | |
id: check_tag | |
run: curl -s -I ${{ format('https://github.com/{0}/releases/tag/{1}', github.repository, steps.get_version.outputs.version) }} | head -n 1 | cut -d$' ' -f2 | xargs printf "::set-output name=statusCode::%s" | xargs echo | |
- name: Create release | |
if: steps.check_tag.outputs.statusCode == '404' | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.get_version.outputs.version }} | |
release_name: ${{ steps.get_version.outputs.version }} | |
prerelease: ${{ contains(steps.get_version.outputs.version, '-') }} | |
- name: Setup .NET | |
if: steps.check_tag.outputs.statusCode == '404' | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name : Pack (Neo) | |
if: steps.check_tag.outputs.statusCode == '404' | |
run: | | |
dotnet pack ./src/Neo \ | |
--configuration Release \ | |
--output ./out | |
- name : Pack (Neo.IO) | |
if: steps.check_tag.outputs.statusCode == '404' | |
run: | | |
dotnet pack ./src/Neo.IO \ | |
--configuration Release \ | |
--output ./out | |
- name : Pack (Neo.Extensions) | |
if: steps.check_tag.outputs.statusCode == '404' | |
run: | | |
dotnet pack ./src/Neo.Extensions \ | |
--configuration Release \ | |
--output ./out | |
- name : Pack (Neo.Json) | |
if: steps.check_tag.outputs.statusCode == '404' | |
run: | | |
dotnet pack ./src/Neo.Json \ | |
--configuration Release \ | |
--output ./out | |
- name : Pack (Neo.VM) | |
if: steps.check_tag.outputs.statusCode == '404' | |
run: | | |
dotnet pack ./src/Neo.VM \ | |
--configuration Release \ | |
--output ./out | |
- name : Pack (Neo.ConsoleService) | |
if: steps.check_tag.outputs.statusCode == '404' | |
run: | | |
dotnet pack ./src/Neo.ConsoleService \ | |
--configuration Release \ | |
--output ./out | |
- name : Pack (Neo.Cryptography.BLS12_381) | |
if: steps.check_tag.outputs.statusCode == '404' | |
run: | | |
dotnet pack ./src/Neo.Cryptography.BLS12_381 \ | |
--configuration Release \ | |
--output ./out | |
- name: Publish to NuGet | |
if: steps.check_tag.outputs.statusCode == '404' | |
run: | | |
dotnet nuget push out/*.nupkg -s https://api.nuget.org/v3/index.json -k ${NUGET_TOKEN} | |
env: | |
NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }} |