Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hahn-kev committed Feb 14, 2024
2 parents 68613aa + 883f8d7 commit ace7314
Show file tree
Hide file tree
Showing 154 changed files with 6,842 additions and 3,629 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ jobs:
push: true
verify-published:
name: Verify ${{ matrix.verify.name }} Published
runs-on: ubuntu-latest
if: ${{ inputs.k8s-environment != 'develop' }} #disable develop until we can use a self hosted runner for this test
runs-on: self-hosted #only self hosted can access develop, so we should just run all our verify tests on self hosted
if: ${{ inputs.image != 'ghcr.io/sillsdev/lexbox-hgweb' }}
needs: deploy
strategy:
fail-fast: true
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/develop-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,18 @@ jobs:
version: ${{ needs.set-version.outputs.version }}
image: 'ghcr.io/sillsdev/lexbox-api'
k8s-environment: develop
deploy-domain: staging.languagedepot.org #todo change to develop
deploy-domain: develop.lexbox.org

integration-tests:
name: Integration tests
concurrency: develop
uses: ./.github/workflows/integration-test.yaml
if: false #disable develop until we can use a self hosted runner for this test
permissions:
checks: write
secrets: inherit
needs: deploy-api
with:
test-domain: staging.languagedepot.org #todo change to develop
test-domain: develop.lexbox.org
hg-domain: hg-develop.lexbox.org
http-scheme: http
runs-on: self-hosted
5 changes: 4 additions & 1 deletion .github/workflows/develop-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
version: ${{ needs.set-version.outputs.version }}
image: 'ghcr.io/sillsdev/lexbox-ui'
k8s-environment: develop
deploy-domain: staging.languagedepot.org #todo change to develop
deploy-domain: develop.lexbox.org

check-and-lint:
runs-on: ubuntu-latest
Expand All @@ -52,6 +52,9 @@ jobs:
working-directory: ./frontend
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version-file: './frontend/package.json'
- run: corepack enable
- run: pnpm install
- run: pnpm run build # We need code/types generated by the build (e.g. gql/generated)
Expand Down
45 changes: 32 additions & 13 deletions .github/workflows/integration-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,60 @@ on:
description: 'The environment to run the tests in'
required: true
type: string
runs-on:
description: 'The runner to use'
required: true
type: string
hg-domain:
description: 'The domain to use for hg'
required: true
type: string
http-scheme:
description: 'The scheme to use for http tests'
type: string
default: 'https'
workflow_dispatch:
inputs:
test-domain:
description: 'The environment to run the tests in'
required: true
type: string
runs-on:
description: 'The runner to use'
required: true
type: string
hg-domain:
description: 'The domain to use for hg'
required: true
type: string
http-scheme:
description: 'The scheme to use for http tests'
type: string
default: 'https'

