-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Publish release and NuGet package (#11)
- Loading branch information
1 parent
ac2e2ea
commit 844b253
Showing
18 changed files
with
425 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: "Build And Test Action" | ||
description: "Builds and Tests bindle-dotnet" | ||
inputs: | ||
configuration: | ||
description: 'The Configration to build and test' | ||
required: true | ||
default: 'release' | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Restore dependencies | ||
run: dotnet restore | ||
shell: bash | ||
- name: Set MINVERBUILDMETADATA | ||
run: echo MINVERBUILDMETADATA=$(git rev-parse --short ${GITHUB_SHA}) >> $GITHUB_ENV | ||
shell: bash | ||
- name: Build | ||
run: dotnet build -c ${{ inputs.configuration }} | ||
shell: bash | ||
- name: Build Bindle | ||
run: make build | ||
working-directory: bindleserver | ||
shell: bash | ||
- name: Test | ||
env: | ||
BINDLE_SERVER_PATH: ../../../../bindleserver/target/debug | ||
run: dotnet test | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
name: dotnet | ||
|
||
on: | ||
push: | ||
tags: | ||
- '[0-9]+.[0-9]+.[0-9]+' | ||
- '[0-9]+.[0-9]+.[0-9]+-preview' | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
if: ${{ github.event_name == 'pull_request' }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
build: [linux-debug, linux-release, macos-debug, macos-release, windows-debug, windows-release] | ||
include: | ||
- build: linux-debug | ||
os: ubuntu-latest | ||
config: debug | ||
- build: linux-release | ||
os: ubuntu-latest | ||
config: release | ||
- build: macos-debug | ||
os: macos-latest | ||
config: debug | ||
- build: macos-release | ||
os: macos-latest | ||
config: release | ||
- build: windows-debug | ||
os: windows-latest | ||
config: debug | ||
- build: windows-release | ||
os: windows-latest | ||
config: release | ||
|
||
steps: | ||
- name: Fetch Source | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Get Bindle source for testing | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: deislabs/bindle | ||
path: bindleserver | ||
ref: main | ||
- name: Setup dotnet | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: 5.0.x | ||
- uses: ./.github/workflows/build-and-test | ||
with: | ||
configuration: ${{ matrix.config }} | ||
publish: | ||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Fetch Source | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Get Bindle source for testing | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: deislabs/bindle | ||
path: bindleserver | ||
ref: main | ||
- name: Setup dotnet | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: 5.0.x | ||
- uses: ./.github/workflows/build-and-test | ||
with: | ||
configuration: Release | ||
- name: Publish Github Packages | ||
run: | | ||
for nupkg in $(find . -name *.nupkg) | ||
do | ||
echo Pushing $nupkg | ||
dotnet nuget push $nupkg --api-key ${{ secrets.GHPACKAGES_PAT }} --source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json --skip-duplicate | ||
done | ||
shell: bash | ||
release: | ||
if: startsWith(github.ref, 'refs/tags/') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Fetch Source | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Get Bindle source for testing | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: deislabs/bindle | ||
path: bindleserver | ||
ref: main | ||
- name: Setup dotnet | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: 5.0.x | ||
- uses: ./.github/workflows/build-and-test | ||
with: | ||
configuration: Release | ||
- name: "Build Changelog" | ||
id: github_release | ||
uses: mikepenz/release-changelog-builder-action@main | ||
with: | ||
configuration: ".github/workflows/configuration.json" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Create Release | ||
uses: actions/create-release@v1 | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: ${{ github.ref }} | ||
body: ${{ steps.github_release.outputs.changelog }} | ||
prerelease: ${{ contains(github.ref, '-preview') }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Publish Github Packages | ||
run: | | ||
for nupkg in $(find . -name *.nupkg) | ||
do | ||
echo Pushing $nupkg | ||
dotnet nuget push $nupkg --api-key ${{ secrets.GHPACKAGES_PAT }} --source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json --skip-duplicate | ||
done | ||
shell: bash | ||
- name: Publish Nuget Packages | ||
run: | | ||
for nupkg in $(find . -name *.nupkg) | ||
do | ||
echo Pushing $nupkg | ||
dotnet nuget push $nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | ||
done | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"categories": [ | ||
{ | ||
"title": "## 🚀 Features", | ||
"labels": [ | ||
"feature", | ||
"enhancement" | ||
] | ||
}, | ||
{ | ||
"title": "## 🐛 Fixes", | ||
"labels": [ | ||
"fix", | ||
"bug" | ||
] | ||
}, | ||
{ | ||
"title": "## 🧪 Tests", | ||
"labels": [ | ||
"test" | ||
] | ||
}, | ||
{ | ||
"title": "## 📦 Dependencies", | ||
"labels": [ | ||
"dependencies" | ||
] | ||
}, | ||
{ | ||
"title": "## 🏷️ Uncategorized", | ||
"labels": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Threading; | ||
using Xunit; | ||
|
||
namespace Deislabs.Bindle.Tests | ||
{ | ||
public class IntegrationFixture : IDisposable | ||
{ | ||
private readonly Process process; | ||
private readonly string dataPath; | ||
private readonly string testDataCopy; | ||
|
||
// private readonly string[] testDirs; | ||
public IntegrationFixture() | ||
{ | ||
var bindlePath = Environment.GetEnvironmentVariable("BINDLE_SERVER_PATH"); | ||
if (!string.IsNullOrEmpty(bindlePath)) | ||
{ | ||
var fullPath = Path.GetFullPath(Path.Join(bindlePath, "bindle-server")); | ||
dataPath = Path.GetFullPath(Path.Join("../../../data")); | ||
Console.WriteLine($"Using Bindle Server Path: {fullPath}"); | ||
Console.WriteLine($"Using Test Data Path: {dataPath}"); | ||
|
||
// Take a copy of the test data to be used by the tests | ||
testDataCopy = $"{Path.Combine(Path.GetTempPath(), Path.GetRandomFileName())}/test-data-copy"; | ||
Console.WriteLine($"Copying Test Data to: {testDataCopy}"); | ||
CopyDirectory(dataPath, testDataCopy); | ||
|
||
var psi = new ProcessStartInfo | ||
{ | ||
FileName = fullPath, | ||
Arguments = $"-i 127.0.0.1:14044 -d {dataPath}", | ||
UseShellExecute = false, | ||
CreateNoWindow = true, | ||
RedirectStandardError = true, | ||
RedirectStandardOutput = true | ||
}; | ||
psi.Environment["RUST_LOG"] = "info"; | ||
process = new Process | ||
{ | ||
StartInfo = psi | ||
}; | ||
process.OutputDataReceived += (sender, e) => | ||
{ | ||
if (!String.IsNullOrEmpty(e.Data)) | ||
{ | ||
Console.WriteLine(e.Data); | ||
} | ||
}; | ||
process.ErrorDataReceived += (sender, e) => | ||
{ | ||
if (!String.IsNullOrEmpty(e.Data)) | ||
{ | ||
Console.WriteLine(e.Data); | ||
} | ||
}; | ||
process.Start(); | ||
process.BeginErrorReadLine(); | ||
process.BeginOutputReadLine(); | ||
// TODO: something a bit less crappy that this to wait for server to start: | ||
Thread.Sleep(5000); | ||
Assert.False(process.HasExited); | ||
} | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
// Stop the bindle server | ||
try | ||
{ | ||
process?.Kill(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine($"Failed to stop bindle process:{ex}"); | ||
} | ||
|
||
// Revert the modifications to test data | ||
|
||
var testOutput = $"{Path.Combine(Path.GetTempPath(), Path.GetRandomFileName())}/test-output"; | ||
Console.WriteLine($"Copying Test Output to: {testOutput}"); | ||
|
||
// Copy the output of the test to the temp directory and then delete it and replace with the original, then delete the copies | ||
|
||
CopyDirectory(dataPath, testOutput); | ||
Directory.Delete(dataPath, true); | ||
CopyDirectory(testDataCopy, dataPath); | ||
Directory.Delete(testDataCopy, true); | ||
Directory.Delete(testOutput, true); | ||
} | ||
|
||
private void CopyDirectory(string source, string dest) | ||
{ | ||
Directory.CreateDirectory(dest); | ||
foreach (var file in Directory.GetFiles(source)) | ||
{ | ||
File.Copy(file, Path.Combine(dest, Path.GetFileName(file)), true); | ||
} | ||
|
||
foreach (var dir in Directory.GetDirectories(source)) | ||
{ | ||
CopyDirectory(dir, Path.Combine(dest, Path.GetFileName(dir))); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.