<commit_before>version: 2.1

executors:
  python-executor:
    working_directory: ~/phovea
    docker:
      - image: circleci/python:3.7-buster-node-browsers # for node version see Dockerfile on https://hub.docker.com/r/circleci/python

jobs:
  build:
    executor: node-executor
    steps:
      - checkout
      - setup_remote_docker
      - run:
          name: Show Node.js and npm version
          command: |
            node -v
            npm -v
      - run:
          name: Show Python and pip version
          command: |
            python --version
            pip --version
      - restore_cache:
          key: dependency-cache-{{ checksum "package.json" }}
      - run:
          name: Install npm dependencies
          command: npm install
      - save_cache:
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - ./node_modules
      - run:
          name: Show installed npm dependencies
          command: npm list --depth=1 || true
      - restore_cache:
          key: awscli-1.18.134
      - run:
          name: Install AWS CLI
          command: |
            virtualenv ~/venv
            . ~/venv/bin/activate
            pip install awscli==1.18.134
      - save_cache:
          key: awscli-1.18.134
          paths:
          - ~/venv
      - run:
          name: Login AWS ECR and DockerHub
          command: |
            . ~/venv/bin/activate
            cat > ~/.dockercfg \<< EOF
            {
              "https://index.docker.io/v1/": {
                "auth": "$DOCKER_AUTH"
              }
            }
            EOF
            export AWS_DEFAULT_REGION=eu-central-1
            login="$(aws ecr get-login --no-include-email)"
            ${login}
      - deploy:
          name: Build and deploy
          command: |
            . ~/venv/bin/activate
            case "${CIRCLE_BRANCH}${CIRCLE_TAG}" in
            master)
              awsTag="latest"
              ;;
            *)
              awsTag="${CIRCLE_BRANCH//\//_}${CIRCLE_TAG}" # replace `/` with `_` in branch name
              ;;
            esac
            echo "using tag: --${awsTag}--"
            node build.js --injectVersion --skipSaveImage --noDefaultTags --pushExtra=${awsTag} --pushTo=922145058410.dkr.ecr.eu-central-1.amazonaws.com/caleydo
      - store_artifacts:
          path: build
          destination: build
      - deploy:
          name: Cleanup untagged AWS repositories
          command: |
            . ~/venv/bin/activate
            export AWS_DEFAULT_REGION=eu-central-1
            baseName=${CIRCLE_PROJECT_REPONAME%_product}
            # list repos filter to just the one of this product and delete untagged ones
            aws ecr describe-repositories --output text | cut -f5 | grep "caleydo/${baseName}" | while read line; do aws ecr list-images --repository-name $line --filter tagStatus=UNTAGGED --query 'imageIds[*]' --output text | while read imageId; do aws ecr batch-delete-image --output text --repository-name $line --image-ids imageDigest=$imageId; done; done
      - deploy:
          name: Restart AWS task # assumes the task definition is called <reponame>-<branch>
          command: |
            . ~/venv/bin/activate
            export AWS_DEFAULT_REGION=eu-central-1
            # cleanup name by removing the _product suffix
            baseName=${CIRCLE_PROJECT_REPONAME%_product}
            awsFamily="${baseName}-${CIRCLE_BRANCH//\//_}" # replace `/` with `_` in branch name
            echo "awsFamily --${awsFamily}--"
            tasksExists=$(aws --output text ecs list-task-definitions --family-prefix ${awsFamily})
            echo "existsTaskDefinition? --${tasksExists}--"
            if [ ! -z "$tasksExists" ]; then
              isTaskRunning=$(aws --output text ecs list-tasks --cluster caleydo --family ${awsFamily})
              echo "isTaskRunning? --${isTaskRunning}--"
              if [ ! -z "$isTaskRunning" ]; then
                taskId=$(echo "${isTaskRunning}" | cut -f2)
                echo "taskId--${taskId}--"
                aws --output text ecs stop-task --cluster caleydo --task ${taskId}
              fi
              aws --output text ecs run-task --cluster caleydo --task-definition ${awsFamily} --started-by CircleCIAutoUpdate
            fi
workflows:
  version: 2.1
#  build-nightly:
#    triggers:
#      - schedule:
#          cron: "15 1 * * 1-5" # "At 01:15 on every day-of-week from Monday through Friday.”, see: https://crontab.guru/#15_1_*_*_1-5
#          filters:
#            branches:
#              only:
#                - develop
#    jobs:
#      - build
  build-branch:
    jobs:
      - build:
          filters:
            tags:
              ignore: /^v.*/
  build-tag:
    jobs:
      - build:
          filters:
            branches:
              ignore: /.*/
            tags:
              only: /^v.*/
<commit_msg>change executor<commit_after>version: 2.1

executors:
  node-executor:
    working_directory: ~/phovea
    docker:
      - image: circleci/node:12.13-buster-browsers
