Skip to content

Commit 8c0934b

Browse files
Merge pull request #86 from linked-data-dotnet/support/1.x-from-master
Support/1.x from master
2 parents 95f7f9d + 83b110e commit 8c0934b

File tree

11 files changed

+179
-72
lines changed

11 files changed

+179
-72
lines changed

.github/stale.yml

+11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
11
# Number of days of inactivity before an issue becomes stale
22
daysUntilStale: 90
3+
34
# Number of days of inactivity before a stale issue is closed
45
daysUntilClose: 30
6+
57
# Issues with these labels will never be considered stale
68
exemptLabels:
79
- pinned
810
- security
911
- bug
12+
13+
# Set to true to ignore issues in a milestone (defaults to false)
14+
exemptMilestones: true
15+
16+
# Set to true to ignore issues with an assignee (defaults to false)
17+
exemptAssignees: true
18+
1019
# Label to use when marking an issue as stale
1120
staleLabel: stale
21+
1222
# Comment to post when marking an issue as stale. Set to `false` to disable
1323
markComment: >
1424
This issue has been automatically marked as stale because it has not had
1525
recent activity. After 30 days from now, it will be closed if no further
1626
activity occurs. Thank you for your contributions.
27+
1728
# Comment to post when closing a stale issue. Set to `false` to disable
1829
closeComment: false

.github/workflows/docker.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: docker
2+
3+
on:
4+
push:
5+
branches: [master]
6+
tags: ["*"]
7+
pull_request:
8+
branches: [master]
9+
10+
jobs:
11+
docker:
12+
name: build & run tests
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 0
18+
- name: docker build
19+
run: docker build -t json-ld.net .
20+
- name: docker test
21+
run: docker run --rm json-ld.net dotnet test

.github/workflows/dotnet.yml

+116-17
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,131 @@ name: dotnet
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
6+
tags: ["*"]
67
pull_request:
7-
branches: [ master ]
8+
branches: [master]
89

910
jobs:
1011
build:
1112
runs-on: ubuntu-latest
1213

14+
outputs:
15+
fullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}
16+
1317
steps:
14-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v2
19+
with:
20+
fetch-depth: 0
21+
22+
- uses: gittools/actions/gitversion/[email protected]
23+
with:
24+
versionSpec: "5.x"
25+
26+
- id: gitversion
27+
uses: gittools/actions/gitversion/[email protected]
28+
29+
- uses: actions/setup-dotnet@v1
30+
with:
31+
dotnet-version: 2.1.401
32+
33+
- uses: actions/cache@v2
34+
env:
35+
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
36+
with:
37+
path: ~/.nuget/packages
38+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
39+
restore-keys: ${{ runner.os }}-nuget-
40+
41+
- run: dotnet restore
1542

16-
- name: Setup .NET Core
17-
uses: actions/setup-dotnet@v1
18-
with:
19-
dotnet-version: 2.1.401
43+
- run: dotnet build --configuration Release --no-restore
2044

21-
- name: Install dependencies
22-
run: dotnet restore
45+
- run: |
46+
dotnet test \
47+
--configuration Release \
48+
--no-build \
49+
--no-restore \
50+
-p:CollectCoverage=true \
51+
-p:CoverletOutputFormat=opencover \
52+
-p:Exclude="[JsonLD.Test*]*"
2353
24-
- name: Build
25-
run: dotnet build --configuration Release --no-restore
54+
- name: Codecov
55+
env:
56+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
57+
run: bash <(curl -s https://codecov.io/bash)
58+
59+
- run: |
60+
dotnet pack \
61+
--include-source \
62+
--configuration Release \
63+
--no-build \
64+
--no-restore \
65+
-p:PackageVersion="${{ steps.gitversion.outputs.fullSemVer }}" \
66+
src/json-ld.net/json-ld.net.csproj \
67+
--output ${{ github.workspace }}/nugets/
68+
69+
- uses: actions/upload-artifact@v2
70+
with:
71+
name: nugets
72+
path: nugets
73+
74+
nuget-push-dev:
75+
runs-on: ubuntu-latest
76+
if: github.ref == 'refs/heads/master'
77+
needs: build
78+
79+
steps:
80+
- name: download artifact
81+
uses: actions/download-artifact@v2
82+
with:
83+
name: nugets
2684

27-
- name: Test
28-
run: dotnet test -c Release /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[JsonLD.Test*]*"
85+
- name: setup dotnet
86+
uses: actions/setup-dotnet@v1
87+
with:
88+
dotnet-version: 3.1
89+
source-url: https://nuget.pkg.github.com/linked-data-dotnet/index.json
90+
env:
91+
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
93+
- name: nuget push
94+
run: dotnet nuget push "*.nupkg" --skip-duplicate --api-key ${{ secrets.GITHUB_TOKEN }}
95+
96+
nuget-push-prod:
97+
runs-on: ubuntu-latest
98+
if: startsWith(github.ref, 'refs/tags/')
99+
needs: build
100+
101+
steps:
102+
- uses: actions/download-artifact@v2
103+
with:
104+
name: nugets
105+
106+
- uses: actions/setup-dotnet@v1
107+
with:
108+
dotnet-version: 2.1.401
109+
source-url: https://api.nuget.org/v3/index.json
110+
env:
111+
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_API_KEY }}
112+
113+
- run: dotnet nuget push nugets/*.nupkg --skip-duplicate
114+
115+
release-artifacts:
116+
runs-on: ubuntu-latest
117+
needs: build
118+
if: startsWith(github.ref, 'refs/tags/')
119+
120+
steps:
121+
- uses: actions/download-artifact@v1
122+
with:
123+
name: nugets
29124

30-
- name: Codecov
31-
env:
32-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
33-
run: bash <(curl -s https://codecov.io/bash)
125+
- name: Upload to stable release
126+
uses: svenstaro/upload-release-action@v1-release
127+
with:
128+
repo_token: ${{ secrets.GITHUB_TOKEN }}
129+
file: nugets
130+
asset_name: json-ld.net
131+
tag: ${{ github.ref }}
132+
overwrite: true

Dockerfile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# If you want to build and test under Linux using a docker container, here's how:
2+
#
3+
#> docker build -t json-ld.net .
4+
#> docker run --rm json-ld.net dotnet test -v normal
5+
6+
# .NET Core 2.1 on Ubuntu 18.04 LTS
7+
FROM mcr.microsoft.com/dotnet/core/sdk:2.1-bionic
8+
9+
WORKDIR /App
10+
11+
# First we ONLY copy sln and csproj files so that we don't have to re-cache
12+
# dotnet restore every time a .cs file changes
13+
COPY src/json-ld.net/json-ld.net.csproj src/json-ld.net/json-ld.net.csproj
14+
COPY test/json-ld.net.tests/json-ld.net.tests.csproj test/json-ld.net.tests/json-ld.net.tests.csproj
15+
COPY JsonLD.sln JsonLD.sln
16+
RUN dotnet restore
17+
18+
# Then we copy everything and run dotnet build
19+
COPY . .
20+
RUN dotnet build

src/json-ld.net/Core/Context.cs

-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ namespace JsonLD.Core
1414
/// <author>tristan</author>
1515
//[System.Serializable]
1616
public class Context : JObject
17-
#if !PORTABLE && !IS_CORECLR
18-
, ICloneable
19-
#endif
2017
{
2118
private JsonLdOptions options;
2219

src/json-ld.net/Core/JsonLdApi.cs

-4
Original file line numberDiff line numberDiff line change
@@ -2196,7 +2196,6 @@ public virtual RDFDataset ToRDF()
21962196
/// <exception cref="JsonLD.Core.JsonLdError"></exception>
21972197
public virtual object Normalize(RDFDataset dataset)
21982198
{
2199-
#if !PORTABLE
22002199
// create quads and map bnodes to their associated quads
22012200
IList<RDFDataset.Quad> quads = new List<RDFDataset.Quad>();
22022201
IDictionary<string,IDictionary<string,object>> bnodes = new Dictionary<string,IDictionary<string,object>>();
@@ -2247,9 +2246,6 @@ public virtual object Normalize(RDFDataset dataset)
22472246
NormalizeUtils normalizeUtils = new NormalizeUtils(quads, bnodes, new UniqueNamer
22482247
("_:c14n"), opts);
22492248
return normalizeUtils.HashBlankNodes(bnodes.Keys);
2250-
#else
2251-
throw new PlatformNotSupportedException();
2252-
#endif
22532249
}
22542250
}
22552251
}

src/json-ld.net/Core/JsonLdProcessor.cs

-8
Original file line numberDiff line numberDiff line change
@@ -487,24 +487,16 @@ public static object ToRDF(JToken input)
487487
/// <exception cref="JsonLDNet.Core.JsonLdError"></exception>
488488
public static object Normalize(JToken input, JsonLdOptions options)
489489
{
490-
#if !PORTABLE
491490
JsonLdOptions opts = options.Clone();
492491
opts.format = null;
493492
RDFDataset dataset = (RDFDataset)ToRDF(input, opts);
494493
return new JsonLdApi(options).Normalize(dataset);
495-
#else
496-
throw new PlatformNotSupportedException();
497-
#endif
498494
}
499495

500496
/// <exception cref="JsonLD.Core.JsonLdError"></exception>
501497
public static object Normalize(JToken input)
502498
{
503-
#if !PORTABLE
504499
return Normalize(input, new JsonLdOptions(string.Empty));
505-
#else
506-
throw new PlatformNotSupportedException();
507-
#endif
508500
}
509501
}
510502
}

src/json-ld.net/Core/NormalizeUtils.cs

-12
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public NormalizeUtils(IList<RDFDataset.Quad> quads, IDictionary<string, IDiction
2929
/// <exception cref="JsonLD.Core.JsonLdError"></exception>
3030
public virtual object HashBlankNodes(IEnumerable<string> unnamed_)
3131
{
32-
#if !PORTABLE
3332
IList<string> unnamed = new List<string>(unnamed_);
3433
IList<string> nextUnnamed = new List<string>();
3534
IDictionary<string, IList<string>> duplicates = new Dictionary<string, IList<string
@@ -203,9 +202,6 @@ public virtual object HashBlankNodes(IEnumerable<string> unnamed_)
203202
}
204203
}
205204
}
206-
#else
207-
throw new PlatformNotSupportedException();
208-
#endif
209205
}
210206

211207
private sealed class _IComparer_145 : IComparer<NormalizeUtils.HashResult>
@@ -245,7 +241,6 @@ private class HashResult
245241
/// <param name="callback">(err, result) called once the operation completes.</param>
246242
private static NormalizeUtils.HashResult HashPaths(string id, IDictionary<string, IDictionary<string, object>> bnodes, UniqueNamer namer, UniqueNamer pathNamer)
247243
{
248-
#if !PORTABLE
249244
MessageDigest md = null;
250245

251246
try
@@ -460,9 +455,6 @@ private static NormalizeUtils.HashResult HashPaths(string id, IDictionary<string
460455
{
461456
md?.Dispose();
462457
}
463-
#else
464-
throw new PlatformNotSupportedException();
465-
#endif
466458
}
467459

468460
/// <summary>Hashes all of the quads about a blank node.</summary>
@@ -500,7 +492,6 @@ private static string HashQuads(string id, IDictionary<string, IDictionary<strin
500492
/// <returns></returns>
501493
private static string Sha1hash(ICollection<string> nquads)
502494
{
503-
#if !PORTABLE
504495
try
505496
{
506497
// create SHA-1 digest
@@ -515,9 +506,6 @@ private static string Sha1hash(ICollection<string> nquads)
515506
{
516507
throw;
517508
}
518-
#else
519-
throw new PlatformNotSupportedException();
520-
#endif
521509
}
522510

523511
// TODO: this is something to optimize

src/json-ld.net/Util/JavaCompat.cs

-11
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
using System.Linq;
77
using System.Text;
88
using System.Text.RegularExpressions;
9-
10-
#if !PORTABLE
119
using System.Security.Cryptography;
12-
#endif
1310

1411
namespace JsonLD
1512
{
@@ -281,13 +278,7 @@ public Matcher Matcher(string str)
281278

282279
public string GetPattern()
283280
{
284-
#if !PORTABLE && !IS_CORECLR
285-
return this.pattern;
286-
#elif !PORTABLE
287281
return _rx;
288-
#else
289-
throw new PlatformNotSupportedException();
290-
#endif
291282
}
292283

293284
new public static bool Matches(string val, string rx)
@@ -357,7 +348,6 @@ public bool Find()
357348
}
358349

359350

360-
#if !PORTABLE
361351
internal class MessageDigest : IDisposable
362352
{
363353
SHA1 md;
@@ -392,5 +382,4 @@ public void Dispose()
392382
md.Dispose();
393383
}
394384
}
395-
#endif
396385
}

0 commit comments

Comments
 (0)