Skip to content

Commit

Permalink
more tidynig; test triggering release workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
beforan committed Jan 24, 2025
1 parent 4ddd546 commit 55bfb8e
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
paths:
- lib/Hutch.Rackit/**
- tests/Hutch.Rackit.Tests/**
- .github/workflows/build.Hutch.Rackit.yml
- .github/workflows/check.rackit.build-test.yml

env:
# Configure these
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ on:
paths:
- app/Hutch.Relay/**
- test/Hutch.Relay.Tests/**
- .github/workflows/build.Hutch.Relay.yml
- .github/workflows/check.relay.build-test.yml
env:
# Configure these
CI_build-config: release
CI_dotnet-version: 9.0.x
CI_project: ./app/Hutch.Relay/Hutch.Relay.csproj
Hutch_Relay_test_project: ./tests/Hutch.Relay.Tests/Hutch.Relay.Tests.csproj
build-config: release
dotnet-version: 9.0.x
project: ./app/Hutch.Relay
test-project: ./tests/Hutch.Relay.Tests

DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
Expand All @@ -25,14 +25,14 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.CI_dotnet-version }}
dotnet-version: ${{ env.dotnet-version }}
- name: dotnet build
run: >-
dotnet build
${{ env.CI_project }}
-c ${{ env.CI_build-config }}
${{ env.project }}
-c ${{ env.build-config }}
- name: Run Hutch.Relay Tests
run: >-
dotnet test
${{ env.Hutch_Relay_test_project }}
-c ${{ env.CI_build-config }}
-c ${{ env.build-config }}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ on:
paths:
- app/Hutch.Relay/**
- test/Hutch.Relay.Tests/**
- .github/workflows/build.Hutch.Relay.image.yml

- .github/workflows/check.relay.container-build.yml
jobs:
build:
runs-on: ubuntu-latest
Expand Down
59 changes: 0 additions & 59 deletions .github/workflows/release.Hutch.Relay.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
# TODO: consider preserving existing VersionSuffix pre-release tags e.g. `0.1.0-beta.1` => `0.1.0-beta.1.20240821082421+main.96u7bd07`
# currently this workflow will replace `beta.1` with only the build timestamp

name: Publish Hutch.RACKit Dev Feed
name: Publish a RACKit Dev Release

on:
workflow_dispatch:
push:
branches: [main]
paths: [lib/Hutch.Rackit/**]
pull_request: # TODO: Testing Only

env:
# Configure these
Expand Down
155 changes: 155 additions & 0 deletions .github/workflows/release.relay.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# TODO: Also publish .NET Binaries

# This workflow is used for any merge to main and results in a built container image being pushed and tagged as a dev release
# with commit hash and timestamp tags
#
# These are not stable or pre-release semver releases!
name: Publish a Relay Dev Release

on:
push:
branches: [main]
paths:
- app/Hutch.Relay/**
- test/Hutch.Relay.Tests/**
- .github/workflows/release.Hutch.Relay.yml

pull_request: # TODO: Testing only

env:
project: ./app/Hutch.Relay
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true

jobs:
publish-binaries:
runs-on: ubuntu-latest

env:
build-config: release
dotnet-version: 9.0.x
publish-dir: publish

strategy:
matrix:
include:
- artifact: win-x64
args: >-
-r win-x64
-p:PublishSingleFile=true
-p:IncludeNativeLibrariesInSingleFile=true
--self-contained
- artifact: linux-x64
args: >-
-r linux-x64
-p:PublishSingleFile=true
-p:IncludeNativeLibrariesInSingleFile=true
--self-contained
- artifact: dotnet

steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.dotnet-version }}

- name: dotnet publish
run: >-
dotnet publish
${{ env.project }}
-c ${{ env.build-config }}
-o ${{ env.publish-dir }}
${{ matrix.args }}
- uses: actions/upload-artifact@v3
with:
name: hutch-relay_${{ matrix.artifact == 'dotnet' && format('{0}-{1}', matrix.artifact, env.dotnet-version) || matrix.artifact }}
path: ${{ env.publish-dir }}

# Publish platform native EF Core migrations bundles
publish-migrations:
needs: [init]
runs-on: ubuntu-latest

env:
output-filename: migrate-relay-db

strategy:
matrix:
include:
- artifact: win-x64
file-extension: ".exe"
args: >-
-r win-x64
- artifact: linux-x64

steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.dotnet-version }}
- run: dotnet tool restore

- run: >-
dotnet ef migrations bundle
-p ${{ env.project }}
-s ${{ env.project }}
-o ${{ format('{0}{1}', env.output-filename, matrix.file-extension) }}
${{ matrix.args }}
--self-contained
- uses: actions/upload-artifact@v4
with:
name: ${{ format('migrations-{0}_{1}', needs.init.outputs.version, matrix.artifact) }}
path: ${{ format('{0}{1}', env.output-filename, matrix.file-extension) }}

# Publish Edge Container Image to GHCR
publish-containers:
runs-on: ubuntu-latest
permissions:
packages: write

env:
image-name: hutch/relay
repo-owner: ${{ github.repository_owner }}
registry: ghcr.io

steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

- name: Docker Login
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.registry }}
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}

- name: Set timestamp env var
run: echo "RUN_TIMESTAMP=$(TZ="Etc/UTC" date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV

- name: Docker Metadata action
id: meta
uses: docker/[email protected]
with:
images: ${{ env.registry }}/${{ env.repo-owner}}/${{ env.image-name}}
tags: |
${{ github.sha }}
${{ env.RUN_TIMESTAMP }}
dev-latest
- name: Build and push Docker images
uses: docker/[email protected]
with:
context: .
file: app/Hutch.Relay/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
9 changes: 6 additions & 3 deletions app/Hutch.Relay/Commands/Runners/AddUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public async Task Run(string username)
{
UserName = username
};

var password = GeneratePassword.GenerateUniquePassword(16);

var result = await users.CreateAsync(user, password);
if (!result.Succeeded)
{
Expand All @@ -28,7 +30,7 @@ public async Task Run(string username)
foreach (var e in result.Errors)
{
_logger.LogError(e.Description);
errorRows.Add(new() { e.Description });
errorRows.Add([e.Description]);
}

console.Out.Write(ConsoleTableBuilder
Expand All @@ -39,10 +41,11 @@ public async Task Run(string username)

return;
}
await subNodes.Create(user);

var subnode = await subNodes.Create(user);
var outputRows = new List<List<object>>
{
new() { "Username", username, "Password", password },
new() { "Username", username, "Password", password, "Collection ID", subnode.Id },
};

console.Out.Write(ConsoleTableBuilder
Expand Down

0 comments on commit 55bfb8e

Please sign in to comment.