Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UseArtifactsOutput, add Start pipeline #633

Merged
merged 4 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@
"version": 1,
"isRoot": true,
"tools": {
"fable": {
"version": "4.5.0",
"commands": [
"fable"
]
},
"fantomas": {
"version": "6.3.0-alpha-003",
"version": "6.3.0-alpha-007",
"commands": [
"fantomas"
]
Expand Down
2 changes: 2 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<FantomasMainRepository>$(MSBuildThisFileDirectory).deps\fantomas</FantomasMainRepository>
<FantomasPreviewRepository>$(MSBuildThisFileDirectory).deps\main</FantomasPreviewRepository>
<RollForward>LatestMajor</RollForward>
<UseArtifactsOutput>true</UseArtifactsOutput>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup>

<ItemGroup Condition="'$(IsLambda)' == 'true'">
Expand Down
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,25 @@ To run this tool locally you need:
* Pull in the source dependencies:

```shell
dotnet fsi build.fsx -p Fantomas-Git
dotnet fsi build.fsx -- -p Fantomas-Git
```

* Run the Watch pipeline:

```shell
dotnet fsi build.fsx -p Watch
dotnet fsi build.fsx -- -p Watch
```

Making changes should reflect in the tool.

Or try the Run pipeline:

```shell
dotnet fsi build -- -p Run
```

This will run a published version of the tools.

* Open http://localhost:9060

## Running in Gitpod
Expand All @@ -32,11 +42,11 @@ dotnet fsi build.fsx -p Watch
* Run

```shell
dotnet fsi build.fsx -p Fantomas-Git
dotnet fsi build.fsx -- -p Fantomas-Git
```

```shell
dotnet fsi build.fsx -p Watch
dotnet fsi build.fsx -- -p Watch
```

* Open browser for port `9060`
Expand Down
69 changes: 52 additions & 17 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pipeline "Fantomas-Git" {
}

let publishLambda name =
$"dotnet publish --tl -c Release -o {artifactDir </> name} {serverDir}/{name}/{name}.fsproj"
$"dotnet publish --tl -c Release {serverDir}/{name}/{name}.fsproj"

let runLambda name =
$"dotnet watch run --project {serverDir </> name </> name}.fsproj --tl"
Expand All @@ -107,16 +107,22 @@ let setViteToProduction () =
setEnv "VITE_FANTOMAS_MAIN" $"{mainStageUrl}/fantomas/main"
setEnv "VITE_FANTOMAS_PREVIEW" $"{mainStageUrl}/fantomas/preview"

pipeline "Build" {
workingDir __SOURCE_DIRECTORY__
let bunInstall =
stage "bun install" {
workingDir clientDir
run "bun i"
}

let dotnetInstall =
stage "dotnet install" {
run "dotnet tool restore"
run "dotnet restore --tl"
}

pipeline "Build" {
workingDir __SOURCE_DIRECTORY__
bunInstall
dotnetInstall
stage "check format F#" { run "dotnet fantomas src infrastructure build.fsx --check" }
stage "check format JS" {
workingDir clientDir
Expand All @@ -126,11 +132,7 @@ pipeline "Build" {
run (fun _ ->
async {
Shell.rm_rf artifactDir
!!(serverDir + "/*/bin")
++ (serverDir + "/*/obj")
++ (clientDir + "/src/bin")
++ (clientDir + "/build")
|> Seq.iter Shell.rm_rf
Shell.rm_rf (clientDir + "/build")
return 0
})
}
Expand Down Expand Up @@ -227,15 +229,7 @@ pipeline "FormatChanged" {
runIfOnlySpecified true
}

pipeline "Watch" {
stage "bun install" {
workingDir clientDir
run "bun i"
}
stage "dotnet install" {
run "dotnet tool restore"
run "dotnet restore"
}
let prepareEnvironmentVariables =
stage "prepare environment variables" {
run (fun _ ->
async {
Expand All @@ -259,6 +253,11 @@ pipeline "Watch" {
return 0
})
}

pipeline "Watch" {
bunInstall
dotnetInstall
prepareEnvironmentVariables
stage "launch services" {
paralle
run (runLambda "ASTViewer")
Expand All @@ -276,4 +275,40 @@ pipeline "Watch" {
runIfOnlySpecified true
}

let runPublishedLambda name =
let binary =
__SOURCE_DIRECTORY__
</> "artifacts"
</> "publish"
</> name
</> "debug"
</> $"%s{name}.dll"

stage $"Run %s{name}" {
run $"dotnet publish --nologo -c Debug -tl {serverDir </> name </> name}.fsproj"
run $"dotnet %s{binary}"
}

pipeline "Start" {
bunInstall
dotnetInstall
prepareEnvironmentVariables
stage "launch services" {
paralle
runPublishedLambda "ASTViewer"
runPublishedLambda "OakViewer"
runPublishedLambda "FantomasOnlineV4"
runPublishedLambda "FantomasOnlineV5"
runPublishedLambda "FantomasOnlineV6"
runPublishedLambda "FantomasOnlineMain"
runPublishedLambda "FantomasOnlinePreview"
stage "frontend" {
workingDir clientDir
run "bun run build"
run "bun run serve"
}
}
runIfOnlySpecified true
}

tryPrintPipelineCommandHelp ()
8 changes: 7 additions & 1 deletion infrastructure/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ let getAllLambdas (lastSha, lastTime) =
Environment = environment }

let mkLambdaProject (name: string) lambdas =
let archive = __SOURCE_DIRECTORY__ </> ".." </> "artifacts" </> name
let archive =
__SOURCE_DIRECTORY__
</> ".."
</> "artifacts"
</> "publish"
</> name
</> "release"

{ Name = name
FileArchive = archive
Expand Down
2 changes: 1 addition & 1 deletion src/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"scripts": {
"dev": "bunx --bun vite",
"build": "bunx --bun vite build --base=/fantomas-tools/",
"serve": "vite preview",
"serve": "bunx --bun vite preview",
"format": "prettier --write \"src/**/*.{js,jsx}\" vite.config.js",
"lint": "prettier --check \"src/**/*.{js,jsx}\" vite.config.js"
},
Expand Down
3 changes: 3 additions & 0 deletions src/client/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ export default defineConfig({
outDir: 'build',
},
base: '/fantomas-tools/',
preview: {
port: 9060,
},
});
Loading