Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump dependency and test .NET 8.0 #27

Merged
merged 6 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS base

# Set up environment
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1

ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME;


# Install .NET Core 3.1 SDK
RUN wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
&& dpkg -i packages-microsoft-prod.deb \
&& apt-get update \
&& apt-get install -y apt-transport-https \
&& apt-get update \
&& apt-get install -y dotnet-sdk-3.1 \
&& rm -rf /var/lib/apt/lists/*

# Install .NET 5 SDK
RUN apt-get update \
&& apt-get install -y dotnet-sdk-8.0 \
&& rm -rf /var/lib/apt/lists/*

RUN apt update && apt install -y dirmngr ca-certificates gnupg && \
gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF && \
echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/debian stable-buster main" | tee /etc/apt/sources.list.d/mono-official-stable.list && \
apt update && apt install -y mono-complete ca-certificates-mono && \
rm -rf /var/lib/apt/lists/*



RUN cert-sync /etc/ssl/certs/ca-certificates.crt && \
mozroots --import --sync

USER vscode
ENTRYPOINT ["/bin/bash"]
19 changes: 19 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": ".NET 8",
"build": {
"dockerfile": "Dockerfile"
},
"customizations": {
"vscode": {
"extensions": [
"ms-dotnettools.csharp",
"GitHub.vscode-github-actions"
],
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
}
}
},
"postCreateCommand": "dotnet restore",
"remoteUser": "vscode"
}
104 changes: 74 additions & 30 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,32 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]

dotnet-target: ["3.1.x", "6.0.x", "8.0.x"]
exclude:
- os: macOS-latest
dotnet-target: "3.1.x"
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up dotnet
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.1.x
6.0.x
8.0.x
if: ${{ !startsWith(matrix.os, 'macOS') }}

- name: Set up dotnet macOS ARM
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
6.0.x
8.0.x
if: startsWith(matrix.os, 'macOS')

- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
Expand All @@ -46,21 +58,36 @@ jobs:
run: |
dotnet build --configuration Release --version-suffix "$GITHUB_RUN_ID-prerelease" --no-restore

- name: Run tests on mac and linux
if: ${{ !startsWith(matrix.os, 'windows') }}
env:
TINIFY_KEY: ${{ secrets.TINIFY_KEY }}
- name: Run tests (Linux and macOS)
if: runner.os != 'Windows'
run: |
dotnet test --configuration Release --no-build --verbosity normal --framework netcoreapp3.1 test/Tinify.Tests
dotnet test --configuration Release --no-build --verbosity normal --framework net5.0 test/Tinify.Tests
dotnet test --configuration Release --no-build --verbosity normal --framework net6.0 test/Tinify.Tests

- name: Run tests on windows
if: startsWith(matrix.os, 'windows')
if [ "${{ matrix.dotnet-target }}" == "3.1.x" ]; then
dotnet test --configuration Release --no-build --verbosity normal --framework netcoreapp3.1 test/Tinify.Tests
elif [ "${{ matrix.dotnet-target }}" == "6.0.x" ]; then
dotnet test --configuration Release --no-build --verbosity normal --framework net6.0 test/Tinify.Tests
elif [ "${{ matrix.dotnet-target }}" == "8.0.x" ]; then
dotnet test --configuration Release --no-build --verbosity normal --framework net8.0 test/Tinify.Tests
else
echo "Error: Unsupported .NET version ${{ matrix.dotnet-target }}" && exit 1
fi
- name: Run tests (Windows)
if: runner.os == 'Windows'
env:
TINIFY_KEY: ${{ secrets.TINIFY_KEY }}
run: |
dotnet test --configuration Release --no-build --verbosity normal --framework net6.0 test/Tinify.Tests
if ("${{ matrix.dotnet-target }}" -eq "3.1.x") {
dotnet test --configuration Release --no-build --verbosity normal --framework netcoreapp3.1 test/Tinify.Tests
} elseif ("${{ matrix.dotnet-target }}" -eq "5.0.x") {
dotnet test --configuration Release --no-build --verbosity normal --framework net5.0 test/Tinify.Tests
} elseif ("${{ matrix.dotnet-target }}" -eq "6.0.x") {
dotnet test --configuration Release --no-build --verbosity normal --framework net6.0 test/Tinify.Tests
} elseif ("${{ matrix.dotnet-target }}" -eq "8.0.x") {
dotnet test --configuration Release --no-build --verbosity normal --framework net8.0 test/Tinify.Tests
} else {
Write-Error "Unsupported .NET version $env:MATRIX_DOTNET_VERSION"
exit 1
}


integrationTests:
if: github.event_name == 'push'
Expand All @@ -72,19 +99,20 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]

dotnet-version: [3.1.x, 8.0.x]
exclude:
- os: macOS-latest
dotnet-version: 3.1.x
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up dotnet
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.1.x
6.0.x
dotnet-version: ${{ matrix.dotnet-version }}

- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
Expand All @@ -104,15 +132,31 @@ jobs:
env:
TINIFY_KEY: ${{ secrets.TINIFY_KEY }}
run: |
dotnet test --configuration Release --no-build --verbosity normal --framework netcoreapp3.1 test/Tinify.Tests.Integration
dotnet test --configuration Release --no-build --verbosity normal --framework net6.0 test/Tinify.Tests.Integration
if [ ${{ matrix.dotnet-version }} == "3.1.x" ]; then
dotnet test --configuration Release --no-build --verbosity normal --framework netcoreapp3.1 test/Tinify.Tests.Integration
elif [ ${{ matrix.dotnet-version }} == "6.0.x" ]; then
dotnet test --configuration Release --no-build --verbosity normal --framework net6.0 test/Tinify.Tests.Integration
else
dotnet test --configuration Release --no-build --verbosity normal --framework net8.0 test/Tinify.Tests.Integration
fi

- name: Run tests on windows
if: startsWith(matrix.os, 'windows')
env:
TINIFY_KEY: ${{ secrets.TINIFY_KEY }}
run: |
dotnet test --configuration Release --no-build --verbosity normal --framework net6.0 test/Tinify.Tests.Integration
if ("${{ matrix.dotnet-version }}" -eq "6.0.x") {
dotnet test --configuration Release --no-build --verbosity normal --framework net6.0 test/Tinify.Tests.Integration
} elseif ("${{ matrix.dotnet-version }}" -eq "3.1.x") {
dotnet test --configuration Release --no-build --verbosity normal --framework netcoreapp3.1 test/Tinify.Tests.Integration
} elseif ("${{ matrix.dotnet-version }}" -eq "8.0.x") {
dotnet test --configuration Release --no-build --verbosity normal --framework net8.0 test/Tinify.Tests.Integration
} else {
Write-Error "Unsupported .NET version $env:MATRIX_DOTNET_VERSION"
exit 1
}



publish:
if: |
Expand All @@ -124,12 +168,12 @@ jobs:
- "integrationTests"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up dotnet
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x

Expand Down
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.7.0
* Added .NET 8 as test target
* Dropped .NET 6
* Added tests for macOS ARM
* Bumped System.Text.Json to 8.0.4

## 1.6.0
* Increased TargetFramework to netstandard2.0
* Tinify client is now tested on
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

[![MIT License](http://img.shields.io/badge/license-MIT-green.svg) ](https://github.com/tinify/tinify-python/blob/main/LICENSE)
[![CI_CD](https://github.com/tinify/tinify-net/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/tinify/tinify-net/actions/workflows/ci-cd.yml)
[![Nuget](https://img.shields.io/nuget/v/Tinify)](https://www.nuget.org/packages/Tinify)
Expand Down
4 changes: 2 additions & 2 deletions src/Tinify/Tinify.csproj
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>.NET client for the Tinify API. Tinify compresses your images intelligently. Read more at https://tinify.com.</Description>
<AssemblyTitle>Tinify</AssemblyTitle>
<VersionPrefix>1.6.0</VersionPrefix>
<VersionPrefix>1.7.0</VersionPrefix>
<Authors>Tinify</Authors>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Tinify</AssemblyName>
Expand Down Expand Up @@ -41,7 +41,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="6.0.5" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>

</Project>
12 changes: 7 additions & 5 deletions test/Tinify.Tests.Integration/Integration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public void Should_PreserveMetadata()
{
using (var file = new TempFile())
{
var options = new[] {"copyright", "location"};
var options = new[] {"location", "copyright"};
optimized.Preserve(options).ToFile(file.Path).Wait();

var size = new FileInfo(file.Path).Length;
Expand All @@ -220,7 +220,8 @@ public void Should_PreserveMetadata()

/* width == 137 */
Assert.AreEqual(137, metaData.GetImageWidth());
Assert.IsTrue(metaData.ContainsStringInXmpData(VoormediaCopyright));
bool containsCopyright = File.ReadAllText(file.Path).Contains(VoormediaCopyright);
Assert.IsTrue(containsCopyright, "The file should contain the copyright string.");
}
}