jobs:
  build:
    executor: node-executor
    steps:
      - checkout
      - setup_remote_docker
      - run:
          name: Show Node.js and npm version
          command: |
            node -v
            npm -v
      - run:
          name: Show Python and pip version
          command: |
            python --version
            pip --version
      - restore_cache:
          key: dependency-cache-{{ checksum "package.json" }}
      - run:
          name: Install npm dependencies
          command: npm install
      - save_cache:
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - ./node_modules
      - run:
          name: Show installed npm dependencies
          command: npm list --depth=1 || true
      - restore_cache:
          key: awscli-1.18.134
      - run:
          name: Install AWS CLI
          command: |
            virtualenv ~/venv
            . ~/venv/bin/activate
            pip install awscli==1.18.134
      - save_cache:
          key: awscli-1.18.134
          paths:
          - ~/venv
      - run:
          name: Login AWS ECR and DockerHub
          command: |
            . ~/venv/bin/activate
            cat > ~/.dockercfg \<< EOF
            {
              "https://index.docker.io/v1/": {
                "auth": "$DOCKER_AUTH"
              }
            }
            EOF
            export AWS_DEFAULT_REGION=eu-central-1
            login="$(aws ecr get-login --no-include-email)"
            ${login}
      - deploy:
          name: Build and deploy
          command: |
            . ~/venv/bin/activate
            case "${CIRCLE_BRANCH}${CIRCLE_TAG}" in
            master)
              awsTag="latest"
              ;;
            *)
              awsTag="${CIRCLE_BRANCH//\//_}${CIRCLE_TAG}" # replace `/` with `_` in branch name
              ;;
            esac
            echo "using tag: --${awsTag}--"
            node build.js --injectVersion --skipSaveImage --noDefaultTags --pushExtra=${awsTag} --pushTo=922145058410.dkr.ecr.eu-central-1.amazonaws.com/caleydo
      - store_artifacts:
          path: build
          destination: build
      - deploy:
          name: Cleanup untagged AWS repositories
          command: |
            . ~/venv/bin/activate
            export AWS_DEFAULT_REGION=eu-central-1
            baseName=${CIRCLE_PROJECT_REPONAME%_product}
            # list repos filter to just the one of this product and delete untagged ones
            aws ecr describe-repositories --output text | cut -f5 | grep "caleydo/${baseName}" | while read line; do aws ecr list-images --repository-name $line --filter tagStatus=UNTAGGED --query 'imageIds[*]' --output text | while read imageId; do aws ecr batch-delete-image --output text --repository-name $line --image-ids imageDigest=$imageId; done; done
      - deploy:
          name: Restart AWS task # assumes the task definition is called <reponame>-<branch>
          command: |
            . ~/venv/bin/activate
            export AWS_DEFAULT_REGION=eu-central-1
            # cleanup name by removing the _product suffix
            baseName=${CIRCLE_PROJECT_REPONAME%_product}
            awsFamily="${baseName}-${CIRCLE_BRANCH//\//_}" # replace `/` with `_` in branch name
            echo "awsFamily --${awsFamily}--"
            tasksExists=$(aws --output text ecs list-task-definitions --family-prefix ${awsFamily})
            echo "existsTaskDefinition? --${tasksExists}--"
            if [ ! -z "$tasksExists" ]; then
              isTaskRunning=$(aws --output text ecs list-tasks --cluster caleydo --family ${awsFamily})
              echo "isTaskRunning? --${isTaskRunning}--"
              if [ ! -z "$isTaskRunning" ]; then
                taskId=$(echo "${isTaskRunning}" | cut -f2)
                echo "taskId--${taskId}--"
                aws --output text ecs stop-task --cluster caleydo --task ${taskId}
              fi
              aws --output text ecs run-task --cluster caleydo --task-definition ${awsFamily} --started-by CircleCIAutoUpdate
            fi
workflows:
  version: 2.1
#  build-nightly:
#    triggers:
#      - schedule:
#          cron: "15 1 * * 1-5" # "At 01:15 on every day-of-week from Monday through Friday.”, see: https://crontab.guru/#15_1_*_*_1-5
#          filters:
#            branches:
#              only:
#                - develop
#    jobs:
#      - build
  build-branch:
    jobs:
      - build:
          filters:
            tags:
              ignore: /^v.*/
  build-tag:
    jobs:
      - build:
          filters:
            branches:
              ignore: /.*/
            tags:
              only: /^v.*/

{'fraction_non_alphanumeric': 0.11765917988872862, 'fraction_numerical': 0.012157428394807336, 'mean_word_length': 1.5050322580645161, 'pattern_counts': {'":': 4, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 5, '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': '1790114', 'n_tokens_mistral': 2920, 'n_tokens_neox': 2797, 'n_words': 702}