# Input used by make_workflows.py to generate .github/workflows/

# See VersionFlavor in the script to see how stabl/release/devel/devel_release
# are defined.

software:
    #############################
    # Hybrid family:
    charybdis:
        name: Charybdis
        repository: charybdis-ircd/charybdis
        refs:
            stable: charybdis-4.1.2
            release: null
            devel: null
            devel_release: null
        path: charybdis
        separate_build_job: true
        build_script: |
            cd $GITHUB_WORKSPACE/charybdis/
            patch -p1 < $GITHUB_WORKSPACE/patches/charybdis_ubuntu22.patch
            ./autogen.sh
            ./configure --prefix=$HOME/.local/
            make -j 4
            make install

    hybrid:
        name: Hybrid
        repository: ircd-hybrid/ircd-hybrid
        refs:
            stable: "8.2.39"
            release: null
            devel: "8.2.x"
            devel_release: null
        path: ircd-hybrid
        separate_build_job: true
        build_script: |
            cd $GITHUB_WORKSPACE/ircd-hybrid/
            ./configure --prefix=$HOME/.local/
            make -j 4
            make install

    plexus4:
        name: Plexus4
        path: plexus4
        separate_build_job: true
        install_steps:
            stable:
                - name: clone
                  run: |-
                      curl https://gitlab.com/rizon/plexus4/-/archive/20211115_0-611/plexus4-20211115_0-611.tar | tar -x
                      mv plexus* plexus4
                - name: build
                  run: |-
                      cd $GITHUB_WORKSPACE/plexus4
                      ./autogen.sh
                      ./configure --prefix=$HOME/.local/
                      make -j 4
                      make install
            release: null
            devel:
                - name: clone
                  run: |-
                      curl https://gitlab.com/rizon/plexus4/-/archive/master/plexus4-master.tar.gz | tar -zx
                      mv plexus4* plexus4
                - name: build
                  run: |-
                      cd $GITHUB_WORKSPACE/plexus4
                      ./autogen.sh
                      ./configure --prefix=$HOME/.local/
                      make -j 4
                      make install
            devel_release: null

    solanum:
        name: Solanum
        repository: solanum-ircd/solanum
        refs:
            # Actually Solanum doesn't have releases; so we just bump this
            # commit hash from time to time
            stable: 492d560ee13e71dc35403fd676e58c2d5bdcf2a9
            release: null
            devel: main
            devel_release: null
        path: solanum
        separate_build_job: true
        build_script: |
            cd $GITHUB_WORKSPACE/solanum/
            ./autogen.sh
            ./configure --prefix=$HOME/.local/
            make -j 4
            make install

    #############################
    # Other servers:
    bahamut:
        name: Bahamut
        repository: DALnet/Bahamut
        refs:
            stable: "v2.2.1"
            release: null
            devel: "master"
            devel_release: null
        path: Bahamut
        separate_build_job: true
        build_script: |
            cd $GITHUB_WORKSPACE/Bahamut/
            patch src/s_user.c < $GITHUB_WORKSPACE/patches/bahamut_localhost.patch
            patch src/s_bsd.c < $GITHUB_WORKSPACE/patches/bahamut_mainloop.patch

            # <= v2.2.2
            patch -p1 < $GITHUB_WORKSPACE/patches/bahamut_ubuntu22.patch || true

            echo "#undef THROTTLE_ENABLE" >> include/config.h
            libtoolize --force
            aclocal
            autoheader
            automake --force-missing --add-missing || true
            autoreconf
            ./configure --prefix=$HOME/.local/
            make -j 4
            make install
            mkdir -p $HOME/.local/bin/
            cp $HOME/.local/ircd $HOME/.local/bin/ircd

    ergo:
        name: Ergo
        repository: ergochat/ergo
        refs:
            stable: irctest_stable
            release: stable
            devel: master
            devel_release: null
        path: ergo
        prefix: ~/go
        pre_deps:
            - uses: actions/setup-go@v3
              with:
                  go-version: '^1.22.0'
            - run: go version
        separate_build_job: false
        build_script: |
            cd $GITHUB_WORKSPACE/ergo/
            make build
            make install

    inspircd:
        name: InspIRCd
        repository: inspircd/inspircd
        refs: &inspircd_refs
            stable: v3.17.1
            release: null
            devel: master
            devel_release: insp3
        path: inspircd
        prefix: ~/.local/inspircd
        cache: false  # incremental compilation is frequently broken
        separate_build_job: true
        build_script: &inspircd_build_script |
            cd $GITHUB_WORKSPACE/inspircd/
            ./configure --prefix=$HOME/.local/inspircd --development
            CXXFLAGS=-DINSPIRCD_UNLIMITED_MAINLOOP make -j 4
            make install
    irc2:
        name: irc2
        separate_build_job: false
        repository : irc-archive/irc2-mirror
        path: irc2.11.2p3
        cache: true
        refs:
            stable: 59649f24c3a5c27bad5648b48774f27475bccfd3  #  irc2.11.2p3
            release: null
            devel: null
            devel_release: null
        build_script: |
            # Configure
            cd $GITHUB_WORKSPACE/irc2.11.2p3
            ./configure --prefix=$HOME/.local/
            cd x86*
            echo "#define CMDLINE_CONFIG/" >> config.h
            echo "#define DEFAULT_SPLIT_USERS 0" >> config.h
            echo "#define DEFAULT_SPLIT_SERVERS 0" >> config.h
            #echo "#undef LIST_ALIS_NOTE" >> config.h
            # TODO: find a better way to make it not fork...
            echo "#define fork() (0)" >> config.h

            # Compile and install
            cd $GITHUB_WORKSPACE/irc2.11.2p3/x86*
            make -j 4 all
            make install
            mkdir -p $HOME/.local/bin
            cp $HOME/.local/sbin/ircd $HOME/.local/bin/ircd

    ircu2:
        name: ircu2
        repository: undernetirc/ircu2
        refs:
            stable: "u2.10.12.19"
            release: null
            devel: "u2_10_12_branch"
            devel_release: null
        path: ircu2
        separate_build_job: false
        build_script: |
            cd $GITHUB_WORKSPACE/ircu2
            # We need --with-maxcon, to set MAXCONNECTIONS so that it's much lower than
            # NN_MAX_CLIENT, or ircu2 crashes with a somewhat cryptic error on startup.
            ./configure --prefix=$HOME/.local/ --with-maxcon=1024 --enable-debug
            make -j 4
            make install

    nefarious:
        name: nefarious
        repository: evilnet/nefarious2
        refs:
            stable: "985704168ecada12d9e53b46df6087ef9d9fb40b"
            release: null
            devel: "master"
            devel_release: null
        path: nefarious
        separate_build_job: false
        build_script: |
            cd $GITHUB_WORKSPACE/nefarious
            ./configure --prefix=$HOME/.local/ --enable-debug
            make -j 4
            make install
            cp $GITHUB_WORKSPACE/data/nefarious/* $HOME/.local/lib

    ngircd:
        name: ngircd
        repository: ngircd/ngircd
        refs:
            stable: 3e3f6cbeceefd9357b53b27c2386bb39306ab353 # three years ahead of rel-26.1
            release: null
            devel: master
            devel_release: null
        path: ngircd
        prefix: ~/.local/
        separate_build_job: true
        build_script: |
            cd $GITHUB_WORKSPACE/ngircd
            patch src/ngircd/client.c < $GITHUB_WORKSPACE/patches/ngircd_whowas_delay.patch
            ./autogen.sh
            ./configure --prefix=$HOME/.local/
            make -j 4
            make install

    sable:
        name: Sable
        repository: Libera-Chat/sable
        refs:
            stable: e9701e5e8d0c4f278ddd61ce7285f4918ecf99e9
            release: null
            devel: master
            devel_release: null
        path: sable
        prefix: "$GITHUB_WORKSPACE/sable/target/debug"
        pre_deps:
            - name: Install rust toolchain
              uses: actions-rs/toolchain@v1
              with:
                  toolchain: nightly
                  profile: minimal
                  override: true
            - name: Enable Cargo cache
              uses: Swatinem/rust-cache@v2
              with:
                workspaces: "sable -> target"
                cache-on-failure: true
            - run: rustc --version
        separate_build_job: false
        build_script: |
            cd $GITHUB_WORKSPACE/sable/
            cargo build

    snircd:
        name: snircd
        repository: quakenet/snircd
        refs:
            stable: "u2.10.12.10+snircd(1.3.4a)"
            release: null
            devel: null  # no update in master since 2013...
            devel_release: null
        path: snircd
        separate_build_job: false
        build_script: |
            cd $GITHUB_WORKSPACE/snircd

            # Work around an issue with liblex detection
            rm configure
            autoconf

            # We need --with-maxcon, to set MAXCONNECTIONS so that it's much lower than
            # NN_MAX_CLIENT, or ircu2 crashes with a somewhat cryptic error on startup.
            ./configure --prefix=$HOME/.local/ --with-maxcon=1024 --enable-debug
            make -j 4
            make install

    unrealircd:
        name: UnrealIRCd 6
        repository: unrealircd/unrealircd
        refs:
            stable: da3c1c654481a33035b9c703957e1c25d0158259  # 6.0.7
            release: da3c1c654481a33035b9c703957e1c25d0158259  # 6.0.7
            devel: unreal60_dev
            devel_release: null
        path: unrealircd
        prefix: ~/.local/unrealircd
        separate_build_job: true
        build_script: &unrealircd_build_script |
            cd $GITHUB_WORKSPACE/unrealircd/
            cp $GITHUB_WORKSPACE/data/unreal/* .
            # Need to use a specific -march, because GitHub has inconsistent
            # architectures across workers, which result in random SIGILL with some
            # worker combinations
            sudo apt install libsodium-dev libargon2-dev
            CFLAGS="-O0 -march=x86-64" CXXFLAGS="$CFLAGS" ./Config -quick
            make -j 4
            make install
            # Prevent download of geoIP database on first startup
            sed -i 's/loadmodule "geoip_classic";//' ~/.local/unrealircd/conf/modules.default.conf

    unrealircd-5:
        name: UnrealIRCd 5
        repository: unrealircd/unrealircd
        refs:
            stable: 6604856973f713a494f83d38992d7d61ce6b9db4  # 5.2.4
            release: null
            devel: unreal52
            devel_release:
        path: unrealircd
        prefix: ~/.local/unrealircd
        separate_build_job: true
        build_script: *unrealircd_build_script


    #############################
    # Services:

    anope:
        name: Anope
        repository: anope/anope
        separate_build_job: true
        path: anope
        refs:
            stable: "2.0.14"
            release: "2.1.1"
            devel: "2.1"
            devel_release: "2.0"
        build_script: |
            cd $GITHUB_WORKSPACE/anope/
            sudo apt-get install ninja-build --no-install-recommends
            mkdir build && cd build
            cmake -DCMAKE_INSTALL_PREFIX=$HOME/.local/ -DPROGRAM_NAME=anope -DUSE_PCH=ON -GNinja ..
            ninja install

    dlk:
        name: Dlk
        repository: DalekIRC/Dalek-Services
        separate_build_job: false
        path: Dlk-Services
        refs:
            stable: null  # disabled because flaky, and hard to debug with all the PHP 8 warnings
            release: &dlk_stable "6db51ea03f039c48fd20427c04cec8ff98df7878"
            devel: "main"
            devel_release: *dlk_stable
        build_script: |
            pip install pifpaf
            wget -q https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
            wget -q https://wordpress.org/latest.zip -O wordpress-latest.zip
        env: >-
            IRCTEST_DLK_PATH="${{ github.workspace }}/Dlk-Services"
            IRCTEST_WP_CLI_PATH="${{ github.workspace }}/wp-cli.phar"
            IRCTEST_WP_ZIP_PATH="${{ github.workspace }}/wordpress-latest.zip"


    #############################
    # Clients:

    limnoria:
        name: Limnoria
        separate_build_job: false
        install_steps:
            stable:
                - name: Install dependencies
                  run: pip install limnoria==2023.5.27 cryptography pyxmpp2-scram
            release:
                - name: Install dependencies
                  run: pip install limnoria cryptography pyxmpp2-scram
            devel:
                - name: Install dependencies
                  run: pip install git+https://github.com/progval/Limnoria.git@master cryptography pyxmpp2-scram
            devel_release: null

    sopel:
        name: Sopel
        separate_build_job: false
        install_steps:
            stable:
                - name: Install dependencies
                  run: pip install sopel==7.1.8
            release:
                - name: Install dependencies
                  run: pip install sopel
            devel:
                - name: Install dependencies
                  run: pip install git+https://github.com/sopel-irc/sopel.git
            devel_release: null

    thelounge:
        name: TheLounge
        repository: thelounge/thelounge
        separate_build_job: false
        refs:
            stable: "v4.4.0"
            release: "v4.4.0"
            devel: "master"
            devel_release: null
        path: thelounge
        build_script: |
            cd $GITHUB_WORKSPACE/thelounge
            yarn install
            NODE_ENV=production yarn build
            mkdir -p ~/.local/bin/
            ln -s $(pwd)/index.js ~/.local/bin/thelounge

tests:
    bahamut:
        software: [bahamut]

    bahamut-atheme:
        software: [bahamut]

    bahamut-anope:
        software: [bahamut, anope]

    charybdis:
        software: [charybdis]

    hybrid:
        software: [hybrid, anope]

    solanum:
        software: [solanum]

    ergo:
        software: [ergo]

    inspircd:
        software: [inspircd]

    inspircd-atheme:
        software: [inspircd]
        exclude_versions: [devel] # Atheme does not support Insp4 yet, so it fails to connect

    inspircd-anope:
        software: [inspircd, anope]

    ngircd:
        software: [ngircd]

    ngircd-atheme:
        software: [ngircd]

    ngircd-anope:
        software: [ngircd, anope]

    plexus4:
        software: [plexus4, anope]

    irc2:
        software: [irc2]

    ircu2:
        software: [ircu2]

    nefarious:
        software: [nefarious]

    sable:
        software: [sable]

    # doesn't build because it can't find liblex for some reason
    #snircd:
    #    software: [snircd]

    unrealircd-5:
        software: [unrealircd-5]

    unrealircd:
        software: [unrealircd]

    unrealircd-atheme:
        software: [unrealircd]

    unrealircd-anope:
        software: [unrealircd, anope]

    unrealircd-dlk:
        software: [unrealircd, dlk]


    limnoria:
        software: [limnoria]

    sopel:
        software: [sopel]

    thelounge:
        software: [thelounge]