Skip to content

Commit 41bee84

Browse files
committed
Merge branch 'upload-refactor' of https://github.com/managedcode/Storage into upload-refactor
2 parents 1a5fb6f + 5c6834c commit 41bee84

File tree

13 files changed

+300
-93
lines changed

13 files changed

+300
-93
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ jobs:
3535

3636
steps:
3737
- name: Checkout repository
38-
uses: actions/checkout@v2
38+
uses: actions/checkout@v4
3939

4040
# Initializes the CodeQL tools for scanning.
4141
- name: Initialize CodeQL
42-
uses: github/codeql-action/init@v1
42+
uses: github/codeql-action/init@v2
4343
with:
4444
languages: ${{ matrix.language }}
4545
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -50,7 +50,7 @@ jobs:
5050
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5151
# If this step fails, then you should remove it and run the build manually (see below)
5252
- name: Autobuild
53-
uses: github/codeql-action/autobuild@v1
53+
uses: github/codeql-action/autobuild@v2
5454

5555
# ℹ️ Command-line programs to run using the OS shell.
5656
# 📚 https://git.io/JvXDl
@@ -64,4 +64,4 @@ jobs:
6464
# make release
6565

6666
- name: Perform CodeQL Analysis
67-
uses: github/codeql-action/analyze@v1
67+
uses: github/codeql-action/analyze@v2

.github/workflows/dotnet.yml

Lines changed: 32 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,59 +5,45 @@ on:
55
branches: [ main ]
66
pull_request:
77
branches: [ main ]
8-
98

10-
# Allows you to run this workflow manually from the Actions tab
119
workflow_dispatch:
1210

1311
jobs:
1412

1513
build-and-test:
1614
runs-on: ubuntu-latest
17-
15+
1816
steps:
1917

20-
- name: checkout
21-
uses: actions/checkout@v3
22-
23-
- name: Setup .NET
24-
uses: actions/setup-dotnet@v3
25-
with:
26-
dotnet-version: 7.0.x
27-
28-
- name: Restore dependencies
29-
run: dotnet restore
30-
31-
- name: Build
32-
run: dotnet build --no-restore
33-
34-
- name: Test
35-
run: dotnet test --no-build --logger 'trx;LogFileName=test-results.trx'
36-
37-
- name: Collect Code Coverage
38-
run: dotnet test --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=ManagedCode.Storage.Tests/lcov.info
39-
40-
41-
- name: NDepend
42-
uses: ndepend/ndepend-action@v1
43-
with:
44-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45-
license: ${{ secrets.NDEPENDLICENSE }}
46-
coveragefolder: ManagedCode.Storage.Tests/lcov.info
47-
baseline: recent
48-
#baseline: main_recent
49-
50-
- name : coverlet
51-
uses: b3b00/coverlet-action@1.1.9
52-
with:
53-
testProject: 'ManagedCode.Storage.Tests/ManagedCode.Storage.Tests.csproj'
54-
output: 'lcov.info'
55-
outputFormat: 'lcov'
56-
excludes: '[program]*,[test]test.*'
57-
- name: coveralls
58-
uses: coverallsapp/github-action@master
59-
with:
60-
github-token: ${{secrets.GITHUB_TOKEN }}
61-
path-to-lcov: ManagedCode.Storage.Tests/lcov.info
62-
18+
- name: checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Setup .NET
22+
uses: actions/setup-dotnet@v3
23+
with:
24+
dotnet-version: 7.0.x
25+
26+
- name: Restore dependencies
27+
run: dotnet restore
28+
29+
- name: Build
30+
run: dotnet build
31+
32+
- name: Test
33+
run: dotnet test /p:CollectCoverage=true /p:CoverletOutput=coverage /p:CoverletOutputFormat=opencover
34+
35+
36+
- name: NDepend
37+
uses: ndepend/ndepend-action@v1
38+
with:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
license: ${{ secrets.NDEPENDLICENSE }}
41+
coveragefolder: ${{ github.workspace }}/ManagedCode.Storage.IntegrationTests
42+
baseline: main_recent
43+
retention-days: 15
44+
#stopIfQGFailed: true
6345

