Skip to content

Commit

Permalink
Merge branch 'master' into core-ia-review
Browse files Browse the repository at this point in the history
  • Loading branch information
shargon authored Feb 21, 2024
2 parents e4bf06c + b2deb4c commit 98395a6
Show file tree
Hide file tree
Showing 72 changed files with 3,845 additions and 1,326 deletions.
14 changes: 14 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet
{
"name": "C# (.NET)",
"image": "mcr.microsoft.com/devcontainers/dotnet:1-7.0-jammy",
"onCreateCommand": "./scripts/load_submodule.sh",
"customizations": {
"vscode": {
"extensions": [
"ms-dotnettools.csdevkit"
]
}
}
}
File renamed without changes.
50 changes: 47 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,18 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Build
- name: Build Neo.Compiler.CSharp
run: dotnet build ./src/Neo.Compiler.CSharp/Neo.Compiler.CSharp.csproj
- name: Build Neo.SmartContract.Template and generate artifacts
run: |
dotnet pack ./src/Neo.SmartContract.Template/Neo.SmartContract.Template.csproj
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/ --force
dotnet new uninstall Neo.SmartContract.Template
dotnet remove ./src/Neo.SmartContract.Template/bin/Debug/Nep17Contract.csproj package Neo.SmartContract.Framework
dotnet add ./src/Neo.SmartContract.Template/bin/Debug/Nep17Contract.csproj reference ./src/Neo.SmartContract.Framework/Neo.SmartContract.Framework.csproj
dotnet ./src/Neo.Compiler.CSharp/bin/Debug/net7.0/nccs.dll -d ./src/Neo.SmartContract.Template/bin/Debug/Nep17Contract.csproj -o ./tests/Neo.SmartContract.Template.UnitTests/templates/neocontractnep17/Artifacts/ --generate-artifacts source
- name: Build Solution
run: dotnet build ./neo-devpack-dotnet.sln
- name: Check format
run: |
Expand All @@ -39,6 +50,17 @@ jobs:
run: |
dotnet test ./tests/Neo.SmartContract.Framework.UnitTests \
--no-build \
-l "console;verbosity=normal" \
-p:CollectCoverage=true \
-p:CoverletOutput=${GITHUB_WORKSPACE}/coverage/lcov \
-p:MergeWith=${GITHUB_WORKSPACE}/coverage/coverage.json \
-p:Exclude=\"[Neo.Compiler.CSharp.UnitTests]*\" \
-p:CoverletOutputFormat=lcov
- name: Test Neo.SmartContract.Template.UnitTests
run: |
dotnet test ./tests/Neo.SmartContract.Template.UnitTests \
--no-build \
-l "console;verbosity=detailed" \
-p:CollectCoverage=true \
-p:CoverletOutput=${GITHUB_WORKSPACE}/coverage/lcov \
-p:MergeWith=${GITHUB_WORKSPACE}/coverage/coverage.json \
Expand All @@ -64,7 +86,8 @@ jobs:
OPENAI_API_MODEL: "gpt-4" # Optional: defaults to "gpt-4"
exclude: "**/*.json, **/*.md" # Optional: exclude patterns separated by commas

PublishGithub:
PublishPackage:
if: github.ref == 'refs/heads/master' && startsWith(github.repository, 'neo-project/')
needs: Test
if: github.ref == 'refs/heads/master' && startsWith(github.repository, 'neo-project/')
runs-on: ubuntu-latest
Expand All @@ -79,18 +102,31 @@ jobs:
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Set 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 net7.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 }}
Expand All @@ -102,6 +138,14 @@ jobs:
--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:
needs: Test
Expand Down
65 changes: 62 additions & 3 deletions .github/workflows/pkgs-delete.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,69 @@
name: Nuget Package Cleanup (github)
name: Package Cleanup

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Run every day at 24:00

jobs:
delete-pkgs:
name: Delete Old Nuget Packages

delete-myget-pkgs:
name: Delete Old MyGet Packages
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install Requests
run: pip install requests
- name: Install Packaging
run: pip install packaging
- name: Delete versions below 3.6.1
env:
MYGET_FEED: 'neo'
PACKAGE_NAMES: 'Neo.SmartContract.Framework,Neo.SmartContract.Testing'
MYGET_API_KEY: ${{ secrets.MYGET_TOKEN }}
run: |
import requests
from packaging import version
import os
def get_versions(feed, package_name, api_key):
url = f"https://www.myget.org/F/{feed}/api/v2/Packages?$select=Version&$filter=Id eq '{package_name}'&$format=json"
headers = {'Accept': 'application/json'}
response = requests.get(url, headers=headers)
if response.status_code == 200:
versions = response.json()['d']['results']
return [ver['Version'] for ver in versions]
else:
return []
def delete_version(feed, package_name, ver, api_key):
url = f"https://www.myget.org/F/{feed}/api/v2/package/{package_name}/{ver}?hardDelete=true"
headers = {"X-NuGet-ApiKey": api_key}
response = requests.delete(url, headers=headers)
return response.status_code == 200 # Success
feed = os.environ['MYGET_FEED']
package_names = os.environ['PACKAGE_NAMES'].split(',')
api_key = os.environ['MYGET_API_KEY']
for package_name in package_names:
versions_to_delete = get_versions(feed, package_name, api_key)
for ver in versions_to_delete:
if version.parse(ver.split("-", 1)[0]) >= version.Version("3.6.1"):
print(f"Omited {ver} of package {package_name}.")
continue
if delete_version(feed, package_name, ver, api_key):
print(f"Deleted version {ver} of package {package_name}.")
else:
print(f"Failed to delete version {ver} of package {package_name}.")
shell: python

