name: Check the getting-started.sh script # This workflow aims to make sure that the `getting-started.sh` script # is functional and allows to build the templates # on different operating systems. # # There are two jobs inside. # One for systems that can run in a docker container, and one for macOS. # # Each job consists of: # 1. Some necessary prerequisites for the workflow itself. # 2. A first pass of the script, which will install dependencies and clone a template. # 3. A second pass of the script, to make sure the behaviour is as expected. # 4. Building the template - making sure it's buildable and runnable. # # The script is interacted with using the `expect` tool, which is available on all relevant systems. # The steps are not re-used between macOS and other systems, # because they are very similar but a little different. # Additionally, macOS does NOT start from scratch here - for example, we have homebrew already installed. # # There are many combinations of systems, shells and templates. # We test a selected handful of combinations here. on: pull_request: paths: - ".github/workflows/check-getting-started.yml" - "scripts/getting-started.sh" types: [opened, synchronize, reopened, ready_for_review] schedule: - cron: "0 5 * * *" workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: isdraft: uses: ./.github/workflows/reusable-isdraft.yml check-getting-started: needs: isdraft strategy: fail-fast: true matrix: include: - name: ubuntu container: ubuntu template: minimal package: pez-minimal-template-node shell: bash - name: debian container: debian template: teyrchain package: teyrchain-template-node shell: sh - name: arch container: archlinux template: solochain package: pez-solochain-template-node shell: sh - name: fedora container: fedora template: teyrchain package: teyrchain-template-node shell: sh - name: opensuse container: opensuse/tumbleweed template: solochain package: pez-solochain-template-node shell: sh runs-on: ubuntu-latest container: ${{ matrix.container }}:latest env: # Use local templates from the repo instead of cloning from external repos PEZKUWI_TEMPLATE_SOURCE: ${{ github.workspace }}/templates # Skip WASM build due to serde_core compatibility issues SKIP_WASM_BUILD: 1 # Fix HOME directory mismatch in containers (rustup requires this) HOME: /root steps: # A minimal amount of prerequisites required before we can run the actual getting-started script, # which will install the rest of requirements. - name: Install ubuntu/debian prerequisites run: apt update && apt install -y expect sudo git if: contains(matrix.name, 'ubuntu') || contains(matrix.name, 'debian') - name: Install arch prerequisites run: pacman -Syu --needed --noconfirm expect sudo git if: contains(matrix.name, 'arch') - name: Install fedora prerequisites run: dnf --assumeyes install expect sudo git if: contains(matrix.name, 'fedora') - name: Install opensuse prerequisites run: zypper install --no-confirm expect sudo git if: contains(matrix.name, 'opensuse') - name: Checkout uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - name: Set additional expect flags if necessary run: | # Add a debug flag to expect, if github is re-run with debug logging enabled. [ "${{ runner.debug }}" = "1" ] && EXPECT_FLAGS="-d" || EXPECT_FLAGS="" echo "EXPECT_FLAGS=${EXPECT_FLAGS}" >> $GITHUB_ENV - name: Check the first run of the script run: | expect $EXPECT_FLAGS -c ' set timeout 240 spawn ${{ matrix.shell }} scripts/getting-started.sh expect_after { timeout { puts stderr "Timed out on an expect"; exit 1 } eof { puts stderr "EOF received on an expect"; exit 1 } } expect -nocase "Detected ${{ matrix.name }}" expect "*Rust is not installed. Install it?*" { send "y\r" # rustup runs with -y flag (non-interactive), so no "Proceed" prompt expect "Rust is installed now" } expect "*Setup the Rust environment*" { send "y\r" } expect "start with one of the templates" { send "y\r" } expect -re "(.)\\) ${{ matrix.template }} template" { send "$expect_out(1,string)\r" } expect "*compile the node?*" { send "n\r" } expect eof ' timeout-minutes: 15 - name: Check the second run of the script run: | expect $EXPECT_FLAGS -c ' set timeout 120 spawn ${{ matrix.shell }} scripts/getting-started.sh expect_after { timeout { puts stderr "Timed out on an expect"; exit 1 } eof { puts stderr "EOF received on an expect"; exit 1 } } expect "Rust already installed" {} expect "*Setup the Rust environment*" { send "n\r" } expect "start with one of the templates" { send "y\r" } expect -re "(.)\\) ${{ matrix.template }} template" { send "$expect_out(1,string)\r" expect "directory already exists" {} } expect "*compile the node?*" { send "n\r" } expect eof ' timeout-minutes: 15 # Build the template from within the SDK workspace context # Templates use workspace inheritance and can't be built standalone # Note: Use $GITHUB_WORKSPACE env var, not ${{ github.workspace }} template # because inside containers the template expands to host path which doesn't exist - name: Compile the template node run: | . "$HOME/.cargo/env" cd "$GITHUB_WORKSPACE" cargo build --release -p ${{ matrix.package }} timeout-minutes: 120 - name: Check that the binary is executable run: | . "$HOME/.cargo/env" cd "$GITHUB_WORKSPACE" cargo run --release -p ${{ matrix.package }} -- --help timeout-minutes: 5 check-getting-started-macos: needs: isdraft strategy: fail-fast: true matrix: include: - template: teyrchain package: teyrchain-template-node shell: sh - template: solochain package: pez-solochain-template-node shell: bash runs-on: macos-latest env: # Use local templates from the repo instead of cloning from external repos PEZKUWI_TEMPLATE_SOURCE: ${{ github.workspace }}/templates # Skip WASM build due to serde_core compatibility issues SKIP_WASM_BUILD: 1 steps: - name: Checkout uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - name: Install LLVM (provides libclang for rocksdb) run: | brew install llvm echo "LIBCLANG_PATH=$(brew --prefix llvm)/lib" >> $GITHUB_ENV - name: Set additional expect flags if necessary run: | # Add a debug flag to expect, if github is re-run with debug logging enabled. [ "${{ runner.debug }}" = "1" ] && EXPECT_FLAGS="-d" || EXPECT_FLAGS="" echo "EXPECT_FLAGS=${EXPECT_FLAGS}" >> $GITHUB_ENV - name: Check the first run of the script run: | expect $EXPECT_FLAGS -c ' set timeout 120 spawn ${{ matrix.shell }} scripts/getting-started.sh expect_after { timeout { puts stderr "Timed out on an expect"; exit 1 } eof { puts stderr "EOF received on an expect"; exit 1 } } expect -nocase "Detected macOS" expect "Homebrew already installed" expect "Install cmake" { send "y\r" } expect "Rust already installed" {} expect "*Setup the Rust environment*" { send "y\r" } expect "start with one of the templates" { send "y\r" } expect -re "(.)\\) ${{ matrix.template }} template" { send "$expect_out(1,string)\r" } expect "*compile the node?*" { send "n\r" } expect eof ' timeout-minutes: 15 - name: Check the second run of the script run: | expect $EXPECT_FLAGS -c ' set timeout 120 spawn ${{ matrix.shell }} scripts/getting-started.sh expect_after { timeout { puts stderr "Timed out on an expect"; exit 1 } eof { puts stderr "EOF received on an expect"; exit 1 } } expect "Homebrew already installed" expect "Install cmake" { send "y\r" } expect "Rust already installed" {} expect "*Setup the Rust environment*" { send "n\r" } expect "start with one of the templates" { send "y\r" } expect -re "(.)\\) ${{ matrix.template }} template" { send "$expect_out(1,string)\r" expect "directory already exists" {} } expect "*compile the node?*" { send "n\r" } expect eof ' timeout-minutes: 15 # Build the template from within the SDK workspace context # Templates use workspace inheritance and can't be built standalone # Note: Use $GITHUB_WORKSPACE env var, not ${{ github.workspace }} template # because inside containers the template expands to host path which doesn't exist - name: Compile the template node run: | . "$HOME/.cargo/env" cd "$GITHUB_WORKSPACE" cargo build --release -p ${{ matrix.package }} timeout-minutes: 120 - name: Check that the binary is executable run: | . "$HOME/.cargo/env" cd "$GITHUB_WORKSPACE" cargo run --release -p ${{ matrix.package }} -- --help timeout-minutes: 5