mirror of
https://github.com/logos-co/logos-libp2p-module.git
synced 2026-08-31 01:41:12 +00:00
125 lines
3.3 KiB
YAML
125 lines
3.3 KiB
YAML
name: Tutorial CI
|
|
|
|
on:
|
|
push:
|
|
branches: [ master ]
|
|
paths:
|
|
- 'tutorial/**'
|
|
- 'src/**'
|
|
- 'CMakeLists.txt'
|
|
- 'tutorial/CMakeLists.txt'
|
|
pull_request:
|
|
paths:
|
|
- 'tutorial/**'
|
|
- 'src/**'
|
|
- 'CMakeLists.txt'
|
|
- 'tutorial/CMakeLists.txt'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: tutorial-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
NIX_CONFIG: |
|
|
experimental-features = nix-command flakes
|
|
|
|
jobs:
|
|
compile-check:
|
|
name: Compile and Smoke check (${{ matrix.name }})
|
|
runs-on: ${{ matrix.runner }}
|
|
timeout-minutes: 30
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- name: Linux (x86_64-linux)
|
|
runner: ubuntu-latest
|
|
system: x86_64-linux
|
|
|
|
- name: macOS (aarch64-darwin)
|
|
runner: macos-latest
|
|
system: aarch64-darwin
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Install Nix
|
|
uses: DeterminateSystems/nix-installer-action@v12
|
|
|
|
- name: Setup Nix Cache
|
|
uses: DeterminateSystems/magic-nix-cache-action@v5
|
|
with:
|
|
use-flakehub: false
|
|
|
|
- name: Build tutorials inside Nix dev shell
|
|
run: |
|
|
nix develop --command ./tutorial/build_tutorials.sh
|
|
|
|
# Run tutorials after compilation as a simple check that the tutorial code is also correct.
|
|
- name: Run tutorial examples inside Nix dev shell
|
|
run: |
|
|
nix develop --command bash -c '
|
|
set -euo pipefail
|
|
shopt -s nullglob
|
|
|
|
tutorial_binaries=(./build/tutorial/tutorial_*)
|
|
if [[ ${#tutorial_binaries[@]} -eq 0 ]]; then
|
|
echo "No tutorial binaries found in ./build/tutorial/"
|
|
exit 1
|
|
fi
|
|
|
|
ran_any=0
|
|
for tutorial_binary in "${tutorial_binaries[@]}"; do
|
|
if [[ ! -f "${tutorial_binary}" || ! -x "${tutorial_binary}" ]]; then
|
|
continue
|
|
fi
|
|
|
|
echo "Running ${tutorial_binary}"
|
|
"${tutorial_binary}"
|
|
ran_any=1
|
|
done
|
|
|
|
if [[ "${ran_any}" -eq 0 ]]; then
|
|
echo "No executable tutorial binaries found in ./build/tutorial/"
|
|
exit 1
|
|
fi
|
|
'
|
|
|
|
markdown-check:
|
|
name: Markdown freshness check
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 15
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Generate markdown from tutorial sources
|
|
run: |
|
|
chmod +x ./tutorial/generate_markdown.sh
|
|
rm -rf ./tutorial/docs
|
|
./tutorial/generate_markdown.sh
|
|
|
|
- name: Check git diff (no changes expected)
|
|
run: |
|
|
if ! git diff --quiet -- ./tutorial/docs/; then
|
|
echo "❌ Generated markdown does not match committed version."
|
|
echo ""
|
|
echo "Differences found:"
|
|
git diff -- ./tutorial/docs/
|
|
echo ""
|
|
echo "Run './tutorial/generate_markdown.sh' locally and commit the updated docs/"
|
|
exit 1
|
|
fi
|
|
echo "✅ Generated markdown matches committed version."
|