Skip to content

Commit 543e61a

Browse files
authored
Merge branch 'master' into feat/zis-updated-iter
2 parents 80e4ec7 + bdec777 commit 543e61a

File tree

83 files changed

+4763
-2995
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+4763
-2995
lines changed

.github/workflows/build-test.yml

Lines changed: 76 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: Build and Test
22

33
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: 'Tag Ref'
8+
required: true
49
pull_request:
510
branches: [ master ]
611
push:
@@ -9,24 +14,30 @@ on:
914

1015
jobs:
1116
Build:
12-
runs-on: ${{ matrix.os }}-latest
17+
runs-on: ${{ matrix.os }}
1318
strategy:
1419
fail-fast: false
1520
matrix:
16-
os: [ubuntu, windows, macos]
21+
os: [ubuntu-latest, windows-2019, macos-latest]
1722
target: [netstandard2.0, netstandard2.1]
1823
include:
19-
- os: windows
24+
- os: windows-2019
2025
target: net45
2126
env:
2227
LIB_PROJ: src/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj
2328
steps:
2429
- uses: actions/checkout@v2
25-
30+
with:
31+
ref: ${{ github.events.inputs.tag }}
32+
fetch-depth: 0
33+
2634
- name: Setup .NET Core
2735
uses: actions/setup-dotnet@v1
2836
with:
2937
dotnet-version: '3.1.x'
38+
39+
- name: Show .NET info
40+
run: dotnet --info
3041

3142
- name: Build library (Debug)
3243
run: dotnet build -c debug -f ${{ matrix.target }} ${{ env.LIB_PROJ }}
@@ -39,47 +50,77 @@ jobs:
3950
strategy:
4051
fail-fast: false
4152
matrix:
42-
os: [ubuntu, windows, macos]
53+
# Windows testing is combined with code coverage
54+
os: [ubuntu, macos]
4355
target: [netcoreapp3.1]
44-
include:
45-
- os: windows
46-
target: net46
4756
steps:
4857
- uses: actions/checkout@v2
49-
58+
with:
59+
fetch-depth: 0
60+
5061
- name: Setup .NET Core
5162
if: matrix.target == 'netcoreapp3.1'
5263
uses: actions/setup-dotnet@v1
5364
with:
5465
dotnet-version: '3.1.x'
5566

56-
# NOTE: This is the temporary fix for https://github.com/actions/virtual-environments/issues/1090
57-
- name: Cleanup before restore
58-
if: ${{ matrix.os == 'windows' }}
59-
run: dotnet clean ICSharpCode.SharpZipLib.sln && dotnet nuget locals all --clear
60-
6167
- name: Restore test dependencies
6268
run: dotnet restore
6369

6470
- name: Run tests (Debug)
6571
run: dotnet test -c debug -f ${{ matrix.target }} --no-restore
6672

6773
- name: Run tests (Release)
68-
# Only upload code coverage for windows in an attempt to fix the broken code coverage
69-
if: ${{ matrix.os == 'windows' }}
70-
run: dotnet test -c release -f ${{ matrix.target }} --no-restore --collect="XPlat Code Coverage"
71-
72-
- name: Run tests with coverage (Release)
73-
# Only upload code coverage for windows in an attempt to fix the broken code coverage
74-
if: ${{ matrix.os != 'windows' }}
7574
run: dotnet test -c release -f ${{ matrix.target }} --no-restore
7675

