<commit_before>version: 2

jobs:
  test:
    docker:
      - image: node:8.11.3-alpine
    steps:
      - checkout
      - run: apk --no-cache add ca-certificates
      - restore_cache:
          keys:
            - npm-deps-{{ checksum "package.json" }}
      - run: yarn
      - save_cache:
          key: npm-deps-{{ checksum "package.json" }}
          paths: node_modules
      - run:
          name: Eslint
          command: yarn lint
      - run:
          name: Mocha tests
          command: yarn coverage
      - run:
          name: Upload to codecov
          command: yarn codecov
      - run:
          name: Smoke tests
          command: bids-validator/bin/bids-validator bids-validator/tests/data/valid_headers/ --ignoreNiftiHeaders && bids-validator/bin/bids-validator bids-validator/tests/data/valid_headers/ --ignoreNiftiHeaders --json
  githubPagesTest:
    docker:
      - image: node:8.11.3-alpine
    steps:
      - checkout
      - run: apk --no-cache add ca-certificates
      - restore_cache:
          keys:
            - npm-deps-{{ checksum "package.json" }}
      - run: apk --no-cache add rsync git python build-base openssh
      - run:
          name: Install bids-validator and bids-validator-web dependencies
          command: yarn 
      - run:
          name: Build and export web-validator
          command: yarn web-export && rsync -av ./bids-validator-web/out/ ~/web_version
      - store_artifacts:
          path: ~/web_version
  pypi_precheck:
    docker:
      - image: alpine:3.8
    steps:
      - checkout
      - run:
          name: Set up environment
          command: |
            apk --no-cache add ca-certificates git build-base
      - run:
          name: Install Python 3 and update setuptools
          command: |
            apk --no-cache add python3 python3-dev py3-cffi
            python3 -m pip install --upgrade pip setuptools wheel twine readme_renderer[md]
      - run:
          name: Check build and readme rendering
          command: |
            cd bids-validator && python3 setup.py sdist bdist_wheel
            twine check dist/*
      - run:
          name: Check sdist installation
          command: |
            cd bids-validator
            python3 -m pip install -U virtualenv
            virtualenv venv
            source venv/bin/activate
            python --version
            pip install -U pip setuptools>=27.0 wheel
            pip install dist/*.tar.gz
  deployment:
    docker:
      - image: node:8.11.3-alpine
    steps:
      - add_ssh_keys:
          fingerprints:
            - '44:93:5a:f4:2b:2d:c1:8a:f2:8e:8b:e9:27:5f:93:25'
      - checkout
      - run: apk --no-cache add ca-certificates
      - run: apk --no-cache add git python build-base openssh
      - run:
          name: Install Python 3 and update setuptools
          command: |
            apk --no-cache add python3 python3-dev py3-cffi
            python3 -m pip install --upgrade pip setuptools wheel twine
      - run: git checkout -f $CIRCLE_TAG
      - run: cd bids-validator && python3 setup.py sdist bdist_wheel
      # Publish to NPM
      - run: yarn
      - run: ./node_modules/.bin/npm-cli-login -u $NPM_USERNAME -p $NPM_PASSWORD -e $NPM_EMAIL
      - run: cd bids-validator && npm publish
      # Publish to PyPI
      - run: cd bids-validator && twine upload dist/*
      # Update gh-pages demo site
      - run: git config --global user.email circleci@circleci<commit_msg>remove publish step from npm<commit_after>version: 2

jobs:
  test:
    docker:
      - image: node:8.11.3-alpine
    steps:
      - checkout
      - run: apk --no-cache add ca-certificates
      - restore_cache:
          keys:
            - npm-deps-{{ checksum "package.json" }}
      - run: yarn
      - save_cache:
          key: npm-deps-{{ checksum "package.json" }}
          paths: node_modules
      - run:
          name: Eslint
          command: yarn lint
      - run:
          name: Mocha tests
          command: yarn coverage
      - run:
          name: Upload to codecov
          command: yarn codecov
      - run:
          name: Smoke tests
          command: bids-validator/bin/bids-validator bids-validator/tests/data/valid_headers/ --ignoreNiftiHeaders && bids-validator/bin/bids-validator bids-validator/tests/data/valid_headers/ --ignoreNiftiHeaders --json
  githubPagesTest:
    docker:
      - image: node:8.11.3-alpine
    steps:
      - checkout
      - run: apk --no-cache add ca-certificates
      - restore_cache:
          keys:
            - npm-deps-{{ checksum "package.json" }}
      - run: apk --no-cache add rsync git python build-base openssh
      - run:
          name: Install bids-validator and bids-validator-web dependencies
          command: yarn 
      - run:
          name: Build and export web-validator
          command: yarn web-export && rsync -av ./bids-validator-web/out/ ~/web_version
      - store_artifacts:
          path: ~/web_version
  pypi_precheck:
    docker:
      - image: alpine:3.8
    steps:
      - checkout
      - run:
          name: Set up environment
          command: |
            apk --no-cache add ca-certificates git build-base
      - run:
          name: Install Python 3 and update setuptools
          command: |
            apk --no-cache add python3 python3-dev py3-cffi
            python3 -m pip install --upgrade pip setuptools wheel twine readme_renderer[md]
      - run:
          name: Check build and readme rendering
          command: |
            cd bids-validator && python3 setup.py sdist bdist_wheel
            twine check dist/*
      - run:
          name: Check sdist installation
          command: |
            cd bids-validator
            python3 -m pip install -U virtualenv
            virtualenv venv
            source venv/bin/activate
            python --version
            pip install -U pip setuptools>=27.0 wheel
            pip install dist/*.tar.gz
  deployment:
    docker:
      - image: node:8.11.3-alpine
    steps:
      - add_ssh_keys:
          fingerprints:
            - '44:93:5a:f4:2b:2d:c1:8a:f2:8e:8b:e9:27:5f:93:25'
      - checkout
      - run: apk --no-cache add ca-certificates
      - run: apk --no-cache add git python build-base openssh
      - run:
          name: Install Python 3 and update setuptools
          command: |
            apk --no-cache add python3 python3-dev py3-cffi
            python3 -m pip install --upgrade pip setuptools wheel twine
      - run: git checkout -f $CIRCLE_TAG
      - run: cd bids-validator && python3 setup.py sdist bdist_wheel
      # Publish to PyPI
      - run: cd bids-validator && twine upload dist/*
      # Update gh-pages demo site
      - run: git config --global user.email <EMAIL>
{'fraction_non_alphanumeric': 0.092919697194597, 'fraction_numerical': 0.015437138192073624, 'mean_word_length': 1.6695721077654517, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5338777', 'n_tokens_mistral': 2127, 'n_tokens_neox': 2045, 'n_words': 575}