Skip to content

Add C# syntax checklist doc #4613

Add C# syntax checklist doc

Add C# syntax checklist doc #4613

Workflow file for this run

name: .NET Core Test and Publish
on:
push:
branches: [master]
pull_request:
env:
DOTNET_VERSION: 8.0.x
DOTNET_TEST_PARAMETERS: --no-build /p:CollectCoverage=true -l "console;verbosity=detailed"
COVERLET_EXCLUDE_COVERAGE: /p:Exclude=\"[Neo.SmartContract.TestEngine]*,[Neo.Compiler.CSharp.UnitTests]*,[Neo]*,[Neo.IO]*,[Neo.Json]*,[Neo.VM]*,[Neo.Extensions]*,[Neo.Cryptography.BLS12_381]*\"
COVERLET_OUTPUT: /p:CoverletOutput=${{ github.workspace }}/coverage-join/
COVERLET_MERGE_WITH: /p:MergeWith=${{ github.workspace }}/coverage-join/coverage.json
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
Test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Check format
run: |
dotnet format --no-restore --verify-no-changes --verbosity diagnostic
- name: Build Neo.Compiler.CSharp
run: dotnet build ./src/Neo.Compiler.CSharp/Neo.Compiler.CSharp.csproj
- name: Build Neo.SmartContract.Template and test templates
run: |
dotnet pack ./src/Neo.SmartContract.Template/Neo.SmartContract.Template.csproj --configuration Debug
dotnet new install ./src/Neo.SmartContract.Template/bin/Debug/Neo.SmartContract.Template.*.nupkg
dotnet new neocontractnep17 -n Nep17Contract -o ./src/Neo.SmartContract.Template/bin/Debug/nep17/ --force
dotnet new neocontractowner -n Ownable -o ./src/Neo.SmartContract.Template/bin/Debug/ownable/ --force
dotnet new neocontractoracle -n OracleRequest -o ./src/Neo.SmartContract.Template/bin/Debug/oracle/ --force
dotnet new uninstall Neo.SmartContract.Template
dotnet remove ./src/Neo.SmartContract.Template/bin/Debug/nep17/Nep17Contract.csproj package Neo.SmartContract.Framework
dotnet add ./src/Neo.SmartContract.Template/bin/Debug/nep17/Nep17Contract.csproj reference ./src/Neo.SmartContract.Framework/Neo.SmartContract.Framework.csproj
dotnet remove ./src/Neo.SmartContract.Template/bin/Debug/ownable/Ownable.csproj package Neo.SmartContract.Framework
dotnet add ./src/Neo.SmartContract.Template/bin/Debug/ownable/Ownable.csproj reference ./src/Neo.SmartContract.Framework/Neo.SmartContract.Framework.csproj
dotnet remove ./src/Neo.SmartContract.Template/bin/Debug/oracle/OracleRequest.csproj package Neo.SmartContract.Framework
dotnet add ./src/Neo.SmartContract.Template/bin/Debug/oracle/OracleRequest.csproj reference ./src/Neo.SmartContract.Framework/Neo.SmartContract.Framework.csproj
dotnet ./src/Neo.Compiler.CSharp/bin/Debug/net8.0/nccs.dll ./src/Neo.SmartContract.Template/bin/Debug/nep17/Nep17Contract.csproj -o ./tests/Neo.SmartContract.Template.UnitTests/templates/neocontractnep17/Artifacts/
dotnet ./src/Neo.Compiler.CSharp/bin/Debug/net8.0/nccs.dll ./src/Neo.SmartContract.Template/bin/Debug/ownable/Ownable.csproj -o ./tests/Neo.SmartContract.Template.UnitTests/templates/neocontractowner/Artifacts/
dotnet ./src/Neo.Compiler.CSharp/bin/Debug/net8.0/nccs.dll ./src/Neo.SmartContract.Template/bin/Debug/oracle/OracleRequest.csproj -o ./tests/Neo.SmartContract.Template.UnitTests/templates/neocontractoracle/Artifacts/
- name: Build Solution
run: dotnet build ./neo-devpack-dotnet.sln
- name: Add package coverlet.msbuild
run: find tests -name *.csproj | xargs -I % dotnet add % package coverlet.msbuild
- name: Test Neo.Compiler.CSharp.UnitTests
run: |
dotnet test ./tests/Neo.Compiler.CSharp.UnitTests \
${{ env.DOTNET_TEST_PARAMETERS }} \
${{ env.COVERLET_OUTPUT }} \
${{ env.COVERLET_EXCLUDE_COVERAGE }} \
- name: Test Neo.SmartContract.Framework.UnitTests
run: |
dotnet test ./tests/Neo.SmartContract.Framework.UnitTests \
${{ env.DOTNET_TEST_PARAMETERS }} \
${{ env.COVERLET_OUTPUT }} \
${{ env.COVERLET_MERGE_WITH }} \
${{ env.COVERLET_EXCLUDE_COVERAGE }} \
- name: Test Neo.SmartContract.Testing.UnitTests
run: |
dotnet test ./tests/Neo.SmartContract.Testing.UnitTests \
${{ env.DOTNET_TEST_PARAMETERS }} \
${{ env.COVERLET_OUTPUT }} \
${{ env.COVERLET_MERGE_WITH }} \
${{ env.COVERLET_EXCLUDE_COVERAGE }} \
- name: Test Neo.SmartContract.Template.UnitTests
run: |
dotnet test ./tests/Neo.SmartContract.Template.UnitTests \
${{ env.DOTNET_TEST_PARAMETERS }} \
${{ env.COVERLET_MERGE_WITH }} \
${{ env.COVERLET_EXCLUDE_COVERAGE }} \
/p:CoverletOutput=${{ github.workspace }}/coverage/lcov \
/p:CoverletOutputFormat=lcov
- name: Coveralls
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
format: lcov
file: ${{ github.workspace }}/coverage/lcov.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
submodules: recursive
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Set Version (dev-pack)
run: git rev-list --count HEAD | xargs printf 'CI%05d' | xargs -I{} echo 'VERSION_SUFFIX={}' >> $GITHUB_ENV
- name: Set Version (Neo)
run: |
git --git-dir=./neo/.git rev-list --count HEAD | xargs printf 'CI%05d' | xargs -I{} echo 'VERSION_SUFFIX_NEO={}' >> $GITHUB_ENV
sed -n 's/.*<VersionPrefix>\(.*\)<\/VersionPrefix>.*/\1/p' ./neo/src/Directory.Build.props | xargs -I{} echo 'VERSION_NEO={}' >> $GITHUB_ENV
- name : Pack (Neo.SmartContract.Framework)
run: |
dotnet pack ./src/Neo.SmartContract.Framework \
--configuration Debug \
--output ./out \
--version-suffix ${{ env.VERSION_SUFFIX }}
- name : Replace Neo reference by package in Neo.SmartContract.Testing
run: |
dotnet remove ./src/Neo.SmartContract.Testing/Neo.SmartContract.Testing.csproj reference '..\..\neo\src\Neo\Neo.csproj'
dotnet add ./src/Neo.SmartContract.Testing/Neo.SmartContract.Testing.csproj package 'Neo' --version ${{ env.VERSION_NEO }}-${{ env.VERSION_SUFFIX_NEO }}
- name : Build (Neo.SmartContract.Testing)
run: |
dotnet build ./src/Neo.SmartContract.Testing -f net8.0
dotnet build ./src/Neo.SmartContract.Testing -f netstandard2.1
- name : Pack (Neo.SmartContract.Testing)
run: |
dotnet pack ./src/Neo.SmartContract.Testing \
--no-build \
--configuration Debug \
--output ./out \
--version-suffix ${{ env.VERSION_SUFFIX }}
- 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
with:
fetch-depth: 0
submodules: recursive
- 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 Core
if: steps.check_tag.outputs.statusCode == '404'
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Publish to NuGet
if: steps.check_tag.outputs.statusCode == '404'
run: |
dotnet sln neo-devpack-dotnet.sln remove ./neo/src/neo/neo.csproj
dotnet sln neo-devpack-dotnet.sln remove ./neo/src/Neo.Cryptography.BLS12_381/Neo.Cryptography.BLS12_381.csproj
dotnet sln neo-devpack-dotnet.sln remove ./neo/src/Neo.Extensions/Neo.Extensions.csproj
dotnet sln neo-devpack-dotnet.sln remove ./neo/src/Neo.IO/Neo.IO.csproj
dotnet sln neo-devpack-dotnet.sln remove ./neo/src/Neo.Json/Neo.Json.csproj
dotnet sln neo-devpack-dotnet.sln remove ./neo/src/Neo.VM/Neo.VM.csproj
dotnet pack -o pub -c Release
dotnet nuget push "pub/*.nupkg" -s https://api.nuget.org/v3/index.json -k ${NUGET_TOKEN} --skip-duplicate
env:
NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}