New Phone Models


    1.12.2 • Public • Published

    Reaction Commerce CI Scripts

    Scripts we use across many repositories during continuous integration.

    How to use in circleci

    In your .circleci/config.yml, in your appropriate job step, add a run command:

        <<: *defaults
          - checkout
          - setup_remote_docker:
              docker_layer_caching: true
          - run:
              name: Run Lint Suite
              # pin the current latest version explicitly, 1.8.4 for example only
              command: npx --quiet --package @reactioncommerce/ci-scripts@1.8.4 lint-shell-scripts

    Note: Most docker-* scripts as well as lint-dockerfiles require the setup_remote_docker circleci job step as a prerequisite. Be sure your config.yml has that when it's needed.

    If you run a bunch of these and want to DRY it up, try this flavor with an environment variable:

    # The following stanza defines a map named defaults with a variable that may be
    # inserted using the YAML merge (<<: *) key later in the file to save some
    # typing. See for details.
    defaults: &defaults
        - image: circleci/node:12-stretch
        CI_SCRIPTS: 'npx --quiet --package @reactioncommerce/ci-scripts@1.8.4'
        <<: *defaults
          - checkout
          - setup_remote_docker:
              docker_layer_caching: true
          - run:
              name: 'docker: catalog-publisher'
              command: |
                ${CI_SCRIPTS} docker-labels >> Dockerfile
                ${CI_SCRIPTS} build-metadata
                ${CI_SCRIPTS} docker-build-tag-push . reactioncommerce/catalog-publisher

    How to add new scripts

    • Put your script file in the repo root. Use a filename extension. It makes editor syntax highlighting and linting "just work" sometimes.
    • chmod 755
    • Add an entry to the package.json "bin" property mapping "name-without-extension": "./",
    • Commit, being sure to prefix your commit message with feat: so semantic release publishes a new minor version properly
    • Notes on filename extensions vs no extensions
      • In the package.json bin keys, we omit the extension. This is slightly nicer as a command line interface. It's just a logical script name.
      • When launching via npx on the command line during CI, it's no extension
      • In the repo root dir, we do use the extension since this is nicer for editor syntax detection, development tools, etc.
      • So in package.json bin it's no extension for the key but yes extension for the value
      • When calling one ci-script from another ci-script it's no extension because these run from the node_modules/.bin directory which only contains no-extension files which npm picks up from package.json bin key.

    How to troubleshoot script errors

    • Launch the docker image your CI job uses locally
      • For example
        • docker run --rm -it circleci/node:12 bash
    • Install ci-scripts in /tmp so you can debug
    • cd /tmp && npm install @reactioncommerce/ci-scripts
    • Run with debugging
    • bash -x ./node_modules/@reactioncommerce/ci-scripts/

    Implementation Notes

    • Scripts should operate on their current working directory (inherited from the parent process)
      • Meaning the calling code should cd into the root of their project git repository (which happens by default on circleci) then invoke the scripts from this repo
    • Scripts should enumerate files with git ls-files
    • Shell scripts should be formatted with shfmt
    • If you need to call another ci-script from your own ci-script, use this pattern
      1. Make a variable for the directory the script lives in, which is node_modules/.bin when running via npx
      • ci_scripts_dir="$(dirname "${BASH_SOURCE[0]}")"
      1. Reference sibling scripts with no extension
      • ./some-other-script


    npm i @reactioncommerce/ci-scripts

    DownloadsWeekly Downloads






    Unpacked Size

    37.6 kB

    Total Files


    Last publish


    • reactionadmin
    • spencern
    • rc-publisher
    • aldeed
    • ticean
    • focusaurus