Skip to content

Commit

Permalink
Merge pull request #1 from byCrookie/feature/docker-tests
Browse files Browse the repository at this point in the history
start integration tests
  • Loading branch information
byCrookie authored Dec 9, 2023
2 parents b7947ea + c34a9ca commit f6e8a60
Show file tree
Hide file tree
Showing 320 changed files with 753 additions and 332 deletions.
31 changes: 8 additions & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ jobs:

- name: Restore
run: dotnet restore
working-directory: ./GithubBackup

- name: Build
run: dotnet build GithubBackup.sln --configuration Release --no-restore
working-directory: ./GithubBackup

- name: Get Version
id: nerbank_gitversioning
Expand Down Expand Up @@ -56,35 +54,30 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: Restore
run: dotnet restore
working-directory: ./GithubBackup

- name: Build
run: dotnet build GithubBackup.sln --configuration Release --no-restore
working-directory: ./GithubBackup

- name: Test
run: dotnet test GithubBackup.sln --configuration Release --no-restore
working-directory: ./GithubBackup

- name: Publish
run: dotnet publish GithubBackup.Cli/GithubBackup.Cli.csproj --configuration Release --output publish/win-x64 --runtime win-x64 --self-contained
working-directory: ./GithubBackup

- name: Zip
run: Compress-Archive -Path ./publish/win-x64/* -DestinationPath ./publish/ghb_win_x64_${{ needs.release.outputs.version }}.zip
working-directory: ./GithubBackup

- name: Upload Release Assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ./GithubBackup/publish/ghb_win_x64_${{ needs.release.outputs.version }}.zip
asset_path: ./publish/ghb_win_x64_${{ needs.release.outputs.version }}.zip
asset_name: ghb_win_x64_${{ needs.release.outputs.version }}.zip
asset_content_type: application/zip

Expand All @@ -99,35 +92,31 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: Restore
run: dotnet restore
working-directory: ./GithubBackup

- name: Build
run: dotnet build GithubBackup.sln --configuration Release --no-restore
working-directory: ./GithubBackup

- name: Test
run: dotnet test GithubBackup.sln --configuration Release --no-restore
working-directory: ./GithubBackup

- name: Publish
run: dotnet publish GithubBackup.Cli/GithubBackup.Cli.csproj --configuration Release --output publish/linux-x64 --runtime linux-x64 --self-contained
working-directory: ./GithubBackup

- name: Zip
run: zip -r ghb_linux_x64_${{ needs.release.outputs.version }}.zip ./*
working-directory: ./GithubBackup/publish/linux-x64/
working-directory: ./publish/linux-x64/

- name: Upload Release Assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ./GithubBackup/publish/linux-x64/ghb_linux_x64_${{ needs.release.outputs.version }}.zip
asset_path: ./publish/linux-x64/ghb_linux_x64_${{ needs.release.outputs.version }}.zip
asset_name: ghb_linux_x64_${{ needs.release.outputs.version }}.zip
asset_content_type: application/zip

Expand All @@ -142,34 +131,30 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: Restore
run: dotnet restore
working-directory: ./GithubBackup

- name: Build
run: dotnet build GithubBackup.sln --configuration Release --no-restore
working-directory: ./GithubBackup

- name: Test
run: dotnet test GithubBackup.sln --configuration Release --no-restore
working-directory: ./GithubBackup

- name: Publish
run: dotnet publish GithubBackup.Cli/GithubBackup.Cli.csproj --configuration Release --output publish/osx-x64 --runtime osx-x64 --self-contained
working-directory: ./GithubBackup

- name: Zip
run: zip -r ghb_osx_x64_${{ needs.release.outputs.version }}.zip ./*
working-directory: ./GithubBackup/publish/osx-x64/
working-directory: ./publish/osx-x64/

- name: Upload Release Assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ./GithubBackup/publish/osx-x64/ghb_osx_x64_${{ needs.release.outputs.version }}.zip
asset_path: ./publish/osx-x64/ghb_osx_x64_${{ needs.release.outputs.version }}.zip
asset_name: ghb_osx_x64_${{ needs.release.outputs.version }}.zip
asset_content_type: application/zip
7 changes: 2 additions & 5 deletions .github/workflows/test_linux_x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,13 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: Restore
run: dotnet restore
working-directory: ./GithubBackup

- name: Build
run: dotnet build GithubBackup.sln --configuration Release --no-restore
working-directory: ./GithubBackup

- name: Test
run: dotnet test GithubBackup.sln --configuration Release --no-restore
working-directory: ./GithubBackup
run: dotnet test GithubBackup.sln --configuration Release --no-restore
7 changes: 2 additions & 5 deletions .github/workflows/test_osx_x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,13 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: Restore
run: dotnet restore
working-directory: ./GithubBackup

- name: Build
run: dotnet build GithubBackup.sln --configuration Release --no-restore
working-directory: ./GithubBackup

- name: Test
run: dotnet test GithubBackup.sln --configuration Release --no-restore
working-directory: ./GithubBackup
run: dotnet test GithubBackup.sln --configuration Release --no-restore
7 changes: 2 additions & 5 deletions .github/workflows/test_win_x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,13 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: Restore
run: dotnet restore
working-directory: ./GithubBackup

- name: Build
run: dotnet build GithubBackup.sln --configuration Release --no-restore
working-directory: ./GithubBackup

- name: Test
run: dotnet test GithubBackup.sln --configuration Release --no-restore
working-directory: ./GithubBackup
run: dotnet test GithubBackup.sln --configuration Release --no-restore
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ FodyWeavers.xsd
# JetBrains Rider
*.sln.iml

.idea
!Backup/
!Github/Backup/
!Github/Backup/*
Expand Down
4 changes: 2 additions & 2 deletions GithubBackup/Directory.Build.props → Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<LangVersion>11</LangVersion>
<LangVersion>12</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
Expand Down
48 changes: 26 additions & 22 deletions GithubBackup/Directory.Packages.props → Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,57 @@
<PackageVersion Include="AutoBogus" Version="2.13.1" />
<PackageVersion Include="Bogus" Version="34.0.2" />
<PackageVersion Include="FluentAssertions" Version="7.0.0-alpha.1" />
<PackageVersion Include="FluentValidation" Version="11.7.1" />
<PackageVersion Include="FluentValidation" Version="11.8.1" />
<PackageVersion Include="Flurl.Http" Version="3.2.4" />
<PackageVersion Include="Meziantou.Xunit.ParallelTestFramework" Version="2.1.0" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0-rc.1.23419.4" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Http.Polly" Version="7.0.12" />
<PackageVersion Include="Microsoft.Net.Http.Headers" Version="2.2.8" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Http.Polly" Version="8.0.0" />
<PackageVersion Include="Microsoft.Net.Http.Headers" Version="8.0.0" />
<PackageVersion Include="NSubstitute" Version="5.1.0" />
<PackageVersion Include="NSubstitute.Analyzers.CSharp" Version="1.0.16">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="Octokit" Version="8.0.1" />
<PackageVersion Include="Polly" Version="8.0.0" />
<PackageVersion Include="Polly" Version="8.2.0" />
<PackageVersion Include="Polly.Contrib.WaitAndRetry" Version="1.1.1" />
<PackageVersion Include="Polly.Extensions.Http" Version="3.0.0" />
<PackageVersion Include="Roslyn.System.IO.Abstractions.Analyzers" Version="12.2.19" />
<PackageVersion Include="Serilog" Version="3.0.1" />
<PackageVersion Include="Serilog.Extensions.Hosting" Version="7.0.0" />
<PackageVersion Include="Serilog" Version="3.1.1" />
<PackageVersion Include="Serilog.Extensions.Hosting" Version="8.0.0" />
<PackageVersion Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageVersion Include="Spectre.Console" Version="0.47.1-preview.0.26" />
<PackageVersion Include="Spectre.Console.Analyzer" Version="0.47.0" />
<PackageVersion Include="Spectre.Console.Testing" Version="0.47.0" />
<PackageVersion Include="Spectre.Console" Version="0.48.0" />
<PackageVersion Include="Spectre.Console.Analyzer" Version="0.48.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="Spectre.Console.Testing" Version="0.48.0" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageVersion Include="System.CommandLine.Hosting" Version="0.4.0-alpha.22272.1" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
<PackageVersion Include="System.Runtime.Caching" Version="8.0.0-rc.1.23419.4" />
<PackageVersion Include="System.Threading.RateLimiting" Version="7.0.1" />
<PackageVersion Include="TestableIO.System.IO.Abstractions" Version="19.2.69" />
<PackageVersion Include="System.Runtime.Caching" Version="8.0.0" />
<PackageVersion Include="System.Threading.RateLimiting" Version="8.0.0" />
<PackageVersion Include="TestableIO.System.IO.Abstractions" Version="20.0.4" />
<PackageVersion Include="TestableIO.System.IO.Abstractions.Analyzers" Version="2022.0.0" />
<PackageVersion Include="TestableIO.System.IO.Abstractions.Extensions" Version="2.0.5" />
<PackageVersion Include="TestableIO.System.IO.Abstractions.TestingHelpers" Version="19.2.69" />
<PackageVersion Include="TestableIO.System.IO.Abstractions.Wrappers" Version="19.2.69" />
<PackageVersion Include="Verify.Xunit" Version="22.1.4" />
<PackageVersion Include="xunit" Version="2.5.2" />
<PackageVersion Include="xunit.extensibility.core" Version="2.5.2" />
<PackageVersion Include="TestableIO.System.IO.Abstractions.TestingHelpers" Version="20.0.4" />
<PackageVersion Include="TestableIO.System.IO.Abstractions.Wrappers" Version="20.0.4" />
<PackageVersion Include="Testcontainers" Version="3.6.0" />
<PackageVersion Include="Verify.Xunit" Version="22.8.0" />
<PackageVersion Include="xunit" Version="2.6.3" />
<PackageVersion Include="xunit.extensibility.core" Version="2.6.3" />
<PackageVersion Include="xunit.extensibility.execution" Version="2.4.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.3">
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="coverlet.collector" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.6.133">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Description:
Github Backup

Usage:
ghb [command] [options]

Options:
--quiet Do not print logs to console. [default: True]
--log-file <log-file> Path to the log file.
--verbosity <Critical|Debug|Error|Information|None|Trace|Warning> Set the verbosity level of the log file. [default: Information]
--version Show version information
-?, -h, --help Show help and usage information

Commands:
manual Manually backup a Github user. This command is interactive.
migrate Migrate a Github user.
login Login to Github. Persists your login token to disk for future use.
Only one login token can be persisted at a time.
migrations List migrations.
repositories List repositories.
download Download migrations.
backup Backup a Github user.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'' was not matched. Did you mean one of the following?
-h
Required command was not provided.
Unrecognized command or argument ''.

Description:
Github Backup

Usage:
ghb [command] [options]

Options:
--quiet Do not print logs to console. [default: True]
--log-file <log-file> Path to the log file.
--verbosity <Critical|Debug|Error|Information|None|Trace|Warning> Set the verbosity level of the log file. [default: Information]
--version Show version information
-?, -h, --help Show help and usage information

Commands:
manual Manually backup a Github user. This command is interactive.
migrate Migrate a Github user.
login Login to Github. Persists your login token to disk for future use.
Only one login token can be persisted at a time.
migrations List migrations.
repositories List repositories.
download Download migrations.
backup Backup a Github user.

13 changes: 13 additions & 0 deletions GithubBackup.Cli.Tests.Integration/CliTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace GithubBackup.Cli.Tests.Integration;

[UsesVerify]
public class CliTests
{
[Theory]
[InlineData("", 1)]
[InlineData("--help")]
public async Task RunAsync__(string args, int exitCode = 0)
{
await TestCli.RunAsync(args, exitCode, _ => {});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Login failed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Login failed
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Description:
Login to Github. Persists your login token to disk for future use.
Only one login token can be persisted at a time.

Usage:
ghb login [options]

Options:
--token <token> If not provided, the token will be aquired from the environment variable GITHUB_BACKUP_TOKEN.
If provided, device flow authentication will be ignored. Recommended for use on servers.");
--device-flow-auth Interactive authentication using the device flow.
Requires a browser. Recommended for use on clients. [default: False]
--quiet Do not print logs to console. [default: True]
--log-file <log-file> Path to the log file.
--verbosity <Critical|Debug|Error|Information|None|Trace|Warning> Set the verbosity level of the log file. [default: Information]
-?, -h, --help Show help and usage information


Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Token test_token is invalid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Login failed
Loading

0 comments on commit f6e8a60

Please sign in to comment.