Skip to content

Commit 5dc11ca

Browse files
Merge pull request #3 from stefannikolei/sn/build
Add Github Action
2 parents 6080495 + 12d478d commit 5dc11ca

File tree

5 files changed

+252
-0
lines changed

5 files changed

+252
-0
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
types: [ labeled, opened, synchronize, reopened ]
11+
jobs:
12+
Build:
13+
strategy:
14+
matrix: options:
15+
- os: ubuntu-latest
16+
framework: net9.0
17+
sdk: 9.0.x
18+
sdk-preview: true
19+
runtime: -x64
20+
codecov: false
21+
- os: macos-latest # macos-latest runs on arm64 runners where libgdiplus is unavailable
22+
framework: net9.0
23+
sdk: 9.0.x
24+
sdk-preview: true
25+
runtime: -x64
26+
codecov: false
27+
- os: windows-latest
28+
framework: net9.0
29+
sdk: 9.0.x
30+
sdk-preview: true
31+
runtime: -x64
32+
codecov: false
33+
34+
- os: ubuntu-latest
35+
framework: net8.0
36+
sdk: 8.0.x
37+
runtime: -x64
38+
codecov: false
39+
- os: macos-latest # macos-latest runs on arm64 runners where libgdiplus is unavailable
40+
framework: net8.0
41+
sdk: 8.0.x
42+
runtime: -x64
43+
codecov: false
44+
- os: windows-latest
45+
framework: net8.0
46+
sdk: 8.0.x
47+
runtime: -x64
48+
codecov: false
49+
50+
runs-on: ${{matrix.options.os}}
51+
52+
steps:
53+
- name: Git Config
54+
shell: bash
55+
run: |
56+
git config --global core.autocrlf false
57+
git config --global core.longpaths true
58+
59+
- name: Git Checkout
60+
uses: actions/checkout@v4
61+
with:
62+
fetch-depth: 0
63+
submodules: recursive
64+
65+
- name: NuGet Install
66+
uses: NuGet/setup-nuget@v2
67+
68+
- name: NuGet Setup Cache
69+
uses: actions/cache@v4
70+
id: nuget-cache
71+
with:
72+
path: ~/.nuget
73+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props', '**/*.targets') }}
74+
restore-keys: ${{ runner.os }}-nuget-
75+
76+
- name: DotNet Setup
77+
if: ${{ matrix.options.sdk-preview != true }}
78+
uses: actions/setup-dotnet@v4
79+
with:
80+
dotnet-version: |
81+
8.0.x
82+
83+
- name: DotNet Setup Preview
84+
if: ${{ matrix.options.sdk-preview == true }}
85+
uses: actions/setup-dotnet@v4
86+
with:
87+
dotnet-version: |
88+
9.0.x
89+
90+
- name: DotNet Build
91+
if: ${{ matrix.options.sdk-preview != true }}
92+
shell: pwsh
93+
run: ./ci-build.ps1 "${{matrix.options.framework}}"
94+
env:
95+
SIXLABORS_TESTING: True
96+
97+
- name: DotNet Build Preview
98+
if: ${{ matrix.options.sdk-preview == true }}
99+
shell: pwsh
100+
run: ./ci-build.ps1 "${{matrix.options.framework}}"
101+
env:
102+
SIXLABORS_TESTING_PREVIEW: True
103+
104+
- name: DotNet Test
105+
if: ${{ matrix.options.sdk-preview != true }}
106+
shell: pwsh
107+
run: ./ci-test.ps1 "${{matrix.options.os}}" "${{matrix.options.framework}}" "${{matrix.options.runtime}}" "${{matrix.options.codecov}}"
108+
env:
109+
SIXLABORS_TESTING: True
110+
XUNIT_PATH: .\tests\ImageSharp.Tests # Required for xunit
111+
112+
- name: DotNet Test Preview
113+
if: ${{ matrix.options.sdk-preview == true }}
114+
shell: pwsh
115+
run: ./ci-test.ps1 "${{matrix.options.os}}" "${{matrix.options.framework}}" "${{matrix.options.runtime}}" "${{matrix.options.codecov}}"
116+
env:
117+
SIXLABORS_TESTING_PREVIEW: True
118+
XUNIT_PATH: .\tests\PolygonClipper.Tests # Required for xunit
119+
120+
- name: Export Failed Output
121+
uses: actions/upload-artifact@v4
122+
if: failure()
123+
with:
124+
name: actual_output_${{ runner.os }}_${{ matrix.options.framework }}${{ matrix.options.runtime }}.zip
125+
path: tests/Images/ActualOutput/
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: CodeCoverage
2+
3+
on:
4+
schedule:
5+
# 2AM every Tuesday/Thursday
6+
- cron: "0 2 * * 2,4"
7+
jobs:
8+
Build:
9+
strategy:
10+
matrix:
11+
options:
12+
- os: ubuntu-latest
13+
framework: net8.0
14+
runtime: -x64
15+
codecov: true
16+
17+
runs-on: ${{matrix.options.os}}
18+
19+
steps:
20+
- name: Git Config
21+
shell: bash
22+
run: |
23+
git config --global core.autocrlf false
24+
git config --global core.longpaths true
25+
26+
- name: Git Checkout
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
submodules: recursive
31+
32+
- name: NuGet Install
33+
uses: NuGet/setup-nuget@v2
34+
35+
- name: NuGet Setup Cache
36+
uses: actions/cache@v4
37+
id: nuget-cache
38+
with:
39+
path: ~/.nuget
40+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props', '**/*.targets') }}
41+
restore-keys: ${{ runner.os }}-nuget-
42+
43+
- name: DotNet Setup
44+
uses: actions/setup-dotnet@v4
45+
with:
46+
dotnet-version: |
47+
8.0.x
48+
49+
- name: DotNet Build
50+
shell: pwsh
51+
run: ./ci-build.ps1 "${{matrix.options.framework}}"
52+
env:
53+
SIXLABORS_TESTING: True
54+
55+
- name: DotNet Test
56+
shell: pwsh
57+
run: ./ci-test.ps1 "${{matrix.options.os}}" "${{matrix.options.framework}}" "${{matrix.options.runtime}}" "${{matrix.options.codecov}}"
58+
env:
59+
SIXLABORS_TESTING: True
60+
XUNIT_PATH: .\tests\PolygonClipper.Tests # Required for xunit
61+
62+
- name: Export Failed Output
63+
uses: actions/upload-artifact@v4
64+
if: failure()
65+
with:
66+
name: actual_output_${{ runner.os }}_${{ matrix.options.framework }}${{ matrix.options.runtime }}.zip
67+
path: tests/Images/ActualOutput/
68+
69+
- name: Codecov Update
70+
uses: codecov/codecov-action@v4
71+
if: matrix.options.codecov == true && startsWith(github.repository, 'SixLabors')
72+
with:
73+
flags: unittests