46+
- name: Upload coverage reports to Codecov
47+
uses: codecov/codecov-action@v3
48+
env:
49+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/nuget.yml

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
name: nuget
1+
# name: nuget
22

3-
on:
4-
push:
5-
branches: [ main ]
3+
# on:
4+
# push:
5+
# branches: [ main ]
66

7-
# Allows you to run this workflow manually from the Actions tab
8-
workflow_dispatch:
7+
# # Allows you to run this workflow manually from the Actions tab
8+
# workflow_dispatch:
99

10-
jobs:
11-
nuget-pack:
10+
# jobs:
11+
# nuget-pack:
1212

13-
runs-on: ubuntu-latest
13+
# runs-on: ubuntu-latest
1414

15-
steps:
16-
- uses: actions/checkout@v3
17-
- name: Setup .NET
18-
uses: actions/setup-dotnet@v3
19-
with:
20-
dotnet-version: 7.0.x
15+
# steps:
16+
# - uses: actions/checkout@v3
17+
# - name: Setup .NET
18+
# uses: actions/setup-dotnet@v3
19+
# with:
20+
# dotnet-version: 7.0.x
2121

22-
- name: Restore dependencies
23-
run: dotnet restore
24-
- name: Build
25-
run: dotnet build --configuration Release
26-
- name: Pack
27-
run: dotnet pack -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --configuration Release
22+
# - name: Restore dependencies
23+
# run: dotnet restore
24+
# - name: Build
25+
# run: dotnet build --configuration Release
26+
# - name: Pack
27+
# run: dotnet pack -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --configuration Release
2828

29-
- name: publish nuget packages
30-
run: |
31-
shopt -s globstar
32-
for file in **/*.nupkg
33-
do
34-
dotnet nuget push "$file" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols
35-
done
29+
# - name: publish nuget packages
30+
# run: |
31+
# shopt -s globstar
32+
# for file in **/*.nupkg
33+
# do
34+
# dotnet nuget push "$file" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols
35+
# done

ManagedCode.Storage.Aws/ManagedCode.Storage.Aws.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<ItemGroup>
2525
<PackageReference Include="ManagedCode.Communication" Version="2.0.26" />
26-
<PackageReference Include="AWSSDK.S3" Version="3.7.205.10" />
26+
<PackageReference Include="AWSSDK.S3" Version="3.7.205.14" />
2727
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
2828
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
2929
<PackageReference Include="System.Linq.Async" Version="6.0.1" />

ManagedCode.Storage.Azure/BlobStream.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,19 @@ public override long Length
3737
{
3838
get
3939
{
40-
var realLength = 0L;
41-
var metadata = _pageBlob.GetProperties().Value.Metadata;
40+
var properties = _pageBlob.GetProperties();
41+
var metadata = properties.Value.Metadata;
4242
if (metadata.TryGetValue(MetadataLengthKey, out var length))
4343
{
44-
if (long.TryParse(length, out realLength))
44+
if (long.TryParse(length, out var realLength))
4545
{
4646
return realLength;
4747
}
4848
}
49-
50-
SetLengthInternal(realLength);
51-
return realLength;
49+
50+
var contentLenght = properties.Value.ContentLength;
51+
SetLengthInternal(contentLenght);
52+
return contentLenght;
5253
}
5354
}
5455

ManagedCode.Storage.Azure/ManagedCode.Storage.Azure.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</ItemGroup>
2323

