diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..9166b109 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,77 @@ +name: CI + +on: + push: + branches: [ master ] + +jobs: + build: + runs-on: windows-latest + steps: + - uses: actions/checkout@master + - name: Setup dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.102 + - name: Build Main + working-directory: ./source + run: dotnet build Handlebars.sln -c Release + + test: + name: Test + runs-on: windows-latest + needs: [build] + steps: + - uses: actions/checkout@master + - name: Setup dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.102 + - name: Test + working-directory: ./source + run: dotnet test ./Handlebars.Test/Handlebars.Test.csproj -f netcoreapp3.1 --logger:trx + + sonar-ci: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.102 + - name: Sonarscanner for dotnet + uses: Secbyte/dotnet-sonarscanner@v2.2 + with: + buildCommand: dotnet build source/Handlebars.Code.sln -f netstandard2.0 + testCommand: dotnet test source/Handlebars.Test/Handlebars.Test.csproj -f netcoreapp3.1 --logger:trx + projectKey: zjklee_handlebars.csharp + projectName: handlebars.csharp + sonarOrganisation: zjklee + beginArguments: > + /d:sonar.verbose="true" + /d:sonar.cs.opencover.reportsPaths='"*.opencover.xml"' + /d:sonar.coverage.exclusions='"**/*.cs","**/*.md"' + + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + + publish: + needs: [build,test,sonar-ci] + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Setup dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.100 + - name: Fetch + run: git fetch --depth 500 + - name: Determine version + run: echo "::set-env name=VERSION::$(git describe --tags --abbrev=0)" + - name: publish + working-directory: ./source + run: dotnet pack Handlebars.Code.sln -c Release /p:version=${{ env.VERSION }}.${{ github.run_number }}-beta && dotnet nuget push **/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 00000000..bf218810 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,54 @@ +name: Pull Request + +on: + pull_request: + branches: [ master ] + +jobs: + build: + runs-on: windows-latest + steps: + - uses: actions/checkout@master + - name: Setup dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.102 + - name: Build + working-directory: ./source + run: dotnet build Handlebars.Code.sln -c Release + + test: + runs-on: windows-latest + needs: [build] + steps: + - uses: actions/checkout@master + - name: Setup dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.102 + - name: Test + working-directory: ./source + run: dotnet test ./Handlebars.Test/Handlebars.Test.csproj -f netcoreapp3.1 --logger:trx + + sonar-pr: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Sonarscanner for dotnet + uses: Secbyte/dotnet-sonarscanner@v2.2 + with: + buildCommand: dotnet build source/Handlebars.Code.sln -f netstandard2.0 + testCommand: dotnet test source/Handlebars.Test/Handlebars.Test.csproj -f netcoreapp3.1 --logger:trx + projectKey: zjklee_handlebars.csharp + projectName: handlebars.csharp + sonarOrganisation: zjklee + beginArguments: > + /d:sonar.verbose="true" + /d:sonar.coverage.exclusions='"**/*.cs","**/*.md"' + /d:sonar.pullrequest.key=${{ github.event.number }} + /d:sonar.pullrequest.branch=${{ github.event.pull_request.head.ref }} + /d:sonar.pullrequest.base=${{ github.event.pull_request.base.ref }} + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..ce4a5237 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,20 @@ +name: Release + +on: + release: + types: [published] + +jobs: + publish: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + + - name: Setup dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.100 + + - name: publish + working-directory: ./source + run: dotnet pack Handlebars.Code.sln -c Release /p:version=${{ github.event.release.tag_name }} && dotnet nuget push **/*.nupkg -k ${{ secrets.NUGET_TOKEN }} -s https://api.nuget.org/v3/index.json diff --git a/source/Handlebars.Code.sln b/source/Handlebars.Code.sln new file mode 100644 index 00000000..1a5ef6e5 --- /dev/null +++ b/source/Handlebars.Code.sln @@ -0,0 +1,66 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26403.3 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Handlebars", "Handlebars\Handlebars.csproj", "{A09CFF95-B671-48FE-96A8-D3CBDC110B75}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E9AC0BCD-C060-4634-BBBB-636167C809B4}" + ProjectSection(SolutionItems) = preProject + ..\README.md = ..\README.md + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A09CFF95-B671-48FE-96A8-D3CBDC110B75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A09CFF95-B671-48FE-96A8-D3CBDC110B75}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A09CFF95-B671-48FE-96A8-D3CBDC110B75}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A09CFF95-B671-48FE-96A8-D3CBDC110B75}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + Policies = $0 + $0.TextStylePolicy = $1 + $1.inheritsSet = VisualStudio + $1.inheritsScope = text/plain + $1.scope = text/x-csharp + $0.CSharpFormattingPolicy = $2 + $2.IndentSwitchBody = True + $2.IndentBlocksInsideExpressions = True + $2.AnonymousMethodBraceStyle = NextLine + $2.PropertyBraceStyle = NextLine + $2.PropertyGetBraceStyle = NextLine + $2.PropertySetBraceStyle = NextLine + $2.EventBraceStyle = NextLine + $2.EventAddBraceStyle = NextLine + $2.EventRemoveBraceStyle = NextLine + $2.StatementBraceStyle = NextLine + $2.ElseNewLinePlacement = NewLine + $2.CatchNewLinePlacement = NewLine + $2.FinallyNewLinePlacement = NewLine + $2.WhileNewLinePlacement = DoNotCare + $2.ArrayInitializerWrapping = DoNotChange + $2.ArrayInitializerBraceStyle = NextLine + $2.BeforeMethodDeclarationParentheses = False + $2.BeforeMethodCallParentheses = False + $2.BeforeConstructorDeclarationParentheses = False + $2.NewLineBeforeConstructorInitializerColon = NewLine + $2.NewLineAfterConstructorInitializerColon = SameLine + $2.BeforeDelegateDeclarationParentheses = False + $2.NewParentheses = False + $2.SpacesBeforeBrackets = False + $2.inheritsSet = Mono + $2.inheritsScope = text/x-csharp + $2.scope = text/x-csharp + $0.DotNetNamingPolicy = $3 + $3.DirectoryNamespaceAssociation = None + $3.ResourceNamePolicy = FileFormatDefault + version = 1.0.0 + EndGlobalSection +EndGlobal diff --git a/source/Handlebars.Test/Handlebars.Test.csproj b/source/Handlebars.Test/Handlebars.Test.csproj index f9157cfe..662482e0 100644 --- a/source/Handlebars.Test/Handlebars.Test.csproj +++ b/source/Handlebars.Test/Handlebars.Test.csproj @@ -2,7 +2,7 @@ full - net461;netcoreapp1.1;netcoreapp2.0 + net461;netcoreapp1.1;netcoreapp2.0;netcoreapp3.1 @@ -11,6 +11,9 @@ $(DefineConstants);netstandard + + $(DefineConstants);netstandard + diff --git a/source/Handlebars.Test/WhitespaceTests.cs b/source/Handlebars.Test/WhitespaceTests.cs index cf73457d..ca64a623 100644 --- a/source/Handlebars.Test/WhitespaceTests.cs +++ b/source/Handlebars.Test/WhitespaceTests.cs @@ -54,7 +54,8 @@ public void ComplexTest() {{~/if~}} {{~/each}}"; - var template = Handlebars.Compile(source); + var h = Handlebars.Create(); + var template = h.Compile(source); var data = new { nav = new [] { new { @@ -77,7 +78,8 @@ public void ComplexTest() public void StandaloneEach() { var source = "Links:\n {{#each nav}}\n \n {{#if test}}\n {{title}}\n {{else}}\n Empty\n {{/if}}\n \n {{/each}}"; - var template = Handlebars.Compile(source); + var h = Handlebars.Create(); + var template = h.Compile(source); var data = new { nav = new[]