Skip to content

Commit

Permalink
Appveyor cake to ghaction (#165)
Browse files Browse the repository at this point in the history
* Replace AppVeyor/Cake with Github Action workflow
* Generate snupkg instead of legacy symbols packages
* Fix GetSessionHistory_AuthenticatedUserV2_Succeeds test
* Remove useless xUnit customization
* Change copyright to 2021
  • Loading branch information
gpailler authored Mar 16, 2021
1 parent 3e9aa50 commit ab1745f
Show file tree
Hide file tree
Showing 14 changed files with 165 additions and 520 deletions.
147 changes: 147 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: MegaApiClient CI

on:
push:
branches-ignore:
- gh-pages
pull_request:
branches:
- master
workflow_dispatch:

env:
CONFIGURATION: Release

jobs:
build:
name: Build and Pack ⚙️
runs-on: windows-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
with:
fetch-depth: 0 # Full history is required by GitVersion

- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'

- name: Run GitVersion
id: gitversion
uses: gittools/actions/gitversion/[email protected]
with:
updateAssemblyInfo: true
updateAssemblyInfoFilename: './GlobalAssemblyInfo.cs'

- name: Build
run: dotnet build --configuration ${{ env.CONFIGURATION }} ./MegaApiClient/

- name: Create NuGet package
run: dotnet pack --configuration ${{ env.CONFIGURATION }} ./MegaApiClient/ --no-restore --no-build --output ./artifacts/ -p:PackageVersion=${{ env.GITVERSION_NUGETVERSION }} --include-symbols -p:SymbolPackageFormat=snupkg

- name: Upload NuGet packages
uses: actions/upload-artifact@v2
with:
name: NuGet packages
path: ./artifacts/*.*nupkg
if-no-files-found: error

test:
name: Test 🧪
timeout-minutes: 60
runs-on: windows-latest
steps:
- name: Concurrent test execution check
uses: softprops/turnstyle@v1
with:
same-branch-only: false
abort-after-seconds: 1800
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Check out repository code
uses: actions/checkout@v2

- name: Tests
run: dotnet test --configuration ${{ env.CONFIGURATION }} ./MegaApiClient.Tests/ --framework net46 --logger "console;verbosity=detailed" -p:CollectCoverage=true -p:CoverletOutputFormat=opencover -p:Exclude="[MegaApiClient]BigInteger"
env:
MEGAAPICLIENT_PASSWORD: ${{ secrets.MEGAAPICLIENT_PASSWORD }}

- name: Codecov
uses: codecov/codecov-action@v1

doc:
name: Documentation 📚
runs-on: windows-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2

- name: Install DocFX
run: nuget install docfx.console -Version 2.56.7

- name: Build documentation
run: |
./docfx.console.2.56.7/tools/docfx.exe metadata ./docs/docfx.json
./docfx.console.2.56.7/tools/docfx.exe build ./docs/docfx.json
- name: Upload Documentation
uses: actions/upload-artifact@v2
with:
name: Documentation
path: ./docs/_site/
if-no-files-found: error

deploy:
name: Deploy 🚀
needs: [ build, test, doc]
runs-on: windows-latest
steps:
- name: Download NuGet packages
uses: actions/download-artifact@v2
with:
name: NuGet packages
path: ./artifacts/

- name: Publish on MyGet
run: |
cd ./artifacts/
dotnet nuget push *.nupkg --skip-duplicate --source https://www.myget.org/F/megaapiclient/api/v3/index.json --api-key ${{ secrets.MYGET_SECRET }}
deploy-release:
name: Deploy release 🚀🌐
needs: [ build, test, doc ]
runs-on: windows-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download NuGet packages
uses: actions/download-artifact@v2
with:
name: NuGet packages
path: ./artifacts/

- name: Download Documentation
uses: actions/download-artifact@v2
with:
name: Documentation
path: ./docs/_site/

- name: Publish on NuGet
run: |
cd ./artifacts/
dotnet nuget push *.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_SECRET }}
- name: Publish Documentation
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: ./docs/_site/

- name: Create Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ./artifacts/*.nupkg
draft: true
6 changes: 1 addition & 5 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
mode: ContinuousDelivery
branches: {}
ignore:
sha: []
merge-message-formats: {}
mode: ContinuousDeployment
4 changes: 3 additions & 1 deletion MegaApiClient.Tests/DownloadUpload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

namespace CG.Web.MegaApiClient.Tests
{
using xRetry;

public abstract class DownloadUpload : TestsBase
{
protected readonly Random random = new Random();
Expand Down Expand Up @@ -155,7 +157,7 @@ public void DownloadLink_ToStream_Succeeds()
}
}

[Fact]
[RetryFact(3)]
public void Download_ValidateStream_Succeeds()
{
using (Stream stream = this.context.Client.Download(new Uri(AuthenticatedTestContext.FileLink)))
Expand Down
4 changes: 2 additions & 2 deletions MegaApiClient.Tests/Login.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ public void GetSessionHistory_AuthenticatedUserV2_Succeeds(string email, string
ISession first = sessionsHistory.First();
Assert.NotNull(first);
Assert.Equal(SessionStatus.Current | SessionStatus.Active, first.Status);
Assert.Equal(DateTime.UtcNow, first.LoginTime, TimeSpan.FromSeconds(30));
Assert.Equal(DateTime.UtcNow, first.LastSeenTime, TimeSpan.FromSeconds(30));
Assert.Equal(DateTime.UtcNow, first.LoginTime.ToUniversalTime(), TimeSpan.FromSeconds(30));
Assert.Equal(DateTime.UtcNow, first.LastSeenTime.ToUniversalTime(), TimeSpan.FromSeconds(30));
}

[Fact]
Expand Down
9 changes: 9 additions & 0 deletions MegaApiClient.Tests/MegaApiClient.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,19 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.0.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="3.0.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Moq" Version="4.10.1" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
<PackageReference Include="Polly-Signed" Version="5.9.0" />
<PackageReference Include="xRetry" Version="1.4.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta3-build3705" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
Expand Down
28 changes: 0 additions & 28 deletions MegaApiClient.Tests/XUnitExtensibility.cs

This file was deleted.

5 changes: 2 additions & 3 deletions MegaApiClient.Tests/xunit.runner.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
"shadowCopy": false,
"parallelizeTestCollections": false,
"diagnosticMessages": true,
"maxParallelThreads": 1
"parallelizeTestCollections": false
}
2 changes: 1 addition & 1 deletion MegaApiClient/MegaApiClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>MegaApiClient is a C# .Net library to access http://mega.co.nz / http://mega.nz cloud storage and file hosting service.</Description>
<Copyright>Copyright © 2020</Copyright>
<Copyright>Copyright © 2021</Copyright>
<AssemblyTitle>Mega.co.nz client library</AssemblyTitle>
<NeutralLanguage>en-US</NeutralLanguage>
<VersionPrefix>1.0.0</VersionPrefix>
Expand Down
60 changes: 0 additions & 60 deletions appveyor.yml

This file was deleted.

Loading

0 comments on commit ab1745f

Please sign in to comment.