Skip to content

Commit cf864ac

Browse files
committed
Introduce justfile
1 parent 3fe94a8 commit cf864ac

7 files changed

Lines changed: 285 additions & 227 deletions

File tree

.github/workflows/checks.yml

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,10 @@ jobs:
1717
uses: actions/setup-dotnet@v3
1818
with:
1919
dotnet-version: 8.0.x
20-
21-
- name: Restore Tools
22-
run: dotnet tool restore
23-
24-
- name: Check if line endings are CRLF
25-
run: |
26-
bash -c "git grep -rlIP -- ':!GraphvizWrapper/graphvizfiles/*' ':!*.sh' | xargs unix2dos"
27-
git diff --exit-code
28-
29-
- name: Check if README is up-to-date
30-
run: git diff --exit-code -- README.md
31-
32-
- name: Check if code is formatted
33-
run: dotnet format whitespace --verify-no-changes -v diag Rubjerg.Graphviz.sln
20+
21+
- name: Setup Just
22+
uses: extractions/setup-just@v3
3423

35-
- name: Check if code is formatted
36-
run: dotnet format whitespace --verify-no-changes -v diag Rubjerg.Graphviz.Tests.sln
37-
38-
- name: Check for loose ends
39-
run: |
40-
bash -c "! git grep 'FIX''NOW'"
24+
- name: Run static checks
25+
shell: bash
26+
run: just check-all

.github/workflows/ci-pack.yml

