Skip to content

Latest commit

 

History

History
326 lines (213 loc) · 6.48 KB

development.md

File metadata and controls

326 lines (213 loc) · 6.48 KB

senzing-tools development

The following instructions are useful during development.

Note: This has been tested on Linux and Darwin/macOS. It has not been tested on Windows.

Prerequisites for development

🤔 The following tasks need to be complete before proceeding. These are "one-time tasks" which may already have been completed.

  1. The following software programs need to be installed:
    1. git
    2. make
    3. docker
    4. go

Install Senzing C library

Since the Senzing library is a prerequisite, it must be installed first.

  1. Verify Senzing C shared objects, configuration, and SDK header files are installed.

    1. /opt/senzing/er/lib
    2. /opt/senzing/er/sdk/c
    3. /etc/opt/senzing
  2. If not installed, see How to Install Senzing for Go Development.

Install Git repository

  1. Identify git repository.

    export GIT_ACCOUNT=senzing-garage
    export GIT_REPOSITORY=senzing-tools
    export GIT_ACCOUNT_DIR=~/${GIT_ACCOUNT}.git
    export GIT_REPOSITORY_DIR="${GIT_ACCOUNT_DIR}/${GIT_REPOSITORY}"
    
  2. Using the environment variables values just set, follow steps in clone-repository to install the Git repository.

Dependencies

  1. A one-time command to install dependencies needed for make targets. Example:

    cd ${GIT_REPOSITORY_DIR}
    make dependencies-for-development
    
  2. Install dependencies needed for Go code. Example:

    cd ${GIT_REPOSITORY_DIR}
    make dependencies
    

Lint

  1. Run linting. Example:

    cd ${GIT_REPOSITORY_DIR}
    make lint
    

Build

  1. Build the binaries. Example:

    cd ${GIT_REPOSITORY_DIR}
    make clean build
    
  2. The binaries will be found in the ${GIT_REPOSITORY_DIR}/target directory. Example:

    tree ${GIT_REPOSITORY_DIR}/target
    

Run

  1. Run program. Examples:

    1. Linux

      export LD_LIBRARY_PATH=/opt/senzing/er/lib/
      ${GIT_REPOSITORY_DIR}/target/linux-amd64/senzing-tools
      
    2. macOS

      export DYLD_LIBRARY_PATH=/opt/senzing/er/lib/:/opt/senzing/er/lib/macos
      ${GIT_REPOSITORY_DIR}/target/darwin-amd64/senzing-tools
      
    3. Windows

      ${GIT_REPOSITORY_DIR}/target/windows-amd64/senzing-tools
      
  2. Clean up. Example:

    cd ${GIT_REPOSITORY_DIR}
    make clean
    

Test

  1. Run tests. Example:

    cd ${GIT_REPOSITORY_DIR}
    make clean setup test
    

Coverage

Create a code coverage map.

  1. Run Go tests. Example:

    cd ${GIT_REPOSITORY_DIR}
    make clean setup coverage
    

    A web-browser will show the results of the coverage. The goal is to have over 80% coverage. Anything less needs to be reflected in testcoverage.yaml.

Documentation

  1. View documentation. Example:

    cd ${GIT_REPOSITORY_DIR}
    make clean documentation
    
  2. If a web page doesn't appear, visit localhost:6060.

  3. Senzing documentation will be in the "Third party" section. github.com > senzing-garage > senzing-tools

  4. When a versioned release is published with a v0.0.0 format tag, the reference can be found by clicking on the following badge at the top of the README.md page. Example:

    Go Reference Badge

  5. To stop the godoc server, run

    cd ${GIT_REPOSITORY_DIR}
    make clean
    

Docker

  1. Use make target to run a docker images that builds RPM and DEB files. Example:

    cd ${GIT_REPOSITORY_DIR}
    make docker-build
    
  2. Run docker container. Example:

    docker run --rm senzing/senzing-tools
    
  3. Optional: Test using docker-compose. Example:

    cd ${GIT_REPOSITORY_DIR}
    make clean docker-test
    

    To bring the docker-compose formation, run

    cd ${GIT_REPOSITORY_DIR}
    make clean
    

Package

Package RPM and DEB files

  1. Use make target to run a docker images that builds RPM and DEB files. Example:

    cd ${GIT_REPOSITORY_DIR}
    make package
    
  2. The results will be in the ${GIT_REPOSITORY_DIR}/target directory. Example:

    tree ${GIT_REPOSITORY_DIR}/target
    

Test DEB package on Ubuntu

  1. Determine if senzing-tools is installed. Example:

    apt list --installed | grep senzing-tools
    
  2. ✏️ Install senzing-tools. Example:

    cd ${GIT_REPOSITORY_DIR}/target
    sudo apt install ./senzing-tools-0.0.0.deb
    
  3. ✏️ Identify database. Example:

    export SENZING_TOOLS_DATABASE_URL=sqlite3://na:na@/tmp/sqlite/G2C.db
    
  4. ✏️ Run command. Example:

    export LD_LIBRARY_PATH=/opt/senzing/er/lib/
    senzing-tools init-database
    
  5. Remove senzing-tools from system. Example:

    sudo apt-get remove senzing-tools
    

Make documents

Make documents visible at hub.senzing.com/senzing-tools.

  1. Identify repository. Example:

    export GIT_ACCOUNT=senzing-garage
    export GIT_REPOSITORY=senzing-tools
    export GIT_ACCOUNT_DIR=~/${GIT_ACCOUNT}.git
    export GIT_REPOSITORY_DIR="${GIT_ACCOUNT_DIR}/${GIT_REPOSITORY}"
    
  2. Make documents. Example:

    export LD_LIBRARY_PATH=/opt/senzing/er/lib/
    senzing-tools docs --dir ${GIT_REPOSITORY_DIR}/docs
    

References