summaryrefslogtreecommitdiffstats
path: root/.circleci/config.yml
blob: 5d0170e1fe5a143822ad0bcee80d8690d690125f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# References:
# 1. https://circleci.com/blog/how-to-build-a-docker-image-on-circleci-2-0/
# 2. https://circleci.com/docs/2.0/building-docker-images/
#

version: 2

test_docker: &test_docker
  - image: mozillabteam/bmo-slim:20170803.1
    user: app
    environment:
      PORT: 8000
      BMO_db_user: bugs
      BMO_db_host: 127.0.0.1
      BMO_db_pass: bugs
      BMO_db_name: bugs
      BMO_memcached_servers: localhost:11211
      BMO_memcached_namespace: "bugzilla:"
      BZ_QA_CONF_FILE: /app/.circleci/selenium_test.conf
      BZ_QA_ANSWERS_FILE:  /app/.circleci/checksetup_answers.txt
  - image: mozillabteam/bmo-mysql:5.6
    environment:
      MYSQL_DATABASE: bugs
      MYSQL_USER: bugs
      MYSQL_PASSWORD: bugs
      MYSQL_ALLOW_EMPTY_PASSWORD: 1
  - image: selenium/standalone-firefox:2.53.1
  - image: memcached:latest

default_setup: &default_setup
  run:
    command: |
      mv /opt/bmo/local /app/local
      perl -MSys::Hostname -i -pE 's/<<HOSTNAME>>/hostname()/ges' $BZ_QA_CONF_FILE
      perl -MSys::Hostname -i -pE 's/<<HOSTNAME>>/hostname()/ges' $BZ_QA_ANSWERS_FILE
      perl checksetup.pl --no-database --default-localconfig
      mkdir artifacts

run_qa_httpd: &run_qa_httpd
  run:
    command: |
      /app/scripts/entrypoint.pl qa_httpd &> artifacts/httpd.log
    background: true

jobs:
  build:
    working_directory: /app
    docker:
      - image: docker:17.06.1-ce
    steps:
      - setup_remote_docker
      - run:
          name: install git and ssh
          command: apk update && apk add git openssh-client
      - checkout
      - run: |
          docker build -t bmo .
          if [[ -n "$DOCKERHUB_REPO" && -n "$DOCKER_USER" && -n "$DOCKER_PASS" ]]; then
            TAG="$CIRCLE_BRANCH"
            if [[ $TAG == "master" ]]; then
              docker tag bmo $DOCKERHUB_REPO:latest
              docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"
              docker push $DOCKERHUB_REPO:latest
            fi
          fi

  test_sanity:
    parallelism: 4
    working_directory: /app
    docker:
      - image: mozillabteam/bmo-slim:20170803.1
        user: app
    steps:
      - checkout
      - *default_setup
      - run:
          name: run sanity tests
          command: |
            prove -qf $(circleci tests glob 't/*.t' | circleci tests split) | tee artifacts/$CIRCLE_JOB.txt
      - store_artifacts:
          path: /app/artifacts

  test_webservices:
    parallelism: 1
    working_directory: /app
    docker: *test_docker
    steps:
      - checkout
      - *default_setup
      - run: /app/scripts/entrypoint.pl load_test_data
      - *run_qa_httpd
      - run: /app/scripts/entrypoint.pl test_heartbeat
      - run:
          command: |
            /app/scripts/entrypoint.pl test_webservices | tee artifacts/$CIRCLE_JOB.txt
      - store_artifacts:
          path: /app/artifacts

  test_selenium:
    parallelism: 1
    working_directory: /app
    docker: *test_docker
    steps:
      - checkout
      - *default_setup
      - run: /app/scripts/entrypoint.pl load_test_data
      - *run_qa_httpd
      - run:
          command: |
            /app/scripts/entrypoint.pl test_selenium | tee artifacts/$CIRCLE_JOB.txt
      - store_artifacts:
          path: /app/artifacts

workflows:
  version: 2
  tests:
    jobs:
      - test_sanity
      - test_webservices
      - test_selenium
      - build:
          requires:
            - test_sanity
            - test_webservices
            - test_selenium