Lines changed: 77 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,77 @@
1-
# .github/workflows/ci-pack.yml
2-
name: CI-Pack
3-
4-
on:
5-
push: { branches: [ master ] }
6-
pull_request: { branches: [ master ] }
7-
release: { types: [published] } # runs on “Publish release” button
8-
workflow_dispatch: # lets you run it by hand
9-
10-
jobs:
11-
win-build:
12-
uses: ./.github/workflows/win-build.yml
13-
14-
linux-build:
15-
uses: ./.github/workflows/linux-build.yml
16-
17-
pack:
18-
needs: [win-build, linux-build] # ← the two workflow_call jobs
19-
runs-on: windows-latest
20-
21-
steps:
22-
- uses: actions/checkout@v4
23-
24-
# 1) bring the two per-OS packages into this job --------------------
25-
- uses: actions/download-artifact@v4
26-
with: { name: win-bits, path: artifacts/win }
27-
- uses: actions/download-artifact@v4
28-
with: { name: linux-bits, path: artifacts/linux }
29-
30-
# 2) unzip → merge → zip ------------------------------------------
31-
- name: Merge NuGet packages
32-
id: merge
33-
shell: pwsh
34-
run: |
35-
# locate both nupkgs (Rubjerg.Graphviz.<ver>.nupkg)
36-
$winPkg = Get-ChildItem artifacts/win -Filter *.nupkg | Select -First 1
37-
$linuxPkg = Get-ChildItem artifacts/linux -Filter *.nupkg | Select -First 1
38-
if (-not $winPkg -or -not $linuxPkg) { throw "Packages missing" }
39-
40-
# extract <id> and <version> from the file name
41-
if ($winPkg.Name -notmatch '^(.+?)\.(\d+\.\d+\.\d+(?:-[A-Za-z0-9\.-]+)?)\.nupkg$') {
42-
throw "Unexpected package file name $($winPkg.Name)"
43-
}
44-
$id = $Matches[1] # Rubjerg.Graphviz
45-
$version = $Matches[2] # 2.0.2 (or 2.0.2-beta etc.)
46-
47-
$stage = "stage"
48-
Remove-Item $stage -Recurse -Force -ErrorAction SilentlyContinue
49-
New-Item -ItemType Directory -Path $stage | Out-Null
50-
51-
Expand-Archive $winPkg.FullName -DestinationPath $stage -Force
52-
Expand-Archive $linuxPkg.FullName -DestinationPath $stage -Force
53-
54-
$outFile = "$id.$version.nupkg"
55-
Compress-Archive "$stage\*" $outFile -Force
56-
57-
# expose the path for later steps
58-
"outfile=$outFile" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
59-
60-
# 3) upload the merged package as a build artefact ------------------
61-
- name: Upload final package as artefact
62-
uses: actions/upload-artifact@v4
63-
with:
64-
name: merged-nupkg
65-
path: ${{ steps.merge.outputs.outfile }}
66-
retention-days: 30
67-
68-
# 4) push to NuGet only on a GitHub Release -------------------------
69-
# - name: Push to NuGet.org
70-
# if: github.event_name == 'release'
71-
# env:
72-
# NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
73-
# run: |
74-
# nuget push "${{ steps.merge.outputs.outfile }}" `
75-
# -Source https://api.nuget.org/v3/index.json `
76-
# -ApiKey $env:NUGET_API_KEY
77-
1+
# .github/workflows/ci-pack.yml
2+
name: CI-Pack
3+
4+
on:
5+
push: { branches: [ master ] }
6+
pull_request: { branches: [ master ] }
7+
release: { types: [published] } # runs on “Publish release” button
8+
workflow_dispatch: # lets you run it by hand
9+
10+
jobs:
11+
win-build:
12+
uses: ./.github/workflows/win-build.yml
13+
14+
linux-build:
15+
uses: ./.github/workflows/linux-build.yml
16+
17+
pack:
18+
needs: [win-build, linux-build] # ← the two workflow_call jobs
19+
runs-on: windows-latest
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
# 1) bring the two per-OS packages into this job --------------------
25+
- uses: actions/download-artifact@v4
26+
with: { name: win-bits, path: artifacts/win }
27+
- uses: actions/download-artifact@v4
28+
with: { name: linux-bits, path: artifacts/linux }
29+
30+
# 2) unzip → merge → zip ------------------------------------------
31+
- name: Merge NuGet packages
32+
id: merge
33+
shell: pwsh
34+
run: |
35+
# locate both nupkgs (Rubjerg.Graphviz.<ver>.nupkg)
36+
$winPkg = Get-ChildItem artifacts/win -Filter *.nupkg | Select -First 1
37+
$linuxPkg = Get-ChildItem artifacts/linux -Filter *.nupkg | Select -First 1
38+
if (-not $winPkg -or -not $linuxPkg) { throw "Packages missing" }
39+
40+
# extract <id> and <version> from the file name
41+
if ($winPkg.Name -notmatch '^(.+?)\.(\d+\.\d+\.\d+(?:-[A-Za-z0-9\.-]+)?)\.nupkg$') {
42+
throw "Unexpected package file name $($winPkg.Name)"
43+
}
44+
$id = $Matches[1] # Rubjerg.Graphviz
45+
$version = $Matches[2] # 2.0.2 (or 2.0.2-beta etc.)
46+
47+
$stage = "stage"
48+
Remove-Item $stage -Recurse -Force -ErrorAction SilentlyContinue
49+
New-Item -ItemType Directory -Path $stage | Out-Null
50+
51+
Expand-Archive $winPkg.FullName -DestinationPath $stage -Force
52+
Expand-Archive $linuxPkg.FullName -DestinationPath $stage -Force
53+
54+
$outFile = "$id.$version.nupkg"
55+
Compress-Archive "$stage\*" $outFile -Force
56+
57+
# expose the path for later steps
58+
"outfile=$outFile" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
59+
60+
# 3) upload the merged package as a build artefact ------------------
61+
- name: Upload final package as artefact
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: merged-nupkg
65+
path: ${{ steps.merge.outputs.outfile }}
66+
retention-days: 30
67+
68+
# 4) push to NuGet only on a GitHub Release -------------------------
69+
# - name: Push to NuGet.org
70+
# if: github.event_name == 'release'
71+
# env:
72+
# NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
73+
# run: |
74+
# nuget push "${{ steps.merge.outputs.outfile }}" `
75+
# -Source https://api.nuget.org/v3/index.json `
76+
# -ApiKey $env:NUGET_API_KEY
77+

.github/workflows/linux-build.yml

