Skip to content
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
55 changes: 55 additions & 0 deletions .github/workflows/marks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Marks

# Marks in the comments of the code (Docs/Engine/Marks.md): one that stops a commit, or that nobody knows, does not
# get in. The hooks of git check the same on a machine; they can be skipped, this cannot.
#
# One workflow for every repository: the core runs it as it is, a module calls it. The kinds of marks and the command
# are those of the core, so a module is checked out into modules/ of a checkout of the core.

on:
push:
branches: [develop, master]
pull_request:
workflow_call:

permissions:
contents: read

jobs:
marks:
name: Marks
if: vars.STELLAR_MIRROR != 'true'
runs-on: ubuntu-latest
env:
IS_CORE: ${{ github.event.repository.name == 'StellarEngine-Core' }}
steps:
- name: Checkout
if: env.IS_CORE == 'true'
uses: actions/checkout@v5

- name: Checkout the core
if: env.IS_CORE != 'true'
uses: actions/checkout@v5
with:
repository: QuantumDevTeam/StellarEngine-Core
ref: develop

- name: Checkout the module
if: env.IS_CORE != 'true'
uses: actions/checkout@v5
with:
path: modules/${{ github.event.repository.name }}

- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
global-json-file: global.json

# A pull request into master is a release: what may lie in develop may not go there
- name: Check the marks
env:
STAGE: ${{ (github.base_ref == 'master' || github.ref == 'refs/heads/master') && 'release' || 'commit' }}
TARGET: ${{ github.event.repository.name == 'StellarEngine-Core' && '.' || format('modules/{0}', github.event.repository.name) }}
run: |
mkdir -p packages
dotnet run --project SDK/src/Stellar.Cli/Stellar.Cli.csproj -- marks check "$TARGET" --stage "$STAGE"
33 changes: 31 additions & 2 deletions .github/workflows/mirror.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,18 @@ name: Mirror
# The first snapshot comes from a machine: scripts/mirror.ps1 -Push. After that this workflow is the only writer:
# on a machine, mirror.ps1 without -Push shows the next snapshot, Run workflow here publishes it.

# It never starts by itself on a timer: a release of the core sends 'orchestra-release' (release.yml), or a person
# presses Run workflow. Run workflow also takes a component the mirror does not hold yet.

on:
repository_dispatch:
types: [orchestra-release]
workflow_dispatch:
schedule:
- cron: '17 3 * * *'
inputs:
add:
description: 'New components, e.g. modules/Stellar.LoggingSystem (comma separated). Empty: the ones of the mirror'
required: false
default: ''