2424
<ItemGroup>
25-
<PackageReference Include="Azure.Identity" Version="1.10.2" />
25+
<PackageReference Include="Azure.Identity" Version="1.10.3" />
2626
<PackageReference Include="Azure.Storage.Files.DataLake" Version="12.16.0" />
2727
<PackageReference Include="ManagedCode.Communication" Version="2.0.26" />
2828
<PackageReference Include="Azure.Storage.Blobs" Version="12.18.0" />

ManagedCode.Storage.Google/ManagedCode.Storage.Google.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<ItemGroup>
2525
<PackageReference Include="Google.Api.Gax" Version="4.4.0" />
2626
<PackageReference Include="Google.Api.Gax.Rest" Version="4.4.0" />
27-
<PackageReference Include="Google.Apis.Storage.v1" Version="1.62.1.3190" />
27+
<PackageReference Include="Google.Apis.Storage.v1" Version="1.62.1.3206" />
2828
<PackageReference Include="Google.Cloud.Storage.V1" Version="4.6.0" />
2929
<PackageReference Include="ManagedCode.Communication" Version="2.0.26" />
3030
<PackageReference Include="Humanizer.Core" Version="2.14.1" />

ManagedCode.Storage.IntegrationTests/ManagedCode.Storage.IntegrationTests.csproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,22 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12+
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
13+
<PrivateAssets>all</PrivateAssets>
14+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
15+
</PackageReference>
1216
<PackageReference Include="FluentAssertions" Version="6.12.0" />
1317
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.12" />
1418
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="7.0.12" />
1519
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="7.0.12" />
16-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
20+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
1721
<PackageReference Include="Testcontainers.Azurite" Version="3.5.0" />
18-
<PackageReference Include="xunit" Version="2.4.2" />
19-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
22+
<PackageReference Include="xunit" Version="2.5.3" />
23+
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
2024
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2125
<PrivateAssets>all</PrivateAssets>
2226
</PackageReference>
23-
<PackageReference Include="coverlet.collector" Version="3.1.2">
27+
<PackageReference Include="coverlet.collector" Version="6.0.0">
2428
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2529
<PrivateAssets>all</PrivateAssets>
2630
</PackageReference>

ManagedCode.Storage.Tests/Common/FileHelper.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,34 @@ public static LocalFile GenerateLocalFile(string fileName, int byteSize)
2525
return localFile;
2626
}
2727

28+
public static LocalFile GenerateLocalFileWithData(LocalFile file, int sizeInBytes)
29+
{
30+
using (var fileStream = file.FileStream)
31+
{
32+
Random random = new Random();
33+
byte[] buffer = new byte[1024]; // Buffer for writing in chunks
34+
35+
while (sizeInBytes > 0)
36+
{
37+
int bytesToWrite = (int) Math.Min(sizeInBytes, buffer.Length);
38+
39+
for (int i = 0; i < bytesToWrite; i++)
40+
{
41+
buffer[i] = (byte) random.Next(65, 91); // 'A' to 'Z'
42+
if (random.Next(2) == 0)
43+
{
44+
buffer[i] = (byte) random.Next(97, 123); // 'a' to 'z'
45+
}
46+
}
47+
48+
fileStream.Write(buffer, 0, bytesToWrite);
49+
sizeInBytes -= bytesToWrite;
50+
}
51+
}
52+
53+
return file;
54+
}
55+
2856
public static IFormFile GenerateFormFile(string fileName, int byteSize)
2957
{
3058
var localFile = GenerateLocalFile(fileName, byteSize);

ManagedCode.Storage.Tests/ManagedCode.Storage.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<PackageReference Include="Testcontainers" Version="3.5.0" />
3232
<PackageReference Include="Testcontainers.Azurite" Version="3.5.0" />
3333
<PackageReference Include="Testcontainers.LocalStack" Version="3.5.0" />
34-
<PackageReference Include="xunit" Version="2.5.2" />
34+
<PackageReference Include="xunit" Version="2.5.3" />
3535
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
3636
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3737
<PrivateAssets>all</PrivateAssets>

0 commit comments

Comments
 (0)