davidhwyllie / findNeighbour4

A server delivering large scale, incrementable, bacterial relatedness monitoring
MIT License
3 stars 2 forks source link

ensure CI works with versions of nim not available in ubuntu repos #93

Closed davidhwyllie closed 2 years ago

davidhwyllie commented 2 years ago

The catwalk software used by findneighbour4 relies on nim. At present, the nim version pulled by apt-get is old (1.06) wherease the latest nim (requirement for the latest catwalk) is 1.4.0. Need to adjust the CI script to allow the latest nim in the CI environment.

davidhwyllie commented 2 years ago

A recipe for github actions using the latest nim is available: https://github.com/marketplace/actions/setup-nim-environment

davidhwyllie commented 2 years ago

See branch issue93. Unable so far to find a github action which allows this. Tried the following:

https://github.com/alaviss/setup-nim https://github.com/marketplace/actions/setup-nim-environment https://github.com/iffy/install-nim

These approaches fail with various errors, which are shown in the github action and various commits to issue93 branch.

davidhwyllie commented 2 years ago

Used direct cloning and installation in local directory:

        mkdir external_software
        cd external_software
        wget https://nim-lang.org/download/nim-1.4.8-linux_x64.tar.xz
        tar -xf nim-1.4.8-linux_x64.tar.xz
        ./nim-1.4.8/bin/nimble --version

        # clone catwalk relatedness engine
        git clone https://gitea.mmmoxford.uk/dvolk/catwalk.git
        cd catwalk
        ../nim-1.4.8/bin/nimble -y build -d:release -d:danger -d:no_serialisation --nimbleDir:../nim-1.4.8/bin

Note that this works locally but when installed as part of a github action

# This workflow will build the latest version of nim
# and test catwalk

name: Test catwalk with latest nim

on: 
  workflow_dispatch:
    inputs:
      tags:
        description: 'Test catwalk with latest nim'
  push:
    branches:
    - '*'

jobs:
  build:

    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.8"]
        mongodb-version: ["4.4.4"]

    steps:
    - uses: actions/checkout@v2

    - name: Setup Nim environment and catwalk
      run: |
        mkdir external_software
        cd external_software
        wget https://nim-lang.org/download/nim-1.4.8-linux_x64.tar.xz
        tar -xf nim-1.4.8-linux_x64.tar.xz
        ./nim-1.4.8/bin/nimble --version

        # clone catwalk relatedness engine
        git clone https://gitea.mmmoxford.uk/dvolk/catwalk.git
        cd catwalk
        ../nim-1.4.8/bin/nimble -y build -d:release -d:danger -d:no_serialisation --nimbleDir:../nim-1.4.8/bin

this fails reporting

dependency nim > 1.4.0 not present. Presumably the nimble package manager is checking some central location for nimble.

davidhwyllie commented 2 years ago

-- filed bug report

Please note that the step prepending the directory to the system PATH variable cannot itself access the updated path variable. This is documented below:

https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#adding-a-system-path You'll be able to access the updated path in subsequent steps. I was able to successfully test this out with the following workflow

# This workflow will use the latest version of nim

name: Test latest nim

on: 
  workflow_dispatch:
    inputs:
      tags:
        description: 'Test latest nim'

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Setup Nim 
      run: |
        mkdir external_software
        cd external_software
        wget https://nim-lang.org/download/nim-1.4.8-linux_x64.tar.xz
        tar -xf nim-1.4.8-linux_x64.tar.xz
        echo "Checking nimble works when relative path applied"
        ./nim-1.4.8/bin/nimble --version
        # show what is on the path
        echo "Current path"
        sed 's/:/\n/g' <<< "$PATH"
        NIMDIR="`pwd`/nim-1.4.8/bin"
        echo "Nim directory:"
        echo "$NIMDIR"
        echo "Checking nimble works when computed NIMDIR path applied"
        ${NIMDIR}/nimble --version
        echo "Appending to PATH"
        echo "$NIMDIR" >> $GITHUB_PATH

    - name: updated
      run: |
          echo "Updated path"       
          # show what is on the path
          sed 's/:/\n/g' <<< "$PATH"

          # is nimble accessible on path
          echo "Nimble version:"
          nimble --version
davidhwyllie commented 2 years ago

Issue resolved. CI scripts updated.