Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-4975

Use justfile as the task runner

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 4.11
    • Affects Version/s: None
    • Component/s: None
    • Python Drivers
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      Context

      We currently use hatch as our task runner, but it was not meant to be a general purpose task runner, and we have a number of bash scripts that we'd like to consolidate under a single runner. We'd explored several options, and have seen that justfile is a good option.

      An example justfile that we could start with is:

      # See https://just.systems/man/en/ for instructions
      
      set dotenv-filename := "./.evergreen/scripts/env.sh"
      
      # Make the default recipe private so it doesn't show up in the list.
      [private]
      default:
        @just --list
      
      [group('docs')]
      docs-build:
          hatch run docs:build
      
      [group('docs')]
      docs-serve:
          hatch run docs:serve
      
      [group('docs')]
      docs-linkcheck:
          hatch run docs:linkcheck
      
      [group('docs')]
      docs-test:
          hatch run doctest:test
      
      [group('typing')]
      typing:
          hatch run typing:check
      
      [group('typing')]
      typing-mypy:
          hatch run typing:mypy
      
      [group('lint')]
      lint:
          pre-commit run --all-files
      
      [group('lint')]
      lint-manual:
          pre-commit run --all-files --hook-stage manual
      
      [group('test')]
      test:
          hatch run test:test
      
      [group('test')]
      test-mockupdb:
          hatch run test:test-mockupdb
      
      [group('test')]
      test-eg:
          hatch run test:test-eg
      
      [group('encryption')]
      setup-encryption:
          bash .evergreen/setup-encryption.sh
      
      [group('encryption')]
      teardown-encryption:
          bash .evergreen/teardown-encryption.sh
      

      We can bootstrap just as follows:

      # Ensure "just" is installed.
      if ! command -v just > /dev/null; then
        # Install "just" using the installer, falling back to using cargo.
        echo "Installing just..."
        CURL_ARGS="--retry 8 --tlsv1.2 -sSf https://just.systems/install.sh"
        mkdir -p ${CARGO_HOME}/bin
        JUST_ARGS="--to ${CARGO_HOME}/bin"
        if [ "${OS:-}" == "Windows_NT" ]; then
          JUST_ARGS="$JUST_ARGS --target x86_64-pc-windows-msvc"
        fi
        curl --proto '=https' $CURL_ARGS | bash -s -- ${JUST_ARGS} || {
          # Install rust and install with cargo.
          export RUSTUP_HOME="${CARGO_HOME}/.rustup"
          ${DRIVERS_TOOLS}/.evergreen/install-rust.sh
          source "${CARGO_HOME}/env"
          cargo install -q just
        }
        echo "Installing just... done."
      fi
      just --version
      

      Definition of done

      Add a justfile and update documentation and script running to use it.

      Pitfalls

      None

            Assignee:
            steve.silvester@mongodb.com Steve Silvester
            Reporter:
            steve.silvester@mongodb.com Steve Silvester
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              None
              None
              None
              None