Plan 9 from Bell Labs’s /usr/web/sources/contrib/yk/rd/.github/workflows/ci.yml

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


name: CI

on:
  push:
  pull_request:

env:
  PLAN9: /opt/plan9port
  PLAN9FRONT: /opt/9front
  PLAN9LEGACY: /opt/9legacy

permissions:
  contents: read

jobs:
  setup:
    name: Set up plan9port
    runs-on: ubuntu-latest
    steps:
      - name: Cache plan9port
        id: cache-plan9port
        uses: actions/cache@v4
        with:
          path: ${{ env.PLAN9 }}
          key: plan9port-${{ runner.os }}-v1
      - name: Install plan9port build dependencies
        run: sudo apt-get install -y gcc libx11-dev libxt-dev libxext-dev libfontconfig1-dev
      - name: Build plan9port
        if: steps.cache-plan9port.outputs.cache-hit != 'true'
        run: |
          git clone --depth=1 https://github.com/9fans/plan9port $PLAN9
          cd $PLAN9
          ./INSTALL

  test:
    name: Test (plan9port)
    needs: setup
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Restore plan9port cache
        uses: actions/cache@v4
        with:
          path: ${{ env.PLAN9 }}
          key: plan9port-${{ runner.os }}-v1
      - name: Add plan9port to PATH
        run: echo "$PLAN9/bin" >> $GITHUB_PATH
      - name: Install OpenSSL
        run: sudo apt-get install -y libssl-dev pkg-config
      - name: Run tests
        run: mk test

  build:
    name: Build (plan9port)
    needs: setup
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Restore plan9port cache
        uses: actions/cache@v4
        with:
          path: ${{ env.PLAN9 }}
          key: plan9port-${{ runner.os }}-v1
      - name: Add plan9port to PATH
        run: echo "$PLAN9/bin" >> $GITHUB_PATH
      - name: Install OpenSSL
        run: sudo apt-get install -y libssl-dev pkg-config
      - name: Build o.thread
        run: mk o.thread

  setup-9front:
    name: Set up 9front
    runs-on: ubuntu-latest
    steps:
      - name: Cache 9front
        id: cache-9front
        uses: actions/cache@v4
        with:
          path: ${{ env.PLAN9FRONT }}
          key: 9front-v3-${{ runner.os }}
      - name: Install dependencies
        if: steps.cache-9front.outputs.cache-hit != 'true'
        run: sudo apt-get install -y build-essential
      - name: Download 9front ISO
        if: steps.cache-9front.outputs.cache-hit != 'true'
        run: |
          mkdir -p $PLAN9FRONT
          BASE="http://9front.org"
          url="/releases/"
          ISO_URL=""
          for _ in $(seq 6); do
            page=$(curl -fsSL "$BASE$url")
            iso=$(printf '%s\n' "$page" | grep -Eo 'https?://9front\.org/iso/[^ "<]+amd64[^ "<]+\.torrent' | head -1 | sed 's/\.torrent$//')
            if [ -n "$iso" ]; then ISO_URL="$iso"; break; fi
            iso=$(printf '%s\n' "$page" | grep -Eo 'https?://9front\.org/iso/[^ "<]+amd64[^ "<]+\.(iso\.gz|iso)' | grep -v torrent | head -1)
            if [ -n "$iso" ]; then ISO_URL="$iso"; break; fi
            next=$(printf '%s\n' "$page" | grep -Eo "href=\"${url}[^/\"]+/\"" | sort | tail -1 | sed 's/href="\([^"]*\)"/\1/')
            [ -z "$next" ] && break
            url="$next"
          done
          if [ -z "$ISO_URL" ]; then
            echo "Could not find amd64 ISO URL under http://9front.org/releases/" >&2
            exit 1
          fi
          echo "Downloading: $ISO_URL"
          curl -fL -o /tmp/9front.iso.tmp "$ISO_URL"
          if echo "$ISO_URL" | grep -q '\.gz$'; then
            gunzip -c /tmp/9front.iso.tmp > /tmp/9front.iso
            rm /tmp/9front.iso.tmp
          else
            mv /tmp/9front.iso.tmp /tmp/9front.iso
          fi
      - name: Extract 9front root and kernel
        if: steps.cache-9front.outputs.cache-hit != 'true'
        run: |
          sudo mkdir -p /mnt/9front
          mkdir -p $PLAN9FRONT/root
          sudo mount -o loop,ro /tmp/9front.iso /mnt/9front
          cp -a /mnt/9front/. $PLAN9FRONT/root/
          chmod -R u+w $PLAN9FRONT/root/
          cp $PLAN9FRONT/root/amd64/9pc64 $PLAN9FRONT/9pc64
          sudo umount /mnt/9front
      - name: Build u9fs from plan9foundation source
        if: steps.cache-9front.outputs.cache-hit != 'true'
        run: |
          git clone --depth=1 --filter=blob:none --sparse \
            https://github.com/plan9foundation/plan9 /tmp/plan9-src
          cd /tmp/plan9-src
          git sparse-checkout set sys/src/cmd/unix/u9fs
          cd sys/src/cmd/unix/u9fs
          make CFLAGS="-g -I. -Wno-implicit-function-declaration -DBit5=2 -DRunemax=0x10FFFF"
          cp u9fs $PLAN9FRONT/u9fs

  setup-9legacy:
    name: Set up 9legacy
    runs-on: ubuntu-latest
    steps:
      - name: Cache 9legacy
        id: cache-9legacy
        uses: actions/cache@v4
        with:
          path: ${{ env.PLAN9LEGACY }}
          key: 9legacy-v2-${{ runner.os }}
      - name: Install dependencies
        if: steps.cache-9legacy.outputs.cache-hit != 'true'
        run: sudo apt-get install -y build-essential
      - name: Download 9legacy ISO
        if: steps.cache-9legacy.outputs.cache-hit != 'true'
        run: |
          mkdir -p $PLAN9LEGACY
          curl -fL -o /tmp/9legacy.iso.bz2 http://9legacy.org/download/9legacy.iso.bz2
          bunzip2 /tmp/9legacy.iso.bz2
      - name: Extract 9legacy root and kernel
        if: steps.cache-9legacy.outputs.cache-hit != 'true'
        run: |
          sudo mkdir -p /mnt/9legacy
          mkdir -p $PLAN9LEGACY/root
          sudo mount -o loop,ro /tmp/9legacy.iso /mnt/9legacy
          cp -a /mnt/9legacy/. $PLAN9LEGACY/root/
          chmod -R u+w $PLAN9LEGACY/root/
          cp $PLAN9LEGACY/root/amd64/9k10f.elf $PLAN9LEGACY/9k10f.elf
          sudo umount /mnt/9legacy
      - name: Build u9fs from plan9foundation source
        if: steps.cache-9legacy.outputs.cache-hit != 'true'
        run: |
          git clone --depth=1 --filter=blob:none --sparse \
            https://github.com/plan9foundation/plan9 /tmp/plan9-src-9legacy
          cd /tmp/plan9-src-9legacy
          git sparse-checkout set sys/src/cmd/unix/u9fs
          cd sys/src/cmd/unix/u9fs
          make CFLAGS="-g -I. -Wno-implicit-function-declaration -DBit5=2 -DRunemax=0x10FFFF"
          cp u9fs $PLAN9LEGACY/u9fs

  run-plan9:
    name: ${{ matrix.jobname }} (${{ matrix.variant }})
    needs: [setup-9front, setup-9legacy]
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        variant: [9front, 9legacy, 9legacy32]
        mktarget: [all, test]
        include:
          - variant: 9front
            plan9dir: /opt/9front
            cache_key: 9front-v3
            kernel: 9pc64
            cfgmethod: append
          - variant: 9legacy
            plan9dir: /opt/9legacy
            cache_key: 9legacy-v2
            kernel: 9k10f.elf
            cfgmethod: ini
          - variant: 9legacy32
            plan9dir: /opt/9legacy
            cache_key: 9legacy-v2
            kernel: /386/9pc
            cfgmethod: pxe
          - mktarget: all
            jobname: Build
          - mktarget: test
            jobname: Test
    env:
      P9DIR: ${{ matrix.plan9dir }}
    steps:
      - uses: actions/checkout@v4
      - name: Restore cache
        uses: actions/cache@v4
        with:
          path: ${{ matrix.plan9dir }}
          key: ${{ matrix.cache_key }}-${{ runner.os }}
      - name: Install QEMU and socat
        run: |
          sudo apt-get update
          sudo apt-get install -y qemu-system-x86 socat
      - name: Copy source into root
        run: cp -r $GITHUB_WORKSPACE $P9DIR/root/rd
      - name: Copy termrc.local into root
        run: cp $GITHUB_WORKSPACE/.github/termrc.local $P9DIR/root/rc/bin/termrc.local
      - name: Prepare u9fs user database
        run: |
          mkdir -p $P9DIR/root/etc
          getent passwd "$(id -un)" >> $P9DIR/root/etc/passwd
          getent group "$(id -gn)" >> $P9DIR/root/etc/group
      - name: Boot VM
        run: |
          rm -f $P9DIR/root/rd/exitcode
          sudo socat TCP4-LISTEN:564,fork,reuseaddr \
            EXEC:"$P9DIR/u9fs -a none -u $(id -un) $P9DIR/root" &
          for i in $(seq 30); do nc -z localhost 564 2>/dev/null && break || sleep 0.5; done
          if [ '${{ matrix.cfgmethod }}' = 'append' ]; then
            cfgargs=(-kernel $P9DIR/${{ matrix.kernel }} -append "nobootprompt=tcp fs=10.0.2.2 auth=10.0.2.2 console=0 b115200 user=glenda mktarget=${{ matrix.mktarget }}")
          elif [ '${{ matrix.cfgmethod }}' = 'pxe' ]; then
            printf 'nobootprompt=tcp\nfs=10.0.2.2\nauth=10.0.2.2\nconsole=0 b115200\nuser=glenda\nmktarget=${{ matrix.mktarget }}\nbootfile=ether0!${{ matrix.kernel }}\n*nomp=1\n' > $P9DIR/root/cfg/pxe/002091373377
            cfgargs=(-boot n -device e1000,netdev=net0,mac=00:20:91:37:33:77 -netdev user,id=net0,tftp=$P9DIR/root/,bootfile=/386/9boot)
          else
            printf 'nobootprompt=tcp\nfs=10.0.2.2\nauth=10.0.2.2\nconsole=0 b115200\nuser=glenda\nmktarget=${{ matrix.mktarget }}\n' > /tmp/plan9.ini
            cfgargs=(-kernel $P9DIR/${{ matrix.kernel }} -device loader,addr=0x1240,file=/tmp/plan9.ini)
          fi
          timeout 300 qemu-system-x86_64 \
            -nographic -no-reboot -m 1G \
            "${cfgargs[@]}" \
            || true
      - name: Check result
        run: |
          result=$(cat $P9DIR/root/rd/exitcode 2>/dev/null | head -1 | tr -d '[:space:]')
          [ "${result:-1}" -eq 0 ]
      - name: Upload build artifacts
        if: matrix.mktarget == 'all'
        uses: actions/upload-artifact@v4
        with:
          name: rd-build-${{ matrix.variant }}
          path: ${{ matrix.plan9dir }}/root/rd/

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.