Repository navigation
feat: mortsom list --json and a reusable app e2e workflow #123
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
092c117
feat: add mortsom list --json, the catalog pull request gates select …
grunch a910d7e
ci: add the reusable app e2e workflow
grunch c475470
fix: harden list --json and the app e2e workflow after review
grunch dc391f4
ci: fail an app e2e run that executed no scenario
grunch 48252ab
ci: a blank scenarios input runs the tag, not every scenario
grunch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,201 @@ | ||
| # End-to-end run of the Mostro app (profile `mobile-v2`, Linux desktop) | ||
| # against a regtest stack this job builds itself: worthless sats and no | ||
| # secrets, so it runs on GitHub-hosted runners. | ||
| # | ||
| # - Reusable (`workflow_call`): MostroP2P/app's Mortsom pull request gate | ||
| # calls it with the app ref and the scenarios its map selected. | ||
| # - By hand (`workflow_dispatch`) for any app branch or pull request. | ||
| # - On pull requests that change this file, with the smoke suite, so a | ||
| # change to the job is exercised before it merges. | ||
| # | ||
| # Every input reaches the scripts through the environment, never through | ||
| # expression interpolation, and the job holds no secret and a read-only | ||
| # token: the app code it builds and runs is untrusted. | ||
| name: app e2e | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| app_ref: | ||
| description: App branch or https://github.com/MostroP2P/app/pull/<number> | ||
| type: string | ||
| required: true | ||
| scenarios: | ||
| description: Scenario names, space separated; empty runs `tag` | ||
| type: string | ||
| default: "" | ||
| tag: | ||
| description: Scenario tag to run when `scenarios` is empty | ||
| type: string | ||
| default: smoke | ||
| bond: | ||
| description: Run on a daemon with anti-abuse bonds (the `bond` family) | ||
| type: boolean | ||
| default: false | ||
| mortsom_ref: | ||
| description: Mortsom ref to build (the caller pins it) | ||
| type: string | ||
| default: main | ||
| artifact_name: | ||
| description: Name of the uploaded summaries artifact | ||
| type: string | ||
| default: app-e2e-summaries | ||
| workflow_dispatch: | ||
| inputs: | ||
| app_ref: | ||
| description: App branch or https://github.com/MostroP2P/app/pull/<number> | ||
| required: false | ||
| default: main | ||
| scenarios: | ||
| description: Scenario names, space separated; empty runs `tag` | ||
| required: false | ||
| default: "" | ||
| tag: | ||
| description: Scenario tag to run when `scenarios` is empty | ||
| required: false | ||
| default: smoke | ||
| bond: | ||
| description: Run on a daemon with anti-abuse bonds (the `bond` family) | ||
| type: boolean | ||
| default: false | ||
| pull_request: | ||
| paths: | ||
| - ".github/workflows/app-e2e.yml" | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| app: | ||
| name: mobile-v2 on Linux (${{ inputs.app_ref || 'main' }}) | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 300 | ||
| env: | ||
| APP_REF: ${{ inputs.app_ref || 'main' }} | ||
| SCENARIOS: ${{ inputs.scenarios || '' }} | ||
| TAG: ${{ inputs.tag || 'smoke' }} | ||
| BOND: ${{ inputs.bond && 'true' || 'false' }} | ||
| MORTSOM: ./target/release/mortsom | ||
| # Versions the app's own CI pins (MostroP2P/app .github/workflows/ci.yml). | ||
| FLUTTER_VERSION: "3.41.9" | ||
| FRB_VERSION: "2.11.1" | ||
| CARGO_EXPAND_VERSION: "1.0.123" | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| # Called from the app, the default would be the app repository. | ||
| repository: MostroP2P/mortsom | ||
| ref: ${{ inputs.mortsom_ref || github.sha }} | ||
| persist-credentials: false | ||
| - name: System packages | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y --no-install-recommends protobuf-compiler \ | ||
| clang libclang-dev lld cmake ninja-build pkg-config libgtk-3-dev libsecret-1-dev \ | ||
| xvfb dbus dbus-x11 gnome-keyring at-spi2-core imagemagick | ||
| - uses: dtolnay/rust-toolchain@stable | ||
| - uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| # Only runs of Mortsom's own main save the cache. | ||
| save-if: ${{ github.repository == 'MostroP2P/mortsom' && github.ref == 'refs/heads/main' }} | ||
| - uses: subosito/flutter-action@v2 | ||
| with: | ||
| flutter-version: ${{ env.FLUTTER_VERSION }} | ||
| channel: stable | ||
| # The app code this job builds is untrusted: never save a cache it | ||
| # could have written into. | ||
| cache: false | ||
| - uses: taiki-e/install-action@v2 | ||
| with: | ||
| tool: cargo-expand@${{ env.CARGO_EXPAND_VERSION }},flutter_rust_bridge_codegen@${{ env.FRB_VERSION }} | ||
| - name: Build Mortsom | ||
| run: cargo build --release --locked -p mortsom-coordinator --bin mortsom | ||
| - name: Regtest stack | ||
| run: | | ||
| if [ "$BOND" = true ]; then | ||
| $MORTSOM stack up --bond | ||
| else | ||
| $MORTSOM stack up | ||
| fi | ||
| - name: Preflight | ||
| run: $MORTSOM doctor --platform linux --ref "$APP_REF" | ||
| - name: Run | ||
| run: | | ||
| start=$(date +%s) | ||
| # Split into names without globbing, and accept only scenario | ||
| # names: nothing here may become a flag. A blank list falls back | ||
| # to the tag, never to the whole registry. | ||
| set -f | ||
| read -r -a names <<< "$SCENARIOS" | ||
| if [ ${#names[@]} -gt 0 ]; then | ||
| for name in "${names[@]}"; do | ||
| if ! [[ "$name" =~ ^[a-z0-9_]+$ ]]; then | ||
| echo "::error::not a scenario name: $name" | ||
| exit 2 | ||
| fi | ||
| done | ||
| $MORTSOM run --platform linux --ref "$APP_REF" "${names[@]}" || status=$? | ||
| else | ||
| $MORTSOM run --platform linux --ref "$APP_REF" --tag "$TAG" || status=$? | ||
| fi | ||
| echo "run took $(( $(date +%s) - start )) s" | tee -a "$GITHUB_STEP_SUMMARY" | ||
| exit "${status:-0}" | ||
| - name: Require an executed scenario | ||
| # A run whose every scenario was skipped (a bond selection on a plain | ||
| # stack, an interruption scenario on Linux) tested nothing. | ||
| run: | | ||
| shopt -s nullglob | ||
| summaries=(artifacts/*/summary.json) | ||
| executed=0 | ||
| if [ ${#summaries[@]} -gt 0 ]; then | ||
| executed=$(jq -s '[.[].results[]? | select(.outcome.outcome != "skipped")] | length' "${summaries[@]}") | ||
| fi | ||
| if [ "$executed" -eq 0 ]; then | ||
| echo "::error::no selected scenario executed: every one was skipped, or none ran" | ||
| exit 1 | ||
| fi | ||
| - name: Collect summaries | ||
| if: always() | ||
| run: | | ||
| mkdir -p summaries | ||
| shopt -s nullglob | ||
| for f in artifacts/*/summary.json; do | ||
| cp "$f" "summaries/$(basename "$(dirname "$f")").json" | ||
| done | ||
| ls summaries | ||
| - uses: actions/upload-artifact@v4 | ||
| if: always() | ||
| with: | ||
| name: ${{ inputs.artifact_name || 'app-e2e-summaries' }} | ||
| path: summaries | ||
| if-no-files-found: warn | ||
| retention-days: 30 | ||
| - name: Cleanup what the run may have left | ||
| if: always() | ||
| run: | | ||
| shopt -s nullglob | ||
| for dir in artifacts/*/; do | ||
| run=$(basename "$dir") | ||
| [ "$run" = accounting ] && continue | ||
| $MORTSOM cleanup "$run" || echo "::warning::cleanup of $run failed; the stack is discarded with the runner" | ||
| done | ||
| - name: Publish sanitized evidence | ||
| if: always() | ||
| run: | | ||
| mkdir -p bundle | ||
| shopt -s nullglob | ||
| for dir in artifacts/*/; do | ||
| run=$(basename "$dir") | ||
| [ "$run" = accounting ] && continue | ||
| $MORTSOM publish "$run" --out "bundle/$run" --screenshots all || true | ||
| done | ||
| - uses: actions/upload-artifact@v4 | ||
| if: always() | ||
| with: | ||
| name: ${{ inputs.artifact_name || 'app-e2e-summaries' }}-evidence | ||
| path: bundle | ||
| if-no-files-found: ignore | ||
| retention-days: 14 | ||
| - name: Stack down | ||
| if: always() | ||
| run: $MORTSOM stack down || true | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the selected scenarios cannot run on the configured stack—for example,
tag: bondwith the defaultbond: false—this workflow can finish green without executing any scenario.gate_bondskips that selection, andReport::code()returns success when there are no failures, consistent with the README's documented exit-status semantics. The Run step forwards that status, while Collect summaries only copies the results without checking them. Add an executed-result check before accepting the job, as.github/workflows/cli-e2e.ymlalready does, so an incompatible selection cannot produce a successful end-to-end check.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in dc391f4: a new "Require an executed scenario" step fails the job when the summaries hold no executed (non-skipped) scenario, as cli-e2e.yml does. Also took CodeRabbit's nitpicks there: glob loops instead of
ls | grep, and a note thatmortsom_ref/artifact_nameexist only forworkflow_call; the unquoted$SCENARIOSone was already fixed in c475470.