ci-build.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
param(
2+
[Parameter(Mandatory = $true, Position = 0)]
3+
[string]$targetFramework
4+
)
5+
6+
dotnet clean -c Release
7+
8+
$repositoryUrl = "https://github.com/$env:GITHUB_REPOSITORY"
9+
10+
# Building for a specific framework.
11+
dotnet build -c Release -f $targetFramework /p:RepositoryUrl=$repositoryUrl

ci-test.ps1

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
param(
2+
[Parameter(Mandatory, Position = 0)]
3+
[string]$os,
4+
[Parameter(Mandatory, Position = 1)]
5+
[string]$targetFramework,
6+
[Parameter(Mandatory, Position = 2)]
7+
[string]$platform,
8+
[Parameter(Mandatory, Position = 3)]
9+
[string]$codecov,
10+
[Parameter(Position = 4)]
11+
[string]$codecovProfile = 'Release'
12+
)
13+
14+
$netFxRegex = '^net\d+'
15+
16+
if ($codecov -eq 'true') {
17+
18+
# Allow toggling of profile to workaround any potential JIT errors caused by code injection.
19+
dotnet clean -c $codecovProfile
20+
dotnet test --collect "XPlat Code Coverage" --settings .\tests\coverlet.runsettings -c $codecovProfile -f $targetFramework /p:CodeCov=true
21+
}
22+
elseif ($platform -eq '-x86' -and $targetFramework -match $netFxRegex) {
23+
24+
# xunit doesn't run on core with NET SDK 3.1+.
25+
# xunit doesn't actually understand -x64 as an option.
26+
#
27+
# xunit requires explicit path.
28+
Set-Location $env:XUNIT_PATH
29+
30+
dotnet xunit --no-build -c Release -f $targetFramework ${fxVersion} $platform
31+
32+
Set-Location $PSScriptRoot
33+
}
34+
else {
35+
36+
dotnet test --no-build -c Release -f $targetFramework --blame --diag .tests\Images\ActualOutput\diaglog.txt
37+
}

0 commit comments

Comments
 (0)