fix: add oceanbox cicd setup and fix local versioning

This commit is contained in:
2024-09-17 10:29:42 +02:00
parent 0a84a86393
commit 7358a99d83
17 changed files with 9629 additions and 207 deletions

69
.build/Build.fs Normal file
View File

@@ -0,0 +1,69 @@
open Fake.Core
open Fake.IO
open Farmer
open Farmer.Builders
open Helpers
initializeContext()
let modules = [
"Lit"
"Lit.React"
"Lit.Elmish"
]
let modPath (m: string) = Path.getFullName $"src/{m}"
let distPath = Path.getFullName "dist"
let packPath = Path.getFullName "packages"
Target.create "Clean" (fun _ -> Shell.cleanDir distPath)
Target.create "InstallClient" (fun _ ->
run npm "install" "."
run dotnet "tool restore" "."
)
Target.create "Bundle" (fun _ ->
modules
|> List.iter (fun m ->
let src = modPath m
run dotnet $"publish -c Release -o \"{distPath}/{m}\" -f net8.0" src)
)
Target.create "BundleDebug" (fun _ ->
modules
|> List.iter (fun m ->
let src = modPath m
run dotnet $"publish -c Debug -o \"{distPath}/{m}\" -f net8.0" src)
)
Target.create "Pack" (fun _ ->
modules
|> List.iter (fun m ->
let src = modPath m
run dotnet $"pack -c Release -o \"{packPath}\"" src)
)
Target.create "Format" (fun _ ->
run dotnet "fantomas . -r" "src"
)
open Fake.Core.TargetOperators
let dependencies = [
"Clean"
==> "InstallClient"
==> "Bundle"
"Clean"
==> "BundleDebug"
"Clean"
==> "Pack"
]
[<EntryPoint>]
let main args = runOrDefault args

105
.build/Helpers.fs Normal file
View File

@@ -0,0 +1,105 @@
module Helpers
open Fake.Core
let initializeContext () =
let execContext = Context.FakeExecutionContext.Create false "build.fsx" [ ]
Context.setExecutionContext (Context.RuntimeContext.Fake execContext)
module Proc =
module Parallel =
open System
let locker = obj()
let colors =
[| ConsoleColor.Blue
ConsoleColor.Yellow
ConsoleColor.Magenta
ConsoleColor.Cyan
ConsoleColor.DarkBlue
ConsoleColor.DarkYellow
ConsoleColor.DarkMagenta
ConsoleColor.DarkCyan |]
let print color (colored: string) (line: string) =
lock locker
(fun () ->
let currentColor = Console.ForegroundColor
Console.ForegroundColor <- color
Console.Write colored
Console.ForegroundColor <- currentColor
Console.WriteLine line)
let onStdout index name (line: string) =
let color = colors.[index % colors.Length]
if isNull line then
print color $"{name}: --- END ---" ""
else if String.isNotNullOrEmpty line then
print color $"{name}: " line
let onStderr name (line: string) =
let color = ConsoleColor.Red
if isNull line |> not then
print color $"{name}: " line
let redirect (index, (name, createProcess)) =
createProcess
|> CreateProcess.redirectOutputIfNotRedirected
|> CreateProcess.withOutputEvents (onStdout index name) (onStderr name)
let printStarting indexed =
for (index, (name, c: CreateProcess<_>)) in indexed do
let color = colors.[index % colors.Length]
let wd =
c.WorkingDirectory
|> Option.defaultValue ""
let exe = c.Command.Executable
let args = c.Command.Arguments.ToStartInfo
print color $"{name}: {wd}> {exe} {args}" ""
let run cs =
cs
|> Seq.toArray
|> Array.indexed
|> fun x -> printStarting x; x
|> Array.map redirect
|> Array.Parallel.map Proc.run
let createProcess exe arg dir =
CreateProcess.fromRawCommandLine exe arg
|> CreateProcess.withWorkingDirectory dir
|> CreateProcess.ensureExitCode
let dotnet = createProcess "dotnet"
let npm =
let npmPath =
match ProcessUtils.tryFindFileOnPath "npm" with
| Some path -> path
| None ->
"npm was not found in path. Please install it and make sure it's available from your path. " +
"See https://safe-stack.github.io/docs/quickstart/#install-pre-requisites for more info"
|> failwith
createProcess npmPath
let run proc arg dir =
proc arg dir
|> Proc.run
|> ignore
let runParallel processes =
processes
|> Proc.Parallel.run
|> ignore
let runOrDefault args =
try
match args with
| [| target |] -> Target.runOrDefault target
| _ ->
Target.runOrDefault "Pack"
0
with e ->
printfn "%A" e
1

30
.devcontainer/Dockerfile Normal file
View File

@@ -0,0 +1,30 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0
# Add keys and sources lists
RUN apt-get update && apt-get install -y ca-certificates gnupg
RUN mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
ENV NODE_MAJOR=20
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
# Install node, 7zip, yarn, git, process tools
RUN apt-get update \
&& apt-get install -y nodejs p7zip-full git procps ssh-client
# Clean up
RUN apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
# # Install dotnet tools
# RUN dotnet tool install fable -g
# Trouble brewing
RUN rm /etc/ssl/openssl.cnf
# add dotnet tools to path to pick up fake and paket installation
ENV PATH="/root/.dotnet/tools:${PATH}"
# Copy endpoint specific user settings into container to specify
# .NET Core should be used as the runtime.
COPY settings.vscode.json /root/.vscode-remote/data/Machine/settings.json

View File

@@ -0,0 +1,11 @@
{
"name": "SAFE",
"dockerFile": "Dockerfile",
"appPort": [8080, 8085],
"extensions": [
"ionide.ionide-fsharp",
"ms-dotnettools.csharp",
"editorconfig.editorconfig",
"msjsdiag.debugger-for-chrome"
]
}

View File

@@ -0,0 +1,3 @@
{
"FSharp.fsacRuntime":"netcore"
}

39
.editorconfig Normal file
View File

@@ -0,0 +1,39 @@
root = true
[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false
[*.js]
indent_size = 2
max_line_length= 80
[*.fs]
max_line_length= 120
# Feliz style
fsharp_single_argument_web_mode = true
fsharp_space_before_colon = false
fsharp_space_before_parameter = true
fsharp_max_if_then_else_short_width = 60
fsharp_max_infix_operator_expression = 50
fsharp_max_record_width = 70
fsharp_max_record_number_of_items = 1
fsharp_max_array_or_list_width = 70
fsharp_max_array_or_list_number_of_items = 1
fsharp_max_value_binding_width = 70
fsharp_max_function_binding_width = 40
fsharp_max_dot_get_expression_width = 50
fsharp_multiline_block_brackets_on_same_column = true
fsharp_newline_between_type_definition_and_members = false
fsharp_max_elmish_width = 40
fsharp_align_function_signature_to_indentation = false
fsharp_alternative_long_member_definitions = false
fsharp_multi_line_lambda_closing_newline = false
fsharp_disable_elmish_syntax = false
fsharp_keep_indent_in_branch = false
fsharp_blank_lines_around_nested_multiline_expressions = false
fsharp_multiline_bracket_style = stroustrup
fsharp_newline_before_multiline_computation_expression = true

8
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,8 @@
variables:
PROJECT_NAME: fable.lit
SKIP_TESTS: "true"
include:
- project: oceanbox/gitlab-ci
ref: v3
file: DotnetPackage.gitlab-ci.yml

41
.releaserc.yaml Normal file
View File

@@ -0,0 +1,41 @@
branches:
- main
- master
- name: develop
prerelease: true
plugins:
- '@semantic-release/commit-analyzer'
- '@semantic-release/release-notes-generator'
- - '@semantic-release/changelog'
- changelogFile: RELEASE_NOTES.md
changelogTitle: "# Changelog"
- - 'semantic-release-dotnet'
- paths: [ "src/*.fsproj", "src/*/*.fsproj" ]
- - '@semantic-release/exec'
- generateNotesCmd: "echo ${nextRelease.version} > .version"
- - '@semantic-release/git'
- message: "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}"
assets: [ "RELEASE_NOTES.md", ".version", "src/*.fsproj", "src/*/*.fsproj" ]
- - '@semantic-release/gitlab'
- assets: []
analyzeCommits:
- path: "@semantic-release/commit-analyzer"
releaseRules:
- type: "fix"
release: "patch"
- type: "patch"
release: "patch"
- type: "feat"
release: "minor"
- type: "feature"
release: "minor"
- type: "minor"
release: "minor"
- type: "breaking"
release: "major"
- type: "major"
release: "major"

17
Build.fsproj Normal file
View File

@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include=".build/Helpers.fs" />
<Compile Include=".build/Build.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Fake.Core.Target" Version="6.1.0" />
<PackageReference Include="Fake.DotNet.Cli" Version="6.1.0" />
<PackageReference Include="Fake.IO.FileSystem" Version="6.1.0" />
<PackageReference Include="Farmer" Version="1.9.0" />
<PackageReference Update="FSharp.Core" Version="8.0.301" />
</ItemGroup>
</Project>

View File

@@ -37,4 +37,4 @@ match args with
if ignoreCaseEquals file.[..(file.Length - 8)] target then
pushFableNuget (projDir </> file) [] doNothing
| None -> pushFableNuget (projDir </> file) [] doNothing
| _ -> ()
| _ -> ()

9481
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -18,6 +18,12 @@
"react-dom": "^18.3.1"
},
"devDependencies": {
"@semantic-release/changelog": "^6.0.2",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/gitlab": "^12.1.1",
"semantic-release": "^22.0.2",
"semantic-release-dotnet": "^1.0.0",
"@web/test-runner": "^0.19.0",
"@web/test-runner-commands": "^0.9.0",
"@web/test-runner-playwright": "^0.11.0",
@@ -31,4 +37,4 @@
"vite": "^5.4.5",
"vscode-theme-one": "github:mrred85/vscode-theme-one"
}
}
}

View File

@@ -2,8 +2,8 @@
<PropertyGroup>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<PackageId>ConstructStyleSheetsPolyfill</PackageId>
<Version>1.0.0</Version>
<PackageVersion>1.0.0-beta-001</PackageVersion>
<Version>1.5.0</Version>
<PackageVersion>$(Version)-oceanbox</PackageVersion>
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

View File

@@ -2,8 +2,8 @@
<PropertyGroup>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<PackageId>Fable.Lit.Elmish</PackageId>
<Version>1.4.0</Version>
<PackageVersion>1.4.0</PackageVersion>
<Version>1.5.0</Version>
<PackageVersion>$(Version)-oceanbox</PackageVersion>
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

View File

@@ -2,8 +2,8 @@
<PropertyGroup>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<PackageId>Fable.Lit.React</PackageId>
<Version>1.0.0</Version>
<PackageVersion>1.0.0-rc-001</PackageVersion>
<Version>1.5.0</Version>
<PackageVersion>$(Version)-oceanbox</PackageVersion>
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

View File

@@ -2,8 +2,8 @@
<PropertyGroup>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<PackageId>Fable.Lit.Test</PackageId>
<Version>1.3.1</Version>
<PackageVersion>1.3.1</PackageVersion>
<Version>1.5.0</Version>
<PackageVersion>$(Version)-oceanbox</PackageVersion>
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

View File

@@ -2,8 +2,8 @@
<PropertyGroup>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<PackageId>Fable.Lit</PackageId>
<Version>1.4.2</Version>
<PackageVersion>1.4.2</PackageVersion>
<Version>1.5.0</Version>
<PackageVersion>$(Version)-oceanbox</PackageVersion>
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NpmDependencies>
@@ -28,4 +28,4 @@
<PackageReference Include="Fable.Browser.Dom" Version="2.17.0" />
<PackageReference Include="Fable.Promise" Version="3.2.0" />
</ItemGroup>
</Project>
</Project>