<commit_before>image: canopytax/dind

stages:
    - build
    - test
    - push-to-dockerhub
    - deploy-stage
    - deploy-prod

variables:
  REPO_NAME: canopytax/toggle-meister
  CONTAINER_IMAGE: docker.io/$REPO_NAME:$CI_COMMIT_SHA
  REGISTRY: docker.io
  DOCKER_DRIVER: overlay

build:
  stage: build
  before_script:
    - mkdir -p $HOME/.docker
    - echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json
  script:
    - docker build --pull -t $CONTAINER_IMAGE .
    - docker push $REPO_NAME:$CI_COMMIT_SHA

lint:
  image: $REPO_NAME:$CI_COMMIT_SHA
  stage: test
  script:
    - invoke lint

test:
  services:
    - postgres
  image: $REPO_NAME:$CI_COMMIT_SHA
  stage: test
  script:
    - export DATABASE_URL=postgres
    - export IS_LOCAL=true
    - alembic upgrade head
    - python3 -m coverage run run.py &
    - tm_pid=$!
    # wait for 8445 to be open
    - while ! nc -z localhost 8445; do echo "."; sleep 2; done
    - /root/.local/bin/pyresttest http://localhost:8445 tests/api/test.yaml
    - kill -SIGINT $tm_pid
    - sleep 2
    - python3 -m coverage report --include "tmeister/*"

push-to-dockerhub:
  stage: push-to-dockerhub
  before_script:
    - mkdir -p $HOME/.docker
    - echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json
  script:
    - docker pull $REPO_NAME:$CI_COMMIT_SHA
    - docker tag $REPO_NAME:$CI_COMMIT_SHA $REPO_NAME:latest
    - docker push $REPO_NAME:latest
  only:<commit_msg>fix the tests<commit_after>image: canopytax/dind

stages:
    - build
    - test
    - push-to-dockerhub
    - deploy-stage
    - deploy-prod

variables:
  REPO_NAME: canopytax/toggle-meister
  CONTAINER_IMAGE: docker.io/$REPO_NAME:$CI_COMMIT_SHA
  REGISTRY: docker.io
  DOCKER_DRIVER: overlay

build:
  stage: build
  before_script:
    - mkdir -p $HOME/.docker
    - echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json
  script:
    - docker build --pull -t $CONTAINER_IMAGE .
    - docker push $REPO_NAME:$CI_COMMIT_SHA

lint:
  image: $REPO_NAME:$CI_COMMIT_SHA
  stage: test
  script:
    - invoke lint

test:
  services:
    - postgres:9.6-alpine
  image: $REPO_NAME:$CI_COMMIT_SHA
  stage: test
  script:
    - export DATABASE_URL=postgres
    - export IS_LOCAL=true
    - alembic upgrade head
    - python3 -m coverage run run.py &
    - tm_pid=$!
    # wait for 8445 to be open
    - while ! nc -z localhost 8445; do echo "."; sleep 2; done
    - /root/.local/bin/pyresttest http://localhost:8445 tests/api/test.yaml
    - kill -SIGINT $tm_pid
    - sleep 2
    - python3 -m coverage report --include "tmeister/*"

push-to-dockerhub:
  stage: push-to-dockerhub
  before_script:
    - mkdir -p $HOME/.docker
    - echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json
  script:
    - docker pull $REPO_NAME:$CI_COMMIT_SHA
    - docker tag $REPO_NAME:$CI_COMMIT_SHA $REPO_NAME:latest
    - docker push $REPO_NAME:latest
  only:
{'fraction_non_alphanumeric': 0.1096322241681261, 'fraction_numerical': 0.011908931698774081, 'mean_word_length': 2.772787318361955, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1300054', 'n_tokens_mistral': 1135, 'n_tokens_neox': 1059, 'n_words': 235}