76+
77+
CodeCov:
78+
name: Code Coverage
79+
runs-on: windows-2019
80+
env:
81+
DOTCOVER_VER: 2021.1.2
82+
DOTCOVER_PKG: jetbrains.dotcover.commandlinetools
83+
COVER_SNAPSHOT: SharpZipLib.dcvr
84+
steps:
85+
- uses: actions/checkout@v2
86+
with:
87+
fetch-depth: 0
88+
89+
- name: Setup .NET
90+
uses: actions/setup-dotnet@v1
91+
with:
92+
dotnet-version: '3.1.x'
93+
94+
# NOTE: This is the temporary fix for https://github.com/actions/virtual-environments/issues/1090
95+
- name: Cleanup before restore
96+
run: dotnet clean ICSharpCode.SharpZipLib.sln && dotnet nuget locals all --clear
97+
98+
- name: Install codecov
99+
run: nuget install -o tools -version ${{env.DOTCOVER_VER}} ${{env.DOTCOVER_PKG}}
100+
101+
- name: Add dotcover to path
102+
run: echo "$(pwd)\tools\${{env.DOTCOVER_PKG}}.${{env.DOTCOVER_VER}}\tools" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
103+
104+
- name: Run tests with code coverage
105+
run: dotcover dotnet --output=${{env.COVER_SNAPSHOT}} --filters=-:ICSharpCode.SharpZipLib.Tests -- test -c release
106+
107+
- name: Create code coverage report
108+
run: dotcover report --source=${{env.COVER_SNAPSHOT}} --reporttype=detailedxml --output=dotcover-report.xml
109+
77110
- name: Upload coverage to Codecov
78111
uses: codecov/[email protected]
112+
with:
113+
files: dotcover-report.xml
114+
115+
- name: Upload coverage snapshot artifact
116+
uses: actions/upload-artifact@v2
117+
with:
118+
name: Code coverage snapshot
119+
path: ${{env.COVER_SNAPSHOT}}
79120

80121
Pack:
81-
needs: [Build, Test]
82-
runs-on: windows-latest
122+
needs: [Build, Test, CodeCov]
123+
runs-on: windows-2019
83124
env:
84125
PKG_SUFFIX: ''
85126
PKG_PROJ: src/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj
@@ -88,6 +129,7 @@ jobs:
88129
steps:
89130
- uses: actions/checkout@v2
90131
with:
132+
ref: ${{ github.events.inputs.tag }}
91133
fetch-depth: 0
92134

93135
- name: Setup .NET Core
@@ -106,8 +148,18 @@ jobs:
106148
if: ${{ github.event_name == 'pull_request' }}
107149
run: echo "PKG_SUFFIX=-PR" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
108150

151+
- name: Set package version
152+
continue-on-error: true
153+
run: |-
154+
$PKG_GIT_VERSION="$(git describe --tags --abbrev | % { $_.substring(1) })"
155+
Write-Output "::notice::Git describe: $PKG_GIT_VERSION"
156+
Write-Output "::notice::Package suffix: $env:PKG_SUFFIX"
157+
$PKG_VERSION = "${PKG_GIT_VERSION}${env:PKG_SUFFIX}"
158+
Write-Output "::notice::Package version: $PKG_VERSION"
159+
Write-Output "PKG_VERSION=$PKG_VERSION" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
160+
109161
- name: Create nuget package
110-
run: dotnet pack ${{ env.PKG_PROJ }} -c Release --output dist ${{ env.PKG_PROPS }} /p:Version=$(git describe --abbrev | % { $_.substring(1) })${{ env.PKG_SUFFIX }}
162+
run: dotnet pack ${{ env.PKG_PROJ }} -c Release --output dist ${{ env.PKG_PROPS }} /p:Version=${{ env.PKG_VERSION }}
111163

112164
- name: Upload nuget package artifact
113165
uses: actions/upload-artifact@v2
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ master ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ master ]
20+
schedule:
21+
- cron: '40 7 * * 4'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'csharp' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
37+
# Learn more:
38+
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
39+
40+
steps:
41+
- name: Checkout repository
42+
uses: actions/checkout@v2
43+
44+
# Initializes the CodeQL tools for scanning.
45+
- name: Initialize CodeQL
46+
uses: github/codeql-action/init@v1
47+
with:
48+
languages: ${{ matrix.language }}
49+
# If you wish to specify custom queries, you can do so here or in a config file.
50+
# By default, queries listed here will override any specified in a config file.
51+
# Prefix the list here with "+" to use these queries and those in the config file.
52+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
53+
54+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55+
# If this step fails, then you should remove it and run the build manually (see below)
56+
- name: Autobuild
57+
uses: github/codeql-action/autobuild@v1
58+
59+
# ℹ️ Command-line programs to run using the OS shell.
60+
# 📚 https://git.io/JvXDl
61+
62+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
63+
# and modify them (or add more) to build your code if your project
64+
# uses a compiled language
65+
66+
#- run: |
67+
# make bootstrap
68+
# make release
69+
70+
- name: Perform CodeQL Analysis
71+
uses: github/codeql-action/analyze@v1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,4 @@ paket-files/
253253
/test/ICSharpCode.SharpZipLib.TestBootstrapper/Properties/launchSettings.json
254254
_testRunner/
255255
docs/help/api/.manifest
256+
/benchmark/ICSharpCode.SharpZipLib.Benchmark/BenchmarkDotNet.Artifacts/results

