doc: move cpu-core-count to node #809
This file contains 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
name: CI | |
# TODO: If these environment variables only affect Nix, should they be moved under the `formal-spec-check` job? | |
env: | |
ALLOWED_URIS: "https://github.com https://api.github.com" | |
TRUSTED_PUBLIC_KEYS: "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" | |
SUBSTITUTERS: "https://cache.nixos.org/ https://cache.iog.io" | |
on: | |
pull_request: | |
paths: | |
- "formal-spec/**" | |
- "simulation/**" | |
- "sim-rs/**" | |
- "data/**" | |
- "site/**" | |
- "docs/**" | |
- "cabal.project" | |
push: | |
branches: | |
- main | |
paths: | |
- "formal-spec/**" | |
- "simulation/**" | |
- "sim-rs/**" | |
- "data/**" | |
- "site/**" | |
- "docs/**" | |
- "cabal.project" | |
jobs: | |
################################################################################ | |
# Formal Specification in Agda - under /formal-spec/ | |
################################################################################ | |
formal-spec-typecheck: | |
name: "formal-spec: Typecheck" | |
if: | | |
github.event_name == 'push' && | |
contains(github.event.commits.*.modified, 'formal-spec/') || | |
github.event_name == 'pull_request' && | |
contains(github.event.pull_request.files.*.path, 'formal-spec/') | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: 📥 Checkout repository | |
uses: actions/checkout@v4 | |
- name: 💾 Cache Nix store | |
uses: actions/[email protected] | |
id: nix-cache | |
with: | |
path: /tmp/nixcache | |
key: ${{ runner.os }}-nix-typecheck-${{ hashFiles('flake.lock') }} | |
restore-keys: ${{ runner.os }}-nix-typecheck- | |
- name: 🛠️ Install Nix | |
uses: cachix/install-nix-action@v21 | |
with: | |
nix_path: nixpkgs=channel:nixos-unstable | |
install_url: https://releases.nixos.org/nix/nix-2.10.3/install | |
extra_nix_config: | | |
allowed-uris = ${{ env.ALLOWED_URIS }} | |
trusted-public-keys = ${{ env.TRUSTED_PUBLIC_KEYS }} | |
substituters = ${{ env.SUBSTITUTERS }} | |
experimental-features = nix-command flakes | |
- name: 💾➤ Import Nix store cache | |
if: "steps.nix-cache.outputs.cache-hit == 'true'" | |
run: "nix-store --import < /tmp/nixcache" | |
- name: 🏗️ Build specification | |
run: | | |
nix build --show-trace --accept-flake-config .#leiosSpec | |
- name: ➤💾 Export Nix store cache | |
if: "steps.nix-cache.outputs.cache-hit != 'true'" | |
run: "nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nixcache" | |
################################################################################ | |
# Simulation and Prototype in Haskell - under /simulation/ | |
################################################################################ | |
simulation-test: | |
name: "simulation: Test on ${{ matrix.os }} with GHC ${{ matrix.ghc-version }}" | |
if: | | |
github.event_name == 'push' && | |
(contains(github.event.commits.*.modified, 'simulation/') || | |
contains(github.event.commits.*.modified, 'data/') || | |
contains(github.event.commits.*.modified, 'cabal.project')) || | |
github.event_name == 'pull_request' && | |
(contains(github.event.pull_request.files.*.path, 'simulation/') || | |
contains(github.event.pull_request.files.*.path, 'data/') || | |
contains(github.event.pull_request.files.*.path, 'cabal.project')) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [macos-13, macos-14, ubuntu-22.04] | |
ghc-version: ["9.8"] | |
steps: | |
- name: 📥 Checkout repository | |
uses: actions/checkout@v4 | |
- name: 🛠️ Install GHC ${{ matrix.ghc-version }} | |
uses: haskell-actions/setup@v2 | |
id: setup | |
with: | |
ghc-version: ${{ matrix.ghc-version }} | |
# Defaults, added for clarity: | |
cabal-version: "latest" | |
cabal-update: true | |
- name: 🛠️ Install system dependencies (Linux) | |
if: runner.os == 'Linux' | |
run: sudo apt-get install -y graphviz libpango1.0-dev libgtk-3-dev | |
- name: 🛠️ Install system dependencies (macOS) | |
if: runner.os == 'macOS' | |
run: brew install graphviz gtk+3 pango | |
- name: 🛠️ Configure | |
run: | | |
cabal configure --enable-tests --enable-benchmarks --disable-documentation | |
cabal build all --dry-run | |
# The last step generates dist-newstyle/cache/plan.json for the cache key. | |
- name: 💾➤ Restore dependency cache | |
uses: actions/cache/restore@v4 | |
id: cache | |
env: | |
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }} | |
with: | |
path: ${{ steps.setup.outputs.cabal-store }} | |
key: ${{ env.key }}-plan-${{ hashFiles('dist-newstyle/cache/plan.json') }} | |
restore-keys: ${{ env.key }}- | |
- name: 🛠️ Install Cabal dependencies | |
# If we had an exact cache hit, the dependencies will be up to date. | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: cabal build all --only-dependencies | |
# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail. | |
- name: ➤💾 Save dependency cache | |
uses: actions/cache/save@v4 | |
# If we had an exact cache hit, trying to save the cache would error because of key clash. | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
path: ${{ steps.setup.outputs.cabal-store }} | |
key: ${{ steps.cache.outputs.cache-primary-key }} | |
- name: 🏗️ Build | |
run: cabal build all | |
- name: 🏗️ Test | |
run: cabal test all | |
simulation-hlint: | |
name: "simulation: Check with HLint" | |
if: | | |
github.event_name == 'push' && | |
(contains(github.event.commits.*.modified, 'simulation/') || | |
contains(github.event.commits.*.modified, 'data/') || | |
contains(github.event.commits.*.modified, 'cabal.project')) || | |
github.event_name == 'pull_request' && | |
(contains(github.event.pull_request.files.*.path, 'simulation/') || | |
contains(github.event.pull_request.files.*.path, 'data/') || | |
contains(github.event.pull_request.files.*.path, 'cabal.project')) | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: 📥 Checkout repository | |
uses: actions/checkout@v4 | |
- name: 🛠️ Set up HLint | |
uses: haskell-actions/hlint-setup@v2 | |
- name: 🛠️ Run HLint | |
uses: haskell-actions/hlint-run@v2 | |
with: | |
path: simulation/ | |
fail-on: warning | |
simulation-fourmolu: | |
name: "simulation: Check with fourmolu" | |
if: | | |
github.event_name == 'push' && | |
(contains(github.event.commits.*.modified, 'simulation/') || | |
contains(github.event.commits.*.modified, 'data/') || | |
contains(github.event.commits.*.modified, 'cabal.project')) || | |
github.event_name == 'pull_request' && | |
(contains(github.event.pull_request.files.*.path, 'simulation/') || | |
contains(github.event.pull_request.files.*.path, 'data/') || | |
contains(github.event.pull_request.files.*.path, 'cabal.project')) | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: 📥 Checkout repository | |
uses: actions/checkout@v4 | |
- name: 🛠️ Run fourmolu | |
uses: haskell-actions/run-fourmolu@v11 | |
with: | |
version: "0.15.0.0" | |
################################################################################ | |
# Simulation in Rust - under /sim-rs/ | |
################################################################################ | |
sim-rs-check: | |
name: "sim-rs: Test" | |
if: | | |
github.event_name == 'push' && | |
(contains(github.event.commits.*.modified, 'sim-rs/') || | |
contains(github.event.commits.*.modified, 'data/')) || | |
github.event_name == 'pull_request' && | |
(contains(github.event.pull_request.files.*.path, 'sim-rs/') || | |
contains(github.event.pull_request.files.*.path, 'data/')) | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Test Rust packages | |
working-directory: sim-rs | |
run: | | |
cargo test | |
if [ $? -ne 0 ]; then | |
echo "Cargo test failed" | |
exit 1 | |
fi | |
################################################################################ | |
# Tools - Topology checker | |
################################################################################ | |
topology-checker-check: | |
name: "topology-checker: Check and Test" | |
if: | | |
github.event_name == 'push' && | |
(contains(github.event.commits.*.modified, 'topology-checker/') || | |
contains(github.event.commits.*.modified, 'data/simulation/topology*.yaml') || | |
contains(github.event.commits.*.modified, 'data/simulation/topology*.json')) || | |
github.event_name == 'pull_request' && | |
(contains(github.event.pull_request.files.*.path, 'topology-checker/') || | |
contains(github.event.pull_request.files.*.path, 'data/simulation/topology*.yaml') || | |
contains(github.event.pull_request.files.*.path, 'data/simulation/topology*.json')) | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check and test topology checker | |
working-directory: topology-checker | |
run: | | |
cargo check | |
cargo test | |
if [ $? -ne 0 ]; then | |
echo "Topology checker tests failed" | |
exit 1 | |
fi | |
################################################################################ | |
# Documentation - under various directories | |
################################################################################ | |
docs-generate-d2-diagrams: | |
name: "docs: Generate D2 Diagrams" | |
if: | | |
github.event_name == 'push' && | |
endsWith(github.event.commits.*.modified, '.d2') || | |
github.event_name == 'pull_request' && | |
endsWith(github.event.pull_request.files.*.path, '.d2') | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: write | |
steps: | |
- name: 📥 Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref || github.ref_name }} | |
fetch-depth: 2 # Needed to get previous commit for comparison | |
- name: Install D2 | |
run: | | |
curl -fsSL https://d2lang.com/install.sh | sh -s -- | |
d2 --version | |
- name: Generate PNG files for changed D2 files | |
run: | | |
# Get list of changed .d2 files | |
CHANGED_FILES=$(git diff --name-only HEAD^ HEAD | grep '\.d2$' || true) | |
if [ -z "$CHANGED_FILES" ]; then | |
echo "No .d2 files were changed" | |
exit 0 | |
fi | |
echo "Changed .d2 files:" | |
echo "$CHANGED_FILES" | |
# Process each changed file | |
echo "$CHANGED_FILES" | while read -r file; do | |
if [ -f "$file" ]; then | |
output_file="${file%.d2}.png" | |
echo "Converting $file to $output_file" | |
d2 "$file" "$output_file" | |
fi | |
done | |
- name: Check for changes | |
id: changes | |
run: | | |
git add *.png | |
if git diff --staged --quiet; then | |
echo "No changes to commit" | |
echo "has_changes=false" >> $GITHUB_OUTPUT | |
else | |
echo "Changes detected" | |
echo "has_changes=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Commit and push changes | |
if: steps.changes.outputs.has_changes == 'true' | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git commit -m "Auto-generate diagram PNGs [skip ci]" | |
git push origin HEAD:${{ github.head_ref || github.ref_name }} | |
docs-build: | |
name: "docs: Build" | |
if: | | |
github.event_name == 'push' && | |
contains(github.event.commits.*.modified, 'site/') || | |
github.event_name == 'pull_request' && | |
contains(github.event.pull_request.files.*.path, 'site/') | |
runs-on: ubuntu-22.04 | |
outputs: | |
has_changes: ${{ steps.check_changes.outputs.has_changes }} | |
steps: | |
- name: 📥 Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Check for site changes | |
id: check_changes | |
run: | | |
SITE_CHANGES=$(git diff --name-only HEAD^ HEAD -- site/ || true) | |
if [ -z "$SITE_CHANGES" ]; then | |
echo "No changes in site directory" | |
echo "has_changes=false" >> $GITHUB_OUTPUT | |
else | |
echo "Changes detected in site directory:" | |
echo "$SITE_CHANGES" | |
echo "has_changes=true" >> $GITHUB_OUTPUT | |
fi | |
- name: 🛠️ Setup Node.js | |
if: steps.check_changes.outputs.has_changes == 'true' | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: "yarn" | |
cache-dependency-path: site/yarn.lock | |
- name: 📦 Install dependencies | |
if: steps.check_changes.outputs.has_changes == 'true' | |
working-directory: site | |
run: yarn install | |
- name: 🏗️ Build Docusaurus site | |
if: steps.check_changes.outputs.has_changes == 'true' | |
working-directory: site | |
run: | | |
yarn build | |
- name: 🚀 Publish Docusaurus build | |
if: steps.check_changes.outputs.has_changes == 'true' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docusaurus-build | |
if-no-files-found: error | |
path: | | |
site/build/* | |
docs-publish: | |
name: "docs: Publish" | |
if: | | |
github.ref == 'refs/heads/main' && | |
needs.docs-build.outputs.has_changes == 'true' | |
runs-on: ubuntu-22.04 | |
needs: docs-build | |
steps: | |
- name: 📥 Download Docusaurus build | |
uses: actions/download-artifact@v4 | |
with: | |
name: docusaurus-build | |
path: ./github-pages | |
- name: 🚀 Publish GitHub Pages | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN || github.token }} | |
publish_dir: ./github-pages | |
cname: leios.cardano-scaling.org |