delete-git-pkgs:
name: Delete Old Github Packages
runs-on: ubuntu-latest

steps:
Expand All @@ -16,6 +73,7 @@ jobs:
package-name: Neo.SmartContract.Testing
package-type: nuget
min-versions-to-keep: 3
delete-only-pre-release-versions: "true"
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Delete Neo.SmartContract.Framework Package
Expand All @@ -24,4 +82,5 @@ jobs:
package-name: Neo.Neo.SmartContract.Framework
package-type: nuget
min-versions-to-keep: 3
delete-only-pre-release-versions: "true"
token: "${{ secrets.GITHUB_TOKEN }}"
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"dotnet.defaultSolution": "neo-devpack-dotnet.sln"
}
4 changes: 2 additions & 2 deletions NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<configuration>
<packageSources>
<clear />
<add key="github" value="https://nuget.pkg.github.com/neo-project/index.json" />
<add key="MyGet-neo" value="https://www.myget.org/F/neo/api/v3/index.json" />
<add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
</configuration>
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<p align="center">
<a href="https://neo.org/">
<img
src="https://neo3.azureedge.net/images/logo%20files-dark.svg"
<img src="https://neo3.azureedge.net/images/logo%20files-dark.svg"
width="250px" alt="neo-logo">
</a>
</p>
Expand Down
20 changes: 20 additions & 0 deletions neo-devpack-dotnet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.SmartContract.Testing",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.SmartContract.Testing.UnitTests", "tests\Neo.SmartContract.Testing.UnitTests\Neo.SmartContract.Testing.UnitTests.csproj", "{B772B8A9-9362-4C6F-A6D3-2A4138439B2C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.SmartContract.Template.UnitTests", "tests\Neo.SmartContract.Template.UnitTests\Neo.SmartContract.Template.UnitTests.csproj", "{17F45E0B-AB1C-4796-8C99-E5212A5592F8}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.Extensions", "neo\src\Neo.Extensions\Neo.Extensions.csproj", "{E5EFB018-810D-4297-8921-940FA0B1ED97}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.IO", "neo\src\Neo.IO\Neo.IO.csproj", "{C2B7927F-AAA5-432A-8E76-B5080BD7EFB9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -98,6 +103,18 @@ Global
{B772B8A9-9362-4C6F-A6D3-2A4138439B2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B772B8A9-9362-4C6F-A6D3-2A4138439B2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B772B8A9-9362-4C6F-A6D3-2A4138439B2C}.Release|Any CPU.Build.0 = Release|Any CPU
{17F45E0B-AB1C-4796-8C99-E5212A5592F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{17F45E0B-AB1C-4796-8C99-E5212A5592F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{17F45E0B-AB1C-4796-8C99-E5212A5592F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{17F45E0B-AB1C-4796-8C99-E5212A5592F8}.Release|Any CPU.Build.0 = Release|Any CPU
{E5EFB018-810D-4297-8921-940FA0B1ED97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E5EFB018-810D-4297-8921-940FA0B1ED97}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E5EFB018-810D-4297-8921-940FA0B1ED97}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E5EFB018-810D-4297-8921-940FA0B1ED97}.Release|Any CPU.Build.0 = Release|Any CPU
{C2B7927F-AAA5-432A-8E76-B5080BD7EFB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C2B7927F-AAA5-432A-8E76-B5080BD7EFB9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C2B7927F-AAA5-432A-8E76-B5080BD7EFB9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C2B7927F-AAA5-432A-8E76-B5080BD7EFB9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -117,6 +134,9 @@ Global
{D6D53889-5A10-46A4-BA66-E78B56EC1881} = {49D5873D-7B38-48A5-B853-85146F032091}
{648DCE6F-A0BA-4032-951B-20CF5BBFD998} = {79389FC0-C621-4CEA-AD2B-6074C32E7BCA}
{B772B8A9-9362-4C6F-A6D3-2A4138439B2C} = {D5266066-0AFD-44D5-A83E-2F73668A63C8}
{17F45E0B-AB1C-4796-8C99-E5212A5592F8} = {D5266066-0AFD-44D5-A83E-2F73668A63C8}
{E5EFB018-810D-4297-8921-940FA0B1ED97} = {49D5873D-7B38-48A5-B853-85146F032091}
{C2B7927F-AAA5-432A-8E76-B5080BD7EFB9} = {49D5873D-7B38-48A5-B853-85146F032091}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6DA935E1-C674-4364-B087-F1B511B79215}
Expand Down
7 changes: 7 additions & 0 deletions src/Neo.Compiler.CSharp/CompilationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@ public NefFile CreateExecutable()
Tokens = methodTokens.ToArray(),
Script = Script
};

if (nef.Compiler.Length > 64)
{
// Neo.Compiler.CSharp 3.6.2+470d9a8608b41de658849994a258200d8abf7caa
nef.Compiler = nef.Compiler.Substring(0, 61) + "...";
}

nef.CheckSum = NefFile.ComputeChecksum(nef);
// Ensure that is serializable
return nef.ToArray().AsSerializable<NefFile>();
Expand Down
Loading

0 comments on commit 98395a6

Please sign in to comment.