ICSharpCode.SharpZipLib.sln

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ICSharpCode.SharpZipLib", "
1515
EndProject
1616
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ICSharpCode.SharpZipLib.Tests", "test\ICSharpCode.SharpZipLib.Tests\ICSharpCode.SharpZipLib.Tests.csproj", "{82211166-9C45-4603-8E3A-2CA2EFFCBC26}"
1717
EndProject
18-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ICSharpCode.SharpZipLib.TestBootstrapper", "test\ICSharpCode.SharpZipLib.TestBootstrapper\ICSharpCode.SharpZipLib.TestBootstrapper.csproj", "{535D7365-C5B1-4253-9233-D72D972CA851}"
19-
EndProject
2018
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ICSharpCode.SharpZipLib.Benchmark", "benchmark\ICSharpCode.SharpZipLib.Benchmark\ICSharpCode.SharpZipLib.Benchmark.csproj", "{C51E638B-DDD0-48B6-A6BD-EBC4E6A104C7}"
2119
EndProject
2220
Global
@@ -33,10 +31,6 @@ Global
3331
{82211166-9C45-4603-8E3A-2CA2EFFCBC26}.Debug|Any CPU.Build.0 = Debug|Any CPU
3432
{82211166-9C45-4603-8E3A-2CA2EFFCBC26}.Release|Any CPU.ActiveCfg = Release|Any CPU
3533
{82211166-9C45-4603-8E3A-2CA2EFFCBC26}.Release|Any CPU.Build.0 = Release|Any CPU
36-
{535D7365-C5B1-4253-9233-D72D972CA851}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37-
{535D7365-C5B1-4253-9233-D72D972CA851}.Debug|Any CPU.Build.0 = Debug|Any CPU
38-
{535D7365-C5B1-4253-9233-D72D972CA851}.Release|Any CPU.ActiveCfg = Release|Any CPU
39-
{535D7365-C5B1-4253-9233-D72D972CA851}.Release|Any CPU.Build.0 = Release|Any CPU
4034
{C51E638B-DDD0-48B6-A6BD-EBC4E6A104C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
4135
{C51E638B-DDD0-48B6-A6BD-EBC4E6A104C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
4236
{C51E638B-DDD0-48B6-A6BD-EBC4E6A104C7}.Release|Any CPU.ActiveCfg = Release|Any CPU

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SharpZipLib [![Build Status](https://github.com/icsharpcode/SharpZipLib/actions/workflows/build-test.yml/badge.svg?branch=master)](https://github.com/icsharpcode/SharpZipLib/actions/workflows/build-test.yml) [![NuGet Version](https://img.shields.io/nuget/v/SharpZipLib.svg)](https://www.nuget.org/packages/SharpZipLib/)
1+
# SharpZipLib [![Build Status](https://github.com/icsharpcode/SharpZipLib/actions/workflows/build-test.yml/badge.svg?branch=master)](https://github.com/icsharpcode/SharpZipLib/actions/workflows/build-test.yml) [![NuGet Version](https://img.shields.io/nuget/v/SharpZipLib.svg)](https://www.nuget.org/packages/SharpZipLib/) [![openupm](https://img.shields.io/npm/v/org.icsharpcode.sharpziplib?label=openupm&registry_uri=https://package.openupm.com)](https://openupm.com/packages/org.icsharpcode.sharpziplib/)
22

33
Introduction
44
------------

SECURITY.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
| Version | Supported |
66
| ------- | ------------------ |
77
| 1.3.x | :white_check_mark: |
8-
| 1.2.x | :white_check_mark: |
9-
| 1.1.x | :white_check_mark: |
10-
| 1.0.x | :white_check_mark: |
11-
| < 1.0 | :x: |
8+
| < 1.3 | :x: |
129

1310
## Reporting a Vulnerability
1411

benchmark/ICSharpCode.SharpZipLib.Benchmark/Program.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
2-
using BenchmarkDotNet;
3-
using BenchmarkDotNet.Configs;
1+
using BenchmarkDotNet.Configs;
42
using BenchmarkDotNet.Jobs;
53
using BenchmarkDotNet.Running;
64
using BenchmarkDotNet.Toolchains.CsProj;
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
using System;
2+
using System.IO;
3+
using System.Security.Cryptography;
4+
using System.Text;
5+
using System.Threading;
6+
using System.Threading.Tasks;
7+
using BenchmarkDotNet.Attributes;
8+
using ICSharpCode.SharpZipLib.Tar;
9+
10+
namespace ICSharpCode.SharpZipLib.Benchmark.Tar
11+
{
12+
[MemoryDiagnoser]
13+
[Config(typeof(MultipleRuntimes))]
14+
public class TarInputStream
15+
{
16+
private readonly byte[] archivedData;
17+
private readonly byte[] readBuffer = new byte[1024];
18+
19+
public TarInputStream()
20+
{
21+
using (var outputMemoryStream = new MemoryStream())
22+
{
23+
using (var zipOutputStream =
24+
new ICSharpCode.SharpZipLib.Tar.TarOutputStream(outputMemoryStream, Encoding.UTF8))
25+
{
26+
var tarEntry = TarEntry.CreateTarEntry("some file");
27+
tarEntry.Size = 1024 * 1024;
28+
zipOutputStream.PutNextEntry(tarEntry);
29+
30+
var rng = RandomNumberGenerator.Create();
31+
var inputBuffer = new byte[1024];
32+
rng.GetBytes(inputBuffer);
33+
34+
for (int i = 0; i < 1024; i++)
35+
{
36+
zipOutputStream.Write(inputBuffer, 0, inputBuffer.Length);
37+
}
38+
}
39+
40+
archivedData = outputMemoryStream.ToArray();
41+
}
42+
}
43+
44+
[Benchmark]
45+
public long ReadTarInputStream()
46+
{
47+
using (var memoryStream = new MemoryStream(archivedData))
48+
using (var zipInputStream = new ICSharpCode.SharpZipLib.Tar.TarInputStream(memoryStream, Encoding.UTF8))
49+
{
50+
var entry = zipInputStream.GetNextEntry();
51+
52+
while (zipInputStream.Read(readBuffer, 0, readBuffer.Length) > 0)
53+
{
54+
}
55+
56+
return entry.Size;
57+
}
58+
}
59+
60+
[Benchmark]
61+
public async Task<long> ReadTarInputStreamAsync()
62+
{
63+
using (var memoryStream = new MemoryStream(archivedData))
64+
using (var zipInputStream = new ICSharpCode.SharpZipLib.Tar.TarInputStream(memoryStream, Encoding.UTF8))
65+
{
66+
var entry = await zipInputStream.GetNextEntryAsync(CancellationToken.None);
67+
68+
#if NETCOREAPP2_1_OR_GREATER
69+
while (await zipInputStream.ReadAsync(readBuffer.AsMemory()) > 0)
70+
{
71+
}
72+
#else
73+
while (await zipInputStream.ReadAsync(readBuffer, 0, readBuffer.Length) > 0)
74+
{
75+
}
76+
#endif
77+
78+
return entry.Size;
79+
}
80+
}
81+
}
82+
}

0 commit comments

Comments
 (0)