Expand All @@ -229,19 +230,20 @@ public void Should_Resize_And_PreserveMetadata()
{
using var file = new TempFile();
var resizeOptions = new { method = "fit", width = 50, height = 20 };
var preserveOptions = new[] { "copyright", "location" };
var preserveOptions = new[] { "location", "copyright" };
optimized.Resize(resizeOptions).Preserve(preserveOptions).ToFile(file.Path).Wait();

var size = new FileInfo(file.Path).Length;
Assert.Greater(size, 500);
Assert.Less(size, 1100);
Assert.Less(size, 1150);

var metaData = new ImageMetadata(file.Path);
Assert.That(metaData.IsPng);

/* width == 50 */
Assert.AreEqual(50, metaData.GetImageWidth());
Assert.IsTrue(metaData.ContainsStringInXmpData(VoormediaCopyright));
bool containsCopyright = File.ReadAllText(file.Path).Contains(VoormediaCopyright);
Assert.IsTrue(containsCopyright, "The file should contain the copyright string.");
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<TargetFrameworks>net462;net472;net48;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>net462;net472;net48;netcoreapp3.1;net6.0;net8.0</TargetFrameworks>
<AssemblyName>Tinify.Tests.Integration</AssemblyName>
<PackageId>Tinify.Tests.Integration</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
Expand Down
2 changes: 1 addition & 1 deletion test/Tinify.Tests/Tinify.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<TargetFrameworks>net462;net472;net48;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>net462;net472;net48;netcoreapp3.1;net6.0;net8.0</TargetFrameworks>
<AssemblyName>Tinify.Tests</AssemblyName>
<PackageId>Tinify.Tests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
Expand Down
Loading