permissions:
contents: write
Expand Down Expand Up @@ -62,6 +70,8 @@ jobs:
shell: pwsh
env:
COMPONENTS_TOKEN: ${{ secrets.STELLAR_MIRROR_TOKEN || github.token }}
# Through the environment, never pasted into the script
ADD: ${{ inputs.add }}
run: |
if (-not (Test-Path .orchestra)) {
throw 'No .orchestra here: make the first snapshot on a machine with scripts/mirror.ps1 -Push'
Expand All @@ -85,6 +95,13 @@ jobs:

$workspace = Join-Path $env:RUNNER_TEMP 'orchestra'
$components = @((Get-Content .orchestra -Raw | ConvertFrom-Json).Components)
# New components: a repository of the organization of the mirror, at its default branch
foreach ($entry in @("$env:ADD" -split ',' | ForEach-Object { $_.Trim() } | Where-Object { $_ })) {
if ($entry -cnotmatch '^(modules|tools)/([A-Za-z][A-Za-z0-9.-]*)$') { throw "Not modules/<Name> or tools/<Name>: $entry" }
$area, $name = $Matches[1], $Matches[2]
if ($components | Where-Object { $_.Name -eq $name }) { throw "$name is in the mirror already" }
$components += [pscustomobject]@{ Name = $name; Area = $area; Repository = "https://github.com/${{ github.repository_owner }}/$name.git" }
}
foreach ($component in $components) {
if ("$($component.Repository)" -like 'https://github.com/*' -and ($component.Repository -replace '\.git$', '') -ne $mirrorRepository) {
Set-Credentials $component.Repository $env:COMPONENTS_TOKEN
Expand All @@ -108,6 +125,18 @@ jobs:
"path=$workspace" >> $env:GITHUB_OUTPUT
"keep=$($keep -join ',')" >> $env:GITHUB_OUTPUT

- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
global-json-file: global.json

# The core and every component of the snapshot, as it will be pushed
- name: Check the marks
working-directory: ${{ steps.workspace.outputs.path }}
run: |
mkdir -p packages
dotnet run --project SDK/src/Stellar.Cli/Stellar.Cli.csproj -- marks check --all --stage release

- name: Snapshot and push
id: snapshot
shell: pwsh
Expand Down
41 changes: 29 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Release
# into the tag v<version> and a GitHub release of the core.
#
# The orchestra is released by the mirror: its workflow tags the snapshot with the same version and publishes the
# release the installer installs. With the secret STELLAR_DISPATCH_TOKEN (a fine-grained token allowed to run the
# Actions of the mirror) this workflow starts it at once; without it the release of the orchestra waits for the
# nightly run of the mirror, or for Run workflow there.
# release the installer installs. With the variable STELLAR_MIRROR_APP_ID and the secret STELLAR_MIRROR_APP_KEY (the app
# that writes the mirror, see mirror.yml) this workflow starts it at once; without them the release of the orchestra
# waits for Run workflow in the mirror. Merge the modules into their master before the core: a snapshot takes it.
#
# The mirror holds this file too, as everything of the core: it never runs there (STELLAR_MIRROR is 'true').

Expand All @@ -34,6 +34,17 @@ jobs:
with:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
global-json-file: global.json

# Nothing that a mark stops is released: a tag cannot be taken back
- name: Check the marks
run: |
mkdir -p packages
dotnet run --project SDK/src/Stellar.Cli/Stellar.Cli.csproj -- marks check --stage release

- name: Tag and publish
id: release
shell: pwsh
Expand Down Expand Up @@ -77,14 +88,20 @@ jobs:
if ($LASTEXITCODE -ne 0) { throw "gh release create $tag failed" }
"released=true" >> $env:GITHUB_OUTPUT

# Only a release starts the mirror. Without the app here, Run workflow in the mirror does it
- name: Token of the mirror app
id: app
if: steps.release.outputs.released == 'true' && vars.STELLAR_MIRROR_APP_ID != ''
uses: actions/create-github-app-token@v3
with:
client-id: ${{ vars.STELLAR_MIRROR_APP_ID }}
private-key: ${{ secrets.STELLAR_MIRROR_APP_KEY }}
owner: ${{ github.repository_owner }}
repositories: StellarEngine-Mono
permission-contents: write

- name: Start the mirror
if: steps.release.outputs.released == 'true'
if: steps.app.outputs.token != ''
env:
GH_TOKEN: ${{ secrets.STELLAR_DISPATCH_TOKEN }}
MIRROR: ${{ vars.STELLAR_MIRROR_REPOSITORY || 'QuantumDevTeam/StellarEngine-Mono' }}
run: |
if [ -z "$GH_TOKEN" ]; then
echo "::notice::No STELLAR_DISPATCH_TOKEN: the orchestra is released by the next run of the mirror ($MIRROR)"
exit 0
fi
gh workflow run mirror.yml --repo "$MIRROR" --ref master
GH_TOKEN: ${{ steps.app.outputs.token }}
run: gh api "repos/${{ github.repository_owner }}/StellarEngine-Mono/dispatches" -f event_type=orchestra-release
2 changes: 1 addition & 1 deletion Docs/Architecture/Runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ wins:
| `ModuleInitializationParallelism` | `1` | How many modules of one level start at once |
| `Verbose` | `false` | The runtime tells every step on the error output |

Settings the runtime does not know stay in `RuntimeConfiguration.Settings` for the modules.
Modules find all of them in `RuntimeConfiguration.Settings`, the command line included, by names in any case.

## Exit codes

Expand Down
47 changes: 47 additions & 0 deletions Docs/Engine/Marks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Marks

- [README.md](../../README.md)

A mark is metadata in a comment of the code: `#` and a name in angle brackets, capital letters, digits, `-` and `_`.
`MVP` as a mark in C# is a comment `// #` followed by `<MVP>`. It is found in comments only, in C#, C++, shaders,
PowerShell, shell, YAML, TOML, XML, MSBuild and Markdown files.

## Kinds

| File | Whose | Committed |
|---|---|---|
| `Shared/Marks/marks.json` | of the engine, the same for everyone | yes |
| `config/marks.json` | of one machine; adds kinds and replaces those of the engine | never, git ignores `config/` |

```json
{ "Marks": { "WIP": { "Level": "Release", "Description": "Not finished: it cannot be released" } } }
```

| Level | How far code with the mark goes |
|---|---|
| `Info` | anywhere |
| `Release` | into commits and `develop`, not into `master`, a release or the mirror |
| `Commit` | nowhere: not even into a commit |

A mark of a kind that is in neither file is stopped everywhere: a typing error, or a kind of another machine.

## Checking

```powershell
stellar marks install --all # git checks every commit, merge and push of the core, the modules and the tools
stellar marks list --all # where the marks are
stellar marks check # the files of this repository
stellar marks check --staged # what the next commit changes
stellar marks check --all --stage release
stellar marks uninstall --all
```

| Where | What it checks |
|---|---|
| the hooks of git | what is committed, merged and pushed |
| `.github/workflows/marks.yml` | every push to `develop` and `master` and every pull request; `master` as a release. A module calls the workflow of the core, `stellar modules new` writes it. Required by the rulesets |
| `.github/workflows/release.yml` | before a release is tagged |
| `.github/workflows/mirror.yml` | the core and every component, before a snapshot |

The hooks stop the commit when the `stellar` command is missing or older than the marks. They can be skipped with
`--no-verify`; the workflows cannot. A hook somebody else wrote is never replaced.
6 changes: 4 additions & 2 deletions Docs/Engine/Modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ stellar modules build --tests --pack
|---|---|
| `modules new` | Renders `Shared/Templates/Modules/<template>` into `modules/<Id>/`, with its documentation site (`Docs/`, `docfx.json`, a Pages workflow, a placeholder icon in `Branding/`), and syncs |
| `modules sync` | Finds the modules, applies the manifest, checks the rules, writes the catalog |
| `modules build` | For each module in load order, with the dependencies of the selected ones: native projects (MSBuild of Visual Studio), the managed project, the tests, the package |
| `modules build` | For each module in load order, with the dependencies of the selected ones: native projects (MSBuild of Visual Studio), the managed project, the package (`--pack`), the tests (`--tests`) |
| `modules list` | The modules in load order, where each came from, how it is linked |

`modules build --plan` shows the commands without running them; `--no-native`, `--wrapper Managed`,
`-c Release` change what is built.
`-c Release` change what is built. The order of `--tests` and `--pack` means nothing: the package always goes first.
In Debug the tests take the module from its sources; in Release they take the package, so `-c Release --tests` needs
`--pack` with it, or it fails without a package and tests the one packed last time when there is one.

A module developed in its own repository stays there:

Expand Down
16 changes: 9 additions & 7 deletions Docs/Engine/Repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,25 +182,27 @@ A release starts as a decision: a new `StellarOrchesterVersion` in `Shared/Build

1. a push of that version to `master` of the core: `.github/workflows/release.yml` sees a version without a tag, tags
the commit `v<version>` and publishes a GitHub release of the core with the versions of its components;
2. the next run of the mirror (`.github/workflows/mirror.yml`, nightly or Run workflow; at once with the secret
`STELLAR_DISPATCH_TOKEN` in the core) makes a snapshot with the new core, sees the same version without a tag in
the mirror, tags the snapshot `v<version>` and publishes the release of the orchestra: every component, its
version and its commit;
2. that release starts the mirror (`.github/workflows/mirror.yml`) when the core has `STELLAR_MIRROR_APP_ID` and
`STELLAR_MIRROR_APP_KEY`; without them Run workflow there does. It makes a snapshot with the new core, sees the same
version without a tag in the mirror, tags the snapshot `v<version>` and publishes the release of the orchestra:
every component, its version and its commit. It takes the default branch of each module, so the modules of a release
are merged there before the core;
3. the installer installs the latest release by default: it reads `.orchestra` at that tag.

A version with a suffix (`0.9.0-rc.1`) is a pre-release, which the installer takes only when asked for by name.

### The mirror regenerates itself

`.github/workflows/mirror.yml` runs in the mirror (where the repository variable `STELLAR_MIRROR` is `true`) every
night and on demand: it clones every component the last `.orchestra` names, at its default branch, makes a snapshot
`.github/workflows/mirror.yml` runs in the mirror (where the repository variable `STELLAR_MIRROR` is `true`) on a
release of the core and on demand, never on a timer: it clones every component the last `.orchestra` names, at its default branch, makes a snapshot
when anything changed and pushes it, which starts the docs workflow. A component it cannot clone (a private repository) is
kept as the mirror has it (`scripts/mirror.ps1 -Keep`); the secret `STELLAR_MIRROR_TOKEN` lets it read private ones
too. The first snapshot comes from a machine: `scripts/mirror.ps1 -Push`.

The rulesets of the mirror let nobody write its branch, so the workflow pushes with the token of a GitHub App, installed
on the mirror only and in the bypass list of the ruleset (`STELLAR_MIRROR_APP_ID`, `STELLAR_MIRROR_APP_KEY`). The token
of a workflow does not do: it passes no ruleset, and cannot change the files of `.github/workflows/`.
of a workflow does not do: it passes no ruleset, and cannot change the files of `.github/workflows/`. Run workflow takes
a new component in its `add` field, `modules/<Name>` or `tools/<Name>`: a public repository of the organization.

After that the workflow is the only writer of the mirror: on a machine, `scripts/mirror.ps1` without `-Push` shows
what the next snapshot would be, and Run workflow publishes it. A snapshot is always made on top of the last one of
Expand Down
2 changes: 2 additions & 0 deletions Docs/Engine/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
href: Repository.md
- name: Setting up the machine
href: PostInstallSetup.md
- name: Marks
href: Marks.md
- name: Project
items:
- name: README
Expand Down
19 changes: 11 additions & 8 deletions Kernel/src/Managed/Stellar.Kernel/LoggingSystem/ILogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,34 @@
namespace Stellar.Kernel.LoggingSystem;

/// <summary>
/// Engine logger
/// Takes messages: the logger of an engine, or one of those it gives them to (<see cref="ILoggerCatalog"/>).
/// </summary>
/// <remarks>
/// Every member is safe to call from any thread. <c>LoggerExtensions</c> has a method for every level.
/// </remarks>
public interface ILogger
: IQuant
{
/// <summary>
/// Create log with formatting
/// Logs a message in the format of its level (<see cref="LoggerFormat"/>).
/// </summary>
/// <param name="level">Log level</param>
/// <param name="message">Log message</param>
/// <param name="level">How serious the message is.</param>
/// <param name="message">The message.</param>
void Log(LogLevel level, string message);

/// <summary>
/// Create log without formatting
/// Logs a message as it is: no format and no level, so no level turns it away.
/// </summary>
/// <param name="message">just message to write</param>
/// <param name="message">The message.</param>
void LogWithoutFormat(string message);

/// <summary>
/// TODO: summary
/// Starts taking messages. A logger may be started again after <see cref="Stop"/>.
/// </summary>
void Start();

/// <summary>
/// TODO: summary
/// Stops taking messages, and writes out the ones taken before.
/// </summary>
void Stop();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
namespace Stellar.Kernel.LoggingSystem;

/// <summary>
/// TODO: summary
/// The loggers of one engine, by name: where its messages end up (a console, a file, a logger of a game).
/// </summary>
/// <remarks>
/// The logging module publishes it in the services of the engine. A module adds a logger when it starts and takes it
/// out when it stops; the one that added a logger owns it.
/// </remarks>
public interface ILoggerCatalog
: ICatalog<string, ILogger>;
32 changes: 19 additions & 13 deletions Kernel/src/Managed/Stellar.Kernel/LoggingSystem/LogFormat.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
namespace Stellar.Kernel.LoggingSystem;

/// <summary>
/// {0} - date yyyy-MMM-dd <br/>
/// {1} - time HH:mm:ss.fff <br/>
/// {2} - engine clock name <br/>
/// {3} - engine clock time HH:mm:ss.fff <br/>
/// {4} - LogLevel <br/>
/// {5} - Engine instance name <br/>
/// {6} - Logger instance name <br/>
/// {7} - Thread ID <br/>
/// {8} - C# Type name <br/>
/// {9} - C# Method name<br/>
/// {10} - message <br/>
/// The format of the lines of one level: a composite format string (<see cref="string.Format(string, object[])"/>).
/// </summary>
/// <param name="Format">Format string</param>
/// <param name="ColorizedFormat">Colorized Format string (ASCII)</param>
/// <remarks>
/// <list type="table">
/// <listheader><term>Placeholder</term><description>What it is</description></listheader>
/// <item><term>{0}</term><description>the date, yyyy-MM-dd</description></item>
/// <item><term>{1}</term><description>the time, HH:mm:ss.fff</description></item>
/// <item><term>{2}</term><description>the name of the engine clock</description></item>
/// <item><term>{3}</term><description>the time of the engine clock, HH:mm:ss.fff</description></item>
/// <item><term>{4}</term><description>the <see cref="LogLevel"/></description></item>
/// <item><term>{5}</term><description>the name of the engine</description></item>
/// <item><term>{6}</term><description>the name of the logger</description></item>
/// <item><term>{7}</term><description>the identifier of the managed thread</description></item>
/// <item><term>{8}</term><description>the type that logs; costs a walk of the stack, as {9} does</description></item>
/// <item><term>{9}</term><description>the method that logs</description></item>
/// <item><term>{10}</term><description>the message</description></item>
/// </list>
/// </remarks>
/// <param name="Format">The format string.</param>
/// <param name="ColorizedFormat">The same with ANSI colors, for consoles; <c>null</c> for none.</param>
public record struct LogFormat(string Format, string? ColorizedFormat = null);
Loading