Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Relfos committed Jul 14, 2023
2 parents 5b0c88e + 0dfc107 commit ee20d6c
Show file tree
Hide file tree
Showing 219 changed files with 7,892 additions and 2,445 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/comment-on-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Comment on the pull request

# read-write repo token
# access to secrets
on:
workflow_run:
workflows: [".NET Core"]
types:
- completed
permissions:
pull-requests: write
actions: write
issues: write
contents: write

env:
GITHUB_TOKEN: ${{ secrets.PR_KEY }}

jobs:
build:
name: Comment on PR
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
permissions: write-all
steps:
- uses: actions/checkout@v3

- uses: actions/download-artifact@v3
with:
name: my-artifact

- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
with:
recreate: true
path: code-coverage-results.md
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
65 changes: 48 additions & 17 deletions .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,60 @@ on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
branches: [ master, dev]

permissions:
pull-requests: write
issues: write
contents: write
actions: write
id-token: write
packages: write
deployments: write
discussions: write

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build:

name: Build TOMB
runs-on: ubuntu-latest

permissions: write-all

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 3.1.301
- name: Get PhantasmaChain
run: |
sudo apt-get update
sudo apt-get -y install git libicu-dev
git clone https://github.com/phantasma-io/PhantasmaChain.git ../PhantasmaChain
cd ../PhantasmaChain
git checkout development
dotnet-version: 6.0.x

- name: Install dependencies
run: dotnet restore
run: |
sudo apt-get install libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev libzstd-dev
sudo apt-get install libc6-dev libicu-dev libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev libzstd-dev librocksdb-dev
sudo apt-get install librocksdb-dev
dotnet tool install --global dotnet-reportgenerator-globaltool
dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
run: dotnet build --configuration Release --no-restore

- name: Test
run: dotnet test --no-restore --verbosity normal
run: dotnet test --no-build --configuration Release --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage

- name: Combine Coverage Output
run: reportgenerator "-reports:coverage/**/coverage.cobertura.xml" -targetdir:"coverage" -reporttypes:Cobertura -assemblyfilters:"-TOMBLib.Tests"

- name: Code Coverage Summary Report
uses: irongut/[email protected]
with:
filename: coverage/Cobertura.xml
badge: true
fail_below_min: false
format: markdown
hide_branch_rate: false
hide_complexity: false
indicators: true
output: both
thresholds: '60 80'
52 changes: 52 additions & 0 deletions .github/workflows/dotnet-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: .NET Nuget Publish

on:
workflow_dispatch:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
pull-requests: write
actions: write
issues: write
contents: write

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build:
name: Build and Publish Nuget
runs-on: ubuntu-latest
permissions: write-all

steps:
- uses: actions/checkout@v3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x

- name: Install dependencies
run: |
dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore

- name: Pack Nuget
run: dotnet pack --configuration Release --no-restore

- name: Publish Nuget
run: |
dotnet nuget push ./Library/src/bin/Release/TOMBLib.*.nupkg --skip-duplicate -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
- name: Publish Nuget Github
run: |
dotnet nuget add ./Library/src/bin/Release/TOMBLib.*.nupkg --skip-duplicate --username USERNAME --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/phantasma-io/index.json"
dotnet nuget push ./Library/src/bin/Release/TOMBLib.*.nupkg --skip-duplicate --api-key ${{secrets.PR_KEY}} --source "github"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ Publish/

Compiler/Properties/launchSettings.json
.idea/
coverage/

Releases/
10 changes: 8 additions & 2 deletions Compiler/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ static void Main(string[] args)
break;
}

case "debug":
{
Compiler.DebugMode = true;
break;
}

default:
ShowWarning("Unknown option: " + tag);
break;
Expand All @@ -177,9 +183,9 @@ static void Main(string[] args)
sourceFileName = @"..\..\..\builtins.tomb";
}
#else
if (string.IsNullOrEmpty(sourceFilePath))
if (string.IsNullOrEmpty(sourceFileName))
{
sourceFilePath = @"my_contract.tomb";
sourceFileName = @"my_contract.tomb";
}
#endif

Expand Down
5 changes: 2 additions & 3 deletions Compiler/TombCompiler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace>Phantasma.Tomb</RootNamespace>
<ImplicitUsings>disable</ImplicitUsings>
</PropertyGroup>
Expand All @@ -12,8 +12,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CompilerLib\CompilerLib.csproj" />
<ProjectReference Include="..\Library\TOMBLib.csproj" />
<ProjectReference Include="..\Library\src\TOMBLib.csproj" />
</ItemGroup>

</Project>
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public class DecimalDeclaration : VarDeclaration
{
public readonly int Decimals;

public DecimalDeclaration(Scope parentScope, string name, int decimals, VarStorage storage) : base(parentScope, name, VarType.Find(VarKind.Decimal), storage)
public DecimalDeclaration(Scope parentScope, string name, int decimals, VarStorage storage) : base(parentScope, name, VarType.Find(VarKind.Decimal, decimals), storage)
{
this.Decimals = decimals;
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,12 @@ private static void Initialize()
i++;
} while (true);

#if DEBUG
Console.WriteLine($"Detected builtin: {libName}.{methodName}");
#endif
if (Compiler.DebugMode)
{
Console.WriteLine($"Detected builtin: {libName}.{methodName}");
}

var alias = ("tomb_" + libName + "_" + methodName).ToLowerInvariant();
var alias = ("tomb_" + libName + "_" + methodName).ToLowerInvariant();

var builtinCode = code.ToString();

Expand Down
File renamed without changes.
27 changes: 22 additions & 5 deletions Library/CodeGen/Contract.cs → Library/src/CodeGen/Contract.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Phantasma.Business.VM;
using Phantasma.Core.Domain;
using Phantasma.Tomb.AST;
using Phantasma.Tomb.AST.Declarations;
using Phantasma.Tomb.AST.Expressions;
using static Grpc.Core.Metadata;
using Phantasma.Tomb.AST.Statements;

namespace Phantasma.Tomb.CodeGen
{
Expand Down Expand Up @@ -90,6 +87,7 @@ public override ContractInterface GenerateCode(CodeGenerator output)

if (this.Kind == ModuleKind.Token)
{
bool hasSymbol = false;
bool hasName = false;

foreach (var method in this.Methods.Values)
Expand All @@ -116,8 +114,14 @@ public override ContractInterface GenerateCode(CodeGenerator output)
break;

case "Symbol":
hasSymbol = true;
checkForGlobals = true;
ExpectMethodType(method, VarKind.String);
break;

case "Decimals":
checkForGlobals = true;
ExpectMethodType(method, VarKind.Number);
break;
}
}
Expand Down Expand Up @@ -159,6 +163,19 @@ public override ContractInterface GenerateCode(CodeGenerator output)
{
throw new CompilerException($"token {this.Name} is missing property 'name'");
}

if (!hasSymbol)
{
var type = VarType.Find(VarKind.String);
var symbolScope = new Scope(this.Scope, "getSymbol");

var symbolProperty = AddMethod(this.LineNumber, "getSymbol", true, MethodKind.Property, type, new MethodParameter[0], symbolScope, false);

var body = new StatementBlock(symbolScope);
body.Commands.Add(new ReturnStatement(symbolProperty, new LiteralExpression(symbolScope, $"\"{Name}\"", type)));

this.SetMethodBody(symbolProperty.Name, body);
}
}

this.Scope.Enter(output);
Expand Down Expand Up @@ -300,4 +317,4 @@ protected override void ProcessABI(ContractInterface abi, DebugInfo debugInfo)
}
}
}
}
}
Loading

0 comments on commit ee20d6c

Please sign in to comment.