Skip to content

Commit

Permalink
Merge branch 'main' into 13955-replace-altinncontentloader-with-studi…
Browse files Browse the repository at this point in the history
…ospinner
  • Loading branch information
TomasEng authored Nov 8, 2024
2 parents 192d489 + 139ddbd commit ce52779
Show file tree
Hide file tree
Showing 87 changed files with 1,403 additions and 618 deletions.
64 changes: 64 additions & 0 deletions .github/scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env bash

set -e
set -u

DRAFT=true

while [[ $# -gt 0 ]]; do
case $1 in
--github-token)
GITHUB_TOKEN="$2"
shift # pop option
shift # pop value
;;
--draft)
DRAFT="$2"
shift # pop option
shift # pop value
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
echo "Unknown argument $1"
exit 1
;;
esac
done

CURRENT_VERSION=$(git describe --abbrev=0 --tags 2>/dev/null)
CURRENT_VERSION_PARTS=(${CURRENT_VERSION//./ })
FIRST_PART=${CURRENT_VERSION_PARTS[0]:1}
SECOND_PART=${CURRENT_VERSION_PARTS[1]}
YEAR="$(date +"%Y")"

echo "Current git tag: $CURRENT_VERSION"
echo "First part: $FIRST_PART"
echo "Second part: $SECOND_PART"
echo "Current year: $YEAR"
echo "-------------------------------------"


# Ensure that the version starts from 0 when the year changes
if [[ "$YEAR" == "$FIRST_PART" ]]; then
# Increment the second part of the version by 1
NEW_VERSION="v${YEAR}.$(($SECOND_PART+1))"
else
# New year - start from 0
NEW_VERSION="v${YEAR}.0"
fi

echo "New git tag: $NEW_VERSION"
echo "Draft: $DRAFT"

# Create the release
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/altinn/altinn-studio/releases \
-d "{\"tag_name\":\"$NEW_VERSION\",\"name\":\"$NEW_VERSION\",\"draft\":$DRAFT,\"prerelease\":false,\"generate_release_notes\":true}"

2 changes: 1 addition & 1 deletion .github/workflows/deploy-designer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,5 @@ jobs:
client-id: ${{ secrets.AZURE_CLIENT_ID_FC }}
tenant-id: ${{ secrets.AZURE_TENANT_ID_FC }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID_FC }}
trace-connetion-string: ${{ secrets.APP_INSIGHTS_CONNECTION_STRING }}
trace-connection-string: ${{ secrets.APP_INSIGHTS_CONNECTION_STRING }}
trace-repo-token: ${{ secrets.GITHUB_TOKEN }}
32 changes: 32 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Generate release for Altinn Studio
on:
schedule:
# run every friday at 14:45
- cron: '45 14 * * 5'

workflow_dispatch:
inputs:
draft:
description: 'Create a draft release'
required: true
default: true
type: boolean

jobs:
generate-release:
name: Run release script
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
path: altinn-studio
fetch-tags: true
fetch-depth: 0

- name: Run release script
working-directory: altinn-studio
run: |
bash .github/scripts/release.sh \
--github-token ${{ secrets.GITHUB_TOKEN }} \
--draft ${{ github.event.inputs.draft || false }} # cron job will always be a full release
4 changes: 2 additions & 2 deletions .github/workflows/template-flux-config-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ on:
subscription-id:
required: true
trace-connection-string:
required: true
required: false
trace-repo-token:
required: true
required: false

jobs:
config-oci-artifact-push:
Expand Down
2 changes: 2 additions & 0 deletions backend/packagegroups/NuGet.props
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<PackageReference Update="MediatR" Version="12.4.1" />
<PackageReference Update="DotNetEnv" Version="3.1.1" />
<PackageReference Update="NuGet.Versioning" Version="6.11.1" />
<PackageReference Update="DistributedLock.Postgres" Version="1.2.0" />
</ItemGroup>

<ItemGroup Label="Packages used for testing">
Expand All @@ -60,5 +61,6 @@
<PackageReference Update="Microsoft.AspNetCore.SignalR.Client" Version="8.0.10" />
<PackageReference Update="Microsoft.Extensions.DependencyModel" Version="8.0.2" />
<PackageReference Update="WireMock.Net" Version="1.6.7" />
<PackageReference Update="DistributedLock.FileSystem" Version="1.0.2" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ namespace Altinn.Studio.Designer.Configuration.Extensions
{
public static class ServiceCollectionExtensions
{

/// <summary>
/// Registers all settings that implement or inherit from the marker type.
/// Settings configuration will be read from the configuration, and the settings section name will be the same as the class name.
/// It will register the settings as a scoped service.
/// </summary>
/// <param name="services">The <see cref="IServiceCollection"/> to add the service to.</param>
/// <param name="configuration">An <see cref="IConfiguration"/> holding the configuration of the app.</param>
/// <typeparam name="TMarker">The marker type used to identify the services or settings to be registered.</typeparam>
/// <returns>A reference to this instance after the operation has completed.</returns>
public static IServiceCollection RegisterSettingsByBaseType<TMarker>(this IServiceCollection services, IConfiguration configuration)
{
var typesToRegister = AltinnAssembliesScanner.GetTypesAssignedFrom<TMarker>()
Expand Down Expand Up @@ -81,5 +91,24 @@ private static void ConfigureSettingsTypeBySection<TOption>(this IServiceCollect
services.TryAddScoped(typeof(TOption), svc => ((IOptionsSnapshot<object>)svc.GetService(typeof(IOptionsSnapshot<TOption>)))!.Value);
}

/// <summary>
/// Register all the services that implement or inherit from the marker interface.
/// </summary>
/// <param name="services">The <see cref="IServiceCollection"/> to add the service to.</param>
/// <typeparam name="TMarker">The marker type used to identify the services or settings to be registered.</typeparam>
/// <returns>A reference to this instance after the operation has completed.</returns>
public static IServiceCollection RegisterSingletonServicesByBaseType<TMarker>(this IServiceCollection services)
{
var typesToRegister = AltinnAssembliesScanner.GetTypesAssignedFrom<TMarker>()
.Where(type => !type.IsInterface && !type.IsAbstract);

foreach (var serviceType in typesToRegister)
{
services.TryAddSingleton(typeof(TMarker), serviceType);
}

return services;
}

}
}

This file was deleted.

11 changes: 1 addition & 10 deletions backend/src/Designer/Controllers/AppDevelopmentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public class AppDevelopmentController : Controller
private readonly IAltinnGitRepositoryFactory _altinnGitRepositoryFactory;
private readonly ApplicationInsightsSettings _applicationInsightsSettings;
private readonly IMediator _mediator;
private readonly IUserRequestsSynchronizationService _userRequestsSynchronizationService;


/// <summary>
Expand All @@ -47,16 +46,14 @@ public class AppDevelopmentController : Controller
/// <param name="altinnGitRepositoryFactory"></param>
/// <param name="applicationInsightsSettings">An <see cref="ApplicationInsightsSettings"/></param>
/// <param name="mediator"></param>
/// <param name="userRequestsSynchronizationService">An <see cref="IUserRequestsSynchronizationService"/> used to control parallel execution of user requests.</param>
public AppDevelopmentController(IAppDevelopmentService appDevelopmentService, IRepository repositoryService, ISourceControl sourceControl, IAltinnGitRepositoryFactory altinnGitRepositoryFactory, ApplicationInsightsSettings applicationInsightsSettings, IMediator mediator, IUserRequestsSynchronizationService userRequestsSynchronizationService)
public AppDevelopmentController(IAppDevelopmentService appDevelopmentService, IRepository repositoryService, ISourceControl sourceControl, IAltinnGitRepositoryFactory altinnGitRepositoryFactory, ApplicationInsightsSettings applicationInsightsSettings, IMediator mediator)
{
_appDevelopmentService = appDevelopmentService;
_repository = repositoryService;
_sourceControl = sourceControl;
_altinnGitRepositoryFactory = altinnGitRepositoryFactory;
_applicationInsightsSettings = applicationInsightsSettings;
_mediator = mediator;
_userRequestsSynchronizationService = userRequestsSynchronizationService;
}

/// <summary>
Expand Down Expand Up @@ -218,8 +215,6 @@ public ActionResult UpdateFormLayoutName(string org, string app, [FromQuery] str
public async Task<ActionResult> SaveLayoutSettings(string org, string app, [FromQuery] string layoutSetName, [FromBody] JsonNode layoutSettings, CancellationToken cancellationToken)
{
string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
SemaphoreSlim semaphore = _userRequestsSynchronizationService.GetRequestsSemaphore(org, app, developer);
await semaphore.WaitAsync();
try
{
var editingContext = AltinnRepoEditingContext.FromOrgRepoDeveloper(org, app, developer);
Expand All @@ -230,10 +225,6 @@ public async Task<ActionResult> SaveLayoutSettings(string org, string app, [From
{
return NotFound(exception.Message);
}
finally
{
semaphore.Release();
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Altinn.Studio.Designer.Models.App;
using Altinn.Studio.Designer.Services.Interfaces;
Expand All @@ -19,17 +18,15 @@ namespace Altinn.Studio.Designer.Controllers
public class ApplicationMetadataController : ControllerBase
{
private readonly IApplicationMetadataService _applicationMetadataService;
private readonly IUserRequestsSynchronizationService _userRequestsSynchronizationService;

/// <summary>
/// Initializes a new instance of the <see cref="ApplicationMetadataController"/> class.
/// </summary>
/// <param name="applicationMetadataService">The application metadata service</param>
/// <param name="userRequestsSynchronizationService">The user requests synchronization service</param>
public ApplicationMetadataController(IApplicationMetadataService applicationMetadataService, IUserRequestsSynchronizationService userRequestsSynchronizationService)
public ApplicationMetadataController(IApplicationMetadataService applicationMetadataService)
{
_applicationMetadataService = applicationMetadataService;
_userRequestsSynchronizationService = userRequestsSynchronizationService;
}

/// <summary>
Expand Down Expand Up @@ -145,8 +142,6 @@ public async Task<ActionResult> UpdateMetadataForAttachment([FromBody] dynamic a
[Route("attachment-component")]
public async Task<ActionResult> DeleteMetadataForAttachment(string org, string app, [FromBody] string id)
{
SemaphoreSlim semaphore = _userRequestsSynchronizationService.GetRequestsSemaphore(org, app, "");
await semaphore.WaitAsync();
try
{
await _applicationMetadataService.DeleteMetadataForAttachment(org, app, id);
Expand All @@ -156,10 +151,6 @@ public async Task<ActionResult> DeleteMetadataForAttachment(string org, string a
{
return BadRequest("Could not delete metadata");
}
finally
{
semaphore.Release();
}
}
}
}
Loading

0 comments on commit ce52779

Please sign in to comment.