Lines changed: 70 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,70 @@
1-
name: linux-build
2-
3-
on:
4-
workflow_call:
5-
outputs:
6-
artifact-name:
7-
description: "Linux bits"
8-
value: linux-bits
9-
10-
jobs:
11-
build:
12-
runs-on: ubuntu-latest
13-
14-
steps:
15-
- uses: actions/checkout@v1
16-
name: Checkout Code
17-
18-
# Necessary for running neato
19-
- name: Install libgts
20-
run: sudo apt-get update && sudo apt-get install -y libgts-0.7-5
21-
22-
- name: Setup .NET
23-
uses: actions/setup-dotnet@v3
24-
with:
25-
dotnet-version: 8.0.x
26-
27-
- name: Restore Tools
28-
run: dotnet tool restore
29-
30-
- name: Restore NuGet Packages
31-
run: dotnet restore Rubjerg.Graphviz.sln
32-
33-
- name: Print PWD
34-
run: pwd
35-
36-
- name: Build App
37-
run: dotnet build Rubjerg.Graphviz.sln --configuration Release --no-restore
38-
39-
- name: Build App Another Time because dot net sucks and cannot see the native dependencies the first time
40-
run: dotnet build Rubjerg.Graphviz.sln --configuration Release --no-restore
41-
42-
- name: Debug Intermediate Output
43-
run: ls -la /home/runner/work/Graphviz.NetWrapper/Graphviz.NetWrapper/Rubjerg.Graphviz/Resources
44-
45-
- name: Debug Build Output
46-
run: ls -la /home/runner/work/Graphviz.NetWrapper/Graphviz.NetWrapper/Rubjerg.Graphviz/bin/x64/Release/netstandard2.0/
47-
48-
- name: Restore (just built) NuGet Packages for Tests
49-
run: dotnet restore Rubjerg.Graphviz.Tests.sln
50-
51-
- name: Build Tests
52-
run: dotnet build Rubjerg.Graphviz.Tests.sln --configuration Release --no-restore
53-
54-
- name: Debug Test Build Output
55-
run: ls -la /home/runner/work/Graphviz.NetWrapper/Graphviz.NetWrapper/Rubjerg.Graphviz.Test/bin/x64/Release/net8.0/
56-
57-
- name: Run Unittests
58-
run: bash run-tests-netcore.sh Rubjerg.Graphviz.Test/Rubjerg.Graphviz.Test.csproj
59-
60-
- name: Run Transitive Tests
61-
run: bash run-tests-netcore.sh Rubjerg.Graphviz.TransitiveTest/Rubjerg.Graphviz.TransitiveTest.csproj
62-
63-
- name: Locate nupkg
64-
id: pkg
65-
run: |
66-
pkg=$(find . -name "Rubjerg.Graphviz.*.nupkg" | head -1)
67-
echo "package=$pkg" >> "$GITHUB_OUTPUT"
68-
69-
- uses: actions/upload-artifact@v4
70-
with:
71-
name: linux-bits
72-
path: ${{ steps.pkg.outputs.package }}
73-
retention-days: 3
1+
name: linux-build
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
artifact-name:
7+
description: "Linux bits"
8+
value: linux-bits
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v1
16+
name: Checkout Code
17+
18+
# Necessary for running neato
19+
- name: Install libgts
20+
run: sudo apt-get update && sudo apt-get install -y libgts-0.7-5
21+
22+
- name: Setup .NET
23+
uses: actions/setup-dotnet@v3
24+
with:
25+
dotnet-version: 8.0.x
26+
27+
- name: Restore Tools
28+
run: dotnet tool restore
29+
30+
- name: Restore NuGet Packages
31+
run: dotnet restore Rubjerg.Graphviz.sln
32+
33+
- name: Print PWD
34+
run: pwd
35+
36+
- name: Build App
37+
run: dotnet build Rubjerg.Graphviz.sln --configuration Release --no-restore
38+
39+
- name: Build App Another Time because dot net sucks and cannot see the native dependencies the first time
40+
run: dotnet build Rubjerg.Graphviz.sln --configuration Release --no-restore
41+
42+
- name: Debug Intermediate Output
43+
run: ls -la /home/runner/work/Graphviz.NetWrapper/Graphviz.NetWrapper/Rubjerg.Graphviz/Resources
44+
45+
- name: Debug Build Output
46+
run: ls -la /home/runner/work/Graphviz.NetWrapper/Graphviz.NetWrapper/Rubjerg.Graphviz/bin/x64/Release/netstandard2.0/
47+
48+
- name: Restore (just built) NuGet Packages for Tests
49+
run: dotnet restore Rubjerg.Graphviz.Tests.sln
50+
51+
- name: Build Tests
52+
run: dotnet build Rubjerg.Graphviz.Tests.sln --configuration Release --no-restore
53+
54+
- name: Run Unittests
55+
run: bash run-tests-netcore.sh Rubjerg.Graphviz.Test/Rubjerg.Graphviz.Test.csproj
56+
57+
- name: Run Transitive Tests
58+
run: bash run-tests-netcore.sh Rubjerg.Graphviz.TransitiveTest/Rubjerg.Graphviz.TransitiveTest.csproj
59+
60+
- name: Locate nupkg
61+
id: pkg
62+
run: |
63+
pkg=$(find . -name "Rubjerg.Graphviz.*.nupkg" | head -1)
64+
echo "package=$pkg" >> "$GITHUB_OUTPUT"
65+
66+
- uses: actions/upload-artifact@v4
67+
with:
68+
name: linux-bits
69+
path: ${{ steps.pkg.outputs.package }}
70+
retention-days: 3

NugetOrgTests/nuget.config

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<configuration>
3-
<packageSources>
4-
<clear /> <!-- This clears inherited sources -->
5-
<!-- public packages -->
6-
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
7-
</packageSources>
8-
9-
<packageSourceMapping>
10-
<packageSource key="nuget.org">
11-
<package pattern="Rubjerg.*" />
12-
<package pattern="*" />
13-
</packageSource>
14-
</packageSourceMapping>
15-
</configuration>
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<clear /> <!-- This clears inherited sources -->
5+
<!-- public packages -->
6+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
7+
</packageSources>
8+
9+
<packageSourceMapping>
10+
<packageSource key="nuget.org">
11+
<package pattern="Rubjerg.*" />
12+
<package pattern="*" />
13+
</packageSource>
14+
</packageSourceMapping>
15+
</configuration>

Rubjerg.Graphviz/Constants.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
using System;
2-
using System.Runtime.InteropServices;
3-
4-
namespace Rubjerg.Graphviz;
5-
6-
internal static class Constants
7-
{
8-
#if _WINDOWS
9-
public const string GvcLib = "gvc.dll";
10-
public const string CGraphLib = "cgraph.dll";
11-
public const string XDotLib = "xdot.dll";
12-
public const string GraphvizWrapperLib = "GraphvizWrapper.dll";
13-
#else
14-
public const string GvcLib = "libgvc.so.6";
15-
public const string CGraphLib = "libcgraph.so.6";
16-
public const string XDotLib = "libxdot.so.4";
17-
public const string GraphvizWrapperLib = "libGraphvizWrapper.so";
18-
#endif
19-
}
1+
using System;
2+
using System.Runtime.InteropServices;
3+
4+
namespace Rubjerg.Graphviz;
5+
6+
internal static class Constants
7+
{
8+
#if _WINDOWS
9+
public const string GvcLib = "gvc.dll";
10+
public const string CGraphLib = "cgraph.dll";
11+
public const string XDotLib = "xdot.dll";
12+
public const string GraphvizWrapperLib = "GraphvizWrapper.dll";
13+
#else
14+
public const string GvcLib = "libgvc.so.6";
15+
public const string CGraphLib = "libcgraph.so.6";
16+
public const string XDotLib = "libxdot.so.4";
17+
public const string GraphvizWrapperLib = "libGraphvizWrapper.so";
18+
#endif
19+
}

0 commit comments

Comments
 (0)