Skip to content

Commit

Permalink
UseArtifactsOutput, add Start pipeline (#633)
Browse files Browse the repository at this point in the history
* UseArtifactsOutput, add Start pipeline

* Remove Fable cli tool, SatelliteResourceLanguages, update publish folder output

* Don't publish ReadyToRun

* Format build.fsx
  • Loading branch information
nojaf authored Feb 15, 2024
1 parent b4c559b commit fbfdbc5
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 30 deletions.
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,
},
});

0 comments on commit fbfdbc5

Please sign in to comment.