diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ae4c3c5..6be51fd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,11 +4,15 @@ name: Tests # runs it as it is; a module calls it and is checked out into modules/ of a checkout of the core. # # Windows with the Visual Studio the native toolset asks for (Shared/Build/Stellar.Native.props), C++/CLI included. +# +# By itself only on the way into master; on any other branch by hand (Run workflow). on: + workflow_dispatch: push: - branches: [develop, master] + branches: [master] pull_request: + branches: [master] workflow_call: permissions: diff --git a/Docs/Architecture/Sdk.md b/Docs/Architecture/Sdk.md index 537af99..bbc0796 100644 --- a/Docs/Architecture/Sdk.md +++ b/Docs/Architecture/Sdk.md @@ -26,7 +26,7 @@ them, but Rider shows an item written in a project file as a file of the project The SDK version is pinned once, in `global.json`, not in every project: ```json -{ "msbuild-sdks": { "Stellar.Sdk": "0.4.1" } } +{ "msbuild-sdks": { "Stellar.Sdk": "0.4.2" } } ``` The SDK itself comes from the local feed through `NuGet.config`. `stellar project new` and `stellar modules new` @@ -136,7 +136,7 @@ NuGet cache: the next restore of a game takes the new ones. | Target | Task | Result | Switch (`=false`) | |---|---|---|---| | `StellarResolveProject` | `ResolveStellarProject` | Parses `.stellar.project`, selects assets | `StellarEnableAssets` for the assets | -| `StellarCompileResources` | `CompileStellarResources` | `resources/**/*.sres` in the output | `StellarEnableResourceCompilation` | +| `StellarCompileResources` | `CompileStellarResources` | `Resources/**/*.sres` in the output | `StellarEnableResourceCompilation` | | `StellarGenerateRuntimeConfiguration` | `GenerateRuntimeConfiguration` | `{Project}.stellar.runtime.config.json` | `StellarEnableRuntimeConfiguration` | | `StellarGenerateLauncher` | `GenerateStellarLauncher` | The `Main` of an executable module | `StellarEnableLauncher` | diff --git a/Docs/Engine/GitPolicy.md b/Docs/Engine/GitPolicy.md index 8100cda..ca1589a 100644 --- a/Docs/Engine/GitPolicy.md +++ b/Docs/Engine/GitPolicy.md @@ -101,6 +101,16 @@ git switch develop git pull --ff-only ``` +A pull request into `develop` waits for the marks and the CLA, not for the tests: they run by themselves only for +`master`. Test on your machine (`scripts/build.ps1`, `stellar modules build --tests`), and to test a branch on +the server start it by hand, for example after several merges into `develop`: *Actions → Tests → Run workflow*, or + +```powershell +gh workflow run tests.yml --ref develop +``` + +The button appears once the workflow is in `master`. + More commits on the same task before the merge: `git commit` and `git push`, the pull request takes them by itself. Always a **merge commit**, never a squash or a rebase: those make other commits out of the same changes, and `develop` diff --git a/Docs/Engine/Versioning.md b/Docs/Engine/Versioning.md index 2c98f59..237f177 100644 --- a/Docs/Engine/Versioning.md +++ b/Docs/Engine/Versioning.md @@ -112,6 +112,31 @@ After `v1.0.0`: --- +## 8. Versions of Components + +Every component (`Shared/Build/Stellar.Versions.props`, `*.stellar.module`) has a version of its own. What counts is the +version of the last release, the one on `master`: + +| Since the last release | Version | +|---|---| +| nothing that matters to others: formatting, tests, documentation | stays | +| the first compatible change | `Y` is raised, once: `0.10.0` → `0.10.1` | +| more compatible changes | stays: they go into the version that is raised already | +| a breaking change | `X` is raised, once, instead of `Y`: `0.10.1` → `0.11.0` | +| more changes of any kind after it | stays | + +A change is breaking for a component when what uses it does not work with the new one as it is. A component that did not +change is raised only if it does not work with the old version of what it depends on. The orchestra takes `X` when any of +its components does, or when a module enters it. + +Before raising, compare: + +```powershell +git show origin/master:Shared/Build/Stellar.Versions.props +``` + +--- + Also see: - [GitPolicy.md](GitPolicy.md) - [CONTRIBUTING.md](../../CONTRIBUTING.md) diff --git a/Docs/Formats/ProjectFile.md b/Docs/Formats/ProjectFile.md index 55afdb9..257e79b 100644 --- a/Docs/Formats/ProjectFile.md +++ b/Docs/Formats/ProjectFile.md @@ -40,7 +40,7 @@ and `.idea` are never searched. | `Assets.Include` | Files copied to the output as they are | | `Assets.Embedded` | Files embedded into the assembly. They win over `Include` | | `Assets.Exclude` | Files removed from both lists | -| `Resources.Include` | Files compiled into `.sres` containers, in `resources/` of the output | +| `Resources.Include` | Files compiled into `.sres` containers, in `Resources/` of the output | | `Resources.Compilers` | Assemblies with additional resource compilers | | `Localizations.IndexFiles` | Index files. The culture is the file name before `.stellar.loc.index` | | `Runtime` | The settings of the runtime ([Runtime](../Architecture/Runtime.md#settings)), and free-form values for modules. They reach `RuntimeConfiguration.Settings`: strings as they are, other values as JSON text | diff --git a/Docs/Migration-0.11.md b/Docs/Migration-0.11.md index da292bd..9c611ca 100644 --- a/Docs/Migration-0.11.md +++ b/Docs/Migration-0.11.md @@ -8,19 +8,51 @@ number because the logging module enters it. | Component | 0.10 | 0.11 | Why | |---|---|---|---| | Orchester | 0.10.0 | 0.11.0 | The logging module, and the file system published by its module | -| Kernel | 0.10.0 | 0.10.1 | Compatible: a color of `LoggerFormat.Default` | +| Kernel | 0.10.0 | 0.10.1 | Compatible: `Folders`; a color of `LoggerFormat.Default` | +| FileSystem | 0.9.0 | 0.11.0 | It publishes itself and mounts the folders of the engine | | Runtime | 0.10.0 | 0.10.1 | Compatible: settings of the command line reach modules | | Stellar.Tools | 0.3.2 | 0.3.3 | Compatible: marks; a module is packed before its tests | | `stellar` (CLI) | 0.2.3 | 0.2.4 | Compatible: `stellar marks` | -| Core, Stellar.Sdk, P/Invoke exports | 0.10.0, 0.4.1, 3.1 | the same | Nothing changed | +| Stellar.Sdk | 0.4.1 | 0.4.2 | Compatible: compiled resources go into `Resources` | +| Core, P/Invoke exports | 0.10.0, 3.1 | the same | Nothing changed | -Build the engine again and install it (`scripts/build.ps1 -Configuration Release -Install`). `global.json` stays. +Build the engine again and install it (`scripts/build.ps1 -Configuration Release -Install`). `global.json` pins an exact version of +Stellar.Sdk, so change `0.4.1` to `0.4.2` in that of every solution: + +```json +{ "msbuild-sdks": { "Stellar.Sdk": "0.4.2" } } +``` + +## Resources + +Compiled resources lie in `Resources` next to the application, not `resources`: only a system that tells case apart sees +the difference. ## Settings `RuntimeConfiguration.Settings` holds the settings of the project and those of the command line (`--stellar:Name=Value`), which win; names are in any case. Before, a module saw those of the project only. +## File system + +`Stellar.FileSystem` publishes `IFileSystem` by itself and mounts the folders of the engine. Code names them through +`Folders`, so it needs neither `Environment.GetFolderPath` nor the names of the domains: + +| `Folders` | Domain | Where | +|---|---|---| +| `App` | `app://` | the folder of the application, read-only | +| `Assets` | `assets://` | `Assets` of it, read-only; the setting `AssetsFolder` moves it | +| `Resources` | `resources://` | `Resources` of it, read-only; the setting `ResourcesFolder` moves it | +| `AppData.Roaming` | `user://` | `//` | +| `AppData.Local` | `local://` | the same in the local data of the user | +| `AppData.LocalLow` | `locallow://` | the same in the low local data | +| `Temp` | `temp://` | the same in the temporary files | + +The company is `Starlet` when the project names none; a project without a name has none of the last four. They are +created by the first write. Full paths of the machine, to mount domains of your own: `Stellar.FileSystem.SystemFolders`. + +A cancelled or failed atomic write leaves the file as it was. + ## Logging When the module that published the logger stops, the runtime goes back to the error output: what fails after it is diff --git a/Kernel/src/Managed/Stellar.Kernel/FileSystem/Folders.cs b/Kernel/src/Managed/Stellar.Kernel/FileSystem/Folders.cs new file mode 100644 index 0000000..5f43361 --- /dev/null +++ b/Kernel/src/Managed/Stellar.Kernel/FileSystem/Folders.cs @@ -0,0 +1,41 @@ +namespace Stellar.Kernel.FileSystem; + +/// +/// The folders of the engine, as paths of its domains: what a game names instead of locations of the machine. +/// +/// +/// Folders.AppData.Roaming.Combine("saves/slot1.json") is user://saves/slot1.json. These are names +/// only, the same in every engine instance: where each lies is up to the file system of that instance. +/// The module Stellar.FileSystem mounts them when the engine starts. and +/// are there if the application has such folders, and +/// if it has a name. +/// +public static class Folders +{ + /// Gets the folder of the application, read-only. + public static FilePath App { get; } = FilePath.Root("app"); + + /// Gets the assets of the application, read-only. + public static FilePath Assets { get; } = FilePath.Root("assets"); + + /// Gets the compiled resources of the application, read-only. + public static FilePath Resources { get; } = FilePath.Root("resources"); + + /// Gets the folder for files that may disappear once the application stops. + public static FilePath Temp { get; } = FilePath.Root("temp"); + + /// + /// The folders of the application among the data of the user. + /// + public static class AppData + { + /// Gets the data that follows the user from machine to machine: settings, saves. + public static FilePath Roaming { get; } = FilePath.Root("user"); + + /// Gets the data of this machine: caches, logs. + public static FilePath Local { get; } = FilePath.Root("local"); + + /// Gets the data of this machine a process with few rights may write. + public static FilePath LocalLow { get; } = FilePath.Root("locallow"); + } +} diff --git a/SDK/src/MSBuild/Stellar.Sdk.Tasks/CompileStellarResources.cs b/SDK/src/MSBuild/Stellar.Sdk.Tasks/CompileStellarResources.cs index a53759b..cc637f6 100644 --- a/SDK/src/MSBuild/Stellar.Sdk.Tasks/CompileStellarResources.cs +++ b/SDK/src/MSBuild/Stellar.Sdk.Tasks/CompileStellarResources.cs @@ -2,10 +2,13 @@ // ReSharper disable AutoPropertyCanBeMadeGetOnly.Global // ReSharper disable UnusedAutoPropertyAccessor.Global +using System.Collections.Generic; using System.IO; using System.Linq; + using Microsoft.Build.Framework; using Microsoft.Build.Utilities; + using Stellar.Tools.Environment; using Stellar.Tools.Projects; using Stellar.Tools.Resources; @@ -36,21 +39,21 @@ public sealed class CompileStellarResources /// protected override void Run() { - var project = StellarProject.Load(ConfigurationFile); - var sources = ProjectFileResolver.Resolve(project).Resources; + StellarProject project = StellarProject.Load(ConfigurationFile); + IReadOnlyList sources = ProjectFileResolver.Resolve(project).Resources; var compilers = ResourceCompilerRegistry.CreateDefault(); if (!string.IsNullOrEmpty(StellarRoot)) compilers.AddFromDirectory(new StellarInstallation(StellarRoot).ResourceCompilers, this); - foreach (var assembly in project.Configuration.Resources?.Compilers ?? []) + foreach (string assembly in project.Configuration.Resources?.Compilers ?? []) compilers.AddFrom(Path.Combine(project.Directory, assembly), this); - var outputRoot = Path.GetFullPath(Path.Combine(project.Directory, OutputDirectory)) + string outputRoot = Path.GetFullPath(Path.Combine(project.Directory, OutputDirectory)) .TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); - var result = new ResourcePipeline(compilers, this).Compile(sources, outputRoot); + ResourcePipelineResult result = new ResourcePipeline(compilers, this).Compile(sources, outputRoot); Log.LogMessage(MessageImportance.High, $"Resource compilation result: " + $"UpToDate - {result.UpToDate}, " + @@ -61,7 +64,7 @@ protected override void Run() .Select(output => { var item = new TaskItem(output); - item.SetMetadata("Link", Path.Combine("resources", output.Substring(outputRoot.Length + 1))); + item.SetMetadata("Link", Path.Combine("Resources", output.Substring(outputRoot.Length + 1))); item.SetMetadata("CopyToOutputDirectory", "PreserveNewest"); return (ITaskItem)item; }) diff --git a/Shared/Build/Stellar.Versions.props b/Shared/Build/Stellar.Versions.props index 13398c0..42e8fe2 100644 --- a/Shared/Build/Stellar.Versions.props +++ b/Shared/Build/Stellar.Versions.props @@ -14,7 +14,7 @@ 0.10.0 0.10.1 0.3.3 - 0.4.1 + 0.4.2 0.2.4 diff --git a/Shared/Templates/Modules/Managed/.github/workflows/tests.yml b/Shared/Templates/Modules/Managed/.github/workflows/tests.yml index c9fa495..73cfede 100644 --- a/Shared/Templates/Modules/Managed/.github/workflows/tests.yml +++ b/Shared/Templates/Modules/Managed/.github/workflows/tests.yml @@ -1,11 +1,14 @@ name: Tests # The module built and tested on the core, by the workflow of the core. +# By itself only on the way into master; on any other branch by hand (Run workflow). on: + workflow_dispatch: push: - branches: [develop, master] + branches: [master] pull_request: + branches: [master] permissions: contents: read diff --git a/global.json b/global.json index e7a2998..8303ef6 100644 --- a/global.json +++ b/global.json @@ -5,6 +5,6 @@ "allowPrerelease": false }, "msbuild-sdks": { - "Stellar.Sdk": "0.4.1" + "Stellar.Sdk": "0.4.2" } }