jobs:
test:
timeout-minutes: 60
name: Test ${{ matrix.os }} on ${{ inputs.test-domain }}
name: Test ${{ inputs.runs-on }} on ${{ inputs.test-domain }}
permissions:
checks: write
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
environment:
name: staging
runs-on: ${{ matrix.os }}
runs-on: ${{ inputs.runs-on }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'
- uses: MatteoH2O1999/setup-python@v3.0.0
id: python
if: ${{ matrix.os == 'ubuntu-latest' && !env.act }}
if: ${{ inputs.runs-on == 'ubuntu-latest' && !env.act }}
with:
python-version: '2.7.18'
cache-build: true
allow-build: allow
- name: Link python
if: ${{ matrix.os == 'ubuntu-latest' }}
if: ${{ inputs.runs-on == 'ubuntu-latest' }}
run: |
sudo ln -s ${{ steps.python.outputs.python-path }} /usr/bin/python2
- name: Dotnet build
Expand All @@ -53,8 +71,9 @@ jobs:
env:
TEST_SERVER_HOSTNAME: ${{ inputs.test-domain }}
# this is not a typo, we need to use the lf domain because it has a cert that hg will validate
TEST_STANDARD_HG_HOSTNAME: hg-staging.languageforge.org
TEST_STANDARD_HG_HOSTNAME: ${{ inputs.hg-domain }}
TEST_RESUMABLE_HG_HOSTNAME: resumable-${{ inputs.test-domain }}
TEST_HTTP_SCHEME: ${{ inputs.http-scheme }}
TEST_PROJECT_CODE: 'sena-3'
TEST_DEFAULT_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
run: dotnet test --output ./bin --logger trx --results-directory ./test-results --filter Category=Integration
Expand All @@ -68,11 +87,11 @@ jobs:
uses: EnricoMi/publish-unit-test-result-action/composite@v2
if: always() && !env.act
with:
check_name: Integration Tests ${{ matrix.os }}
check_name: Integration Tests ${{ inputs.runs-on }}
files: ./test-results/*.trx
- name: Upload playwright results
if: always()
uses: actions/upload-artifact@v3
with:
name: playwright-traces-${{ matrix.os }}
name: playwright-traces-${{ inputs.runs-on }}
path: ./playwright-traces.7z
2 changes: 1 addition & 1 deletion .github/workflows/lexbox-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
type=ref,event=branch
type=ref,event=pr
type=raw,enable=${{ inputs.label-latest }},value=latest
type=raw,enable=${{ inputs.label-latest }},value=${{ inputs.version }}
type=raw,value=${{ inputs.version }}
- name: ghcr.io login
uses: docker/login-action@v2
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/lexbox-hgweb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ jobs:
- name: Set Version
id: setVersion
if: ${{ !env.VERSION }}
# set version to date in vYYYY-MM-DD format
# set version to date in vYYYY-MM-DD-commitSha format
run: |
echo "VERSION=v$(date --rfc-3339=date)" >> ${GITHUB_ENV}
echo "VERSION=v$(date --rfc-3339=date)" >> ${GITHUB_OUTPUT}
shortSha=$(echo ${{ github.sha }} | cut -c1-8)
echo "VERSION=v$(date --rfc-3339=date)-$shortSha" >> ${GITHUB_OUTPUT}
echo "VERSION=v$(date --rfc-3339=date)-$shortSha" >> ${GITHUB_ENV}
- name: Docker meta
id: meta
Expand All @@ -61,7 +62,7 @@ jobs:
type=ref,event=branch
type=ref,event=pr
type=raw,enable=${{ env.PROD_RELEASE }},value=latest
type=raw,enable=${{ env.PROD_RELEASE }},value=${{ env.VERSION }}
type=raw,value=${{ env.VERSION }}
-
uses: docker/login-action@v2
with:
Expand All @@ -85,5 +86,5 @@ jobs:
with:
version: ${{ needs.publish-hgweb.outputs.version }}
image: 'ghcr.io/sillsdev/lexbox-hgweb'
deploy-domain: 'staging.languagedepot.org'
deploy-domain: 'develop.lexbox.org'
k8s-environment: 'develop'
5 changes: 4 additions & 1 deletion .github/workflows/lexbox-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version-file: './frontend/package.json'
- name: pnpm install
working-directory: ./frontend
run: |
Expand Down Expand Up @@ -53,7 +56,7 @@ jobs:
type=ref,event=branch
type=ref,event=pr
type=raw,enable=${{ inputs.label-latest }},value=latest
type=raw,enable=${{ inputs.label-latest }},value=${{ inputs.version }}
type=raw,value=${{ inputs.version }}
- uses: docker/login-action@v2
with:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/release-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,19 @@ jobs:
integration-tests:
name: Integration tests
uses: ./.github/workflows/integration-test.yaml
strategy:
matrix:
runs-on:
- ubuntu-latest
- windows-latest
needs: deploy
permissions:
checks: write
secrets: inherit
with:
runs-on: ${{ matrix.runs-on }}
test-domain: staging.languagedepot.org
hg-domain: hg-staging.languageforge.org

deploy-prod:
name: Deploy Production
Expand Down
50 changes: 50 additions & 0 deletions backend/LexBoxApi/Controllers/ActionResults/FileCallbackResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Infrastructure;

namespace LexBoxApi.Controllers.ActionResults;

/// <summary>
/// Represents an <see cref="ActionResult"/> that when executed will
/// execute a callback to write the file content out as a stream.
/// copied from https://github.com/StephenClearyExamples/AsyncDynamicZip/tree/net6-ziparchive
/// MIT License
/// </summary>
public sealed class FileCallbackResult : FileResult
{
private readonly Func<Stream, ActionContext, Task> _callback;

/// <summary>
/// Creates a new <see cref="FileCallbackResult"/> instance.
/// </summary>
/// <param name="contentType">The Content-Type header of the response.</param>
/// <param name="callback">The stream with the file.</param>
public FileCallbackResult(string contentType, Func<Stream, ActionContext, Task> callback)
: base(contentType)
{
_ = callback ?? throw new ArgumentNullException(nameof(callback));
_callback = callback;
}

/// <inheritdoc />
public override Task ExecuteResultAsync(ActionContext context)
{
_ = context ?? throw new ArgumentNullException(nameof(context));
var executor =
new FileCallbackResultExecutor(context.HttpContext.RequestServices.GetRequiredService<ILoggerFactory>());
return executor.ExecuteAsync(context, this);
}

private sealed class FileCallbackResultExecutor : FileResultExecutorBase
{
public FileCallbackResultExecutor(ILoggerFactory loggerFactory)
: base(CreateLogger<FileCallbackResultExecutor>(loggerFactory))
{
}

public Task ExecuteAsync(ActionContext context, FileCallbackResult result)
{
SetHeadersAndLog(context, result, fileLength: null, enableRangeProcessing: false);
return result._callback(context.HttpContext.Response.BodyWriter.AsStream(), context);
}
}
}
Loading

0 comments on commit ace7314

Please sign in to comment.