heptapod-ci.yml 5.25 KB
Newer Older
1
2
3
4
5
6
7
# We're using only some parts of the full upstream CI setup
# Notably, our needs in terms of caching will probably be different than
# upstream's.
#
# Of course it'd be a good thing to converge eventually to something closer
# to upstream, but we are just at the beginning of the CI process for Heptapod.

8
stages:
9
  - prepare
10
11
12
  - test
  - upload

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
variables:
  # copied from .gitlab-ci.yml, some of these may not be useful yet,
  # but some are needed (RAILS_ENV is the first example)
  RAILS_ENV: "test"
  NODE_ENV: "test"
  SIMPLECOV: "true"
  GIT_DEPTH: "20"
  GIT_SUBMODULE_STRATEGY: "none"
  GET_SOURCES_ATTEMPTS: "3"
  KNAPSACK_RSPEC_SUITE_REPORT_PATH: knapsack/report-master.json
  FLAKY_RSPEC_SUITE_REPORT_PATH: rspec_flaky/report-suite.json
  BUILD_ASSETS_IMAGE: "false"
  ES_JAVA_OPTS: "-Xms256m -Xmx256m"
  ELASTIC_URL: "http://elastic:changeme@elasticsearch:9200"
  DOCKER_VERSION: "19.03.0"

include:
  - local: .gitlab/ci/global.gitlab-ci.yml

32
33
34
35
36
37
38
39
40
.heptapod-rails-cache:
  extends:
    - .rails-cache
  cache:
    # we include the full GitLab version because that'll typically differ
    # across named branches, but also at each bump of within the
    # release/support branches, such as heptapod-0-15. What kind of
    # cleanup/invalidation we really want is not clear, so for now it's
    # best to keep them really separate.
41
    key: "hpd-rails-13.5.4"
42
43
44
45
46
47
    # our policy differs from GitLab upstream setup, which uses the `pull`
    # policy, but also has the separate
    # `update-rails-cache` job to push the cache, triggered by certain
    # Merge Requests (see `.shared:rules:update-cache`)
    policy: pull-push

48
49
50
51
52
# this plays the role of the setup-test-env and compile-test-assets jobs
# of upstream GitLab. The main difference is that it is "colder" a single
# tarball per GitLab version. Even with frontend assets, the differences
# we can introduce on a given GitLab version don't matter for RSpec tests.
# It will be a different story when we launch functional tests ("qa").
53
gitlab-prebuilds:
54
55
  rules:
    - if: '$UPDATE_GITLAB_PREBUILDS'
56
57
58
59
60
61
62
63
64
65
66
67
  extends:
    - .use-pg11  # base image and services
    - .default-before_script # shell functions and some environment vars
    - .heptapod-rails-cache
  stage: prepare
  variables:
    GITLAB_TEST_EAGER_LOAD: "0"
  script:
    - rm -rf tmp/tests/gitaly  # stale files from previous builds can prevent proper installation
    - run_timed_command "bundle exec ruby -I. -e 'require \"config/environment\"; TestEnv.init'"
    - run_timed_command "scripts/gitaly-test-build"  # Do not use 'bundle exec' here
    - rm tmp/tests/gitaly/.ruby-bundle  # This file prevents gems from being installed even if vendor/gitaly-ruby is missing
68
69
70
71
72
73
74
    # frontend assets production, copied from compile-assets-base.
    - node --version
    - run_timed_command "retry yarn install --frozen-lockfile"
    - free -m
    - run_timed_command "bin/rake gitlab:assets:compile > assets-compile.log 2>&1"
    - run_timed_command "scripts/clean-old-cached-assets"
    # end of frontent assets production
75
76
    - run_timed_command "scripts/hgitaly-test-build"
    - scripts/heptapod-make-push-gitlab-prebuilds.sh
77
78
79
80
81
  artifacts:
    paths:
      - assets-compile.log
    when: always

82

83
rspec:
84
  rules:
85
86
87
88
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      allow_failure: false
    - if: '$CI_PIPELINE_SOURCE != "merge_request_event"'
      when: manual
89
      allow_failure: true
90
91
92
93
94
95
  # sharding (automatically sets the CI_NODE_{INDEX,TOTAL} expected by knapsack)
  parallel: 6
  variables:
    # reconverted for rspec-retries (so this is a per-example retry, not
    # retry of the full shard), including the silly missing +1
    RETRIES: 6
96
97
98
  extends:
    - .use-pg11  # base image and services
    - .default-before_script # shell functions and some environment vars
99
    - .heptapod-rails-cache
100
101
102
103
104
  artifacts:
    when: on_failure
    paths:
      - log/hgitaly-test.log
      - config/gitlab.yml
105
  script:
106
107
    # TODO put it in cellar and benefit from site-local caches
    - wget --progress=dot:giga -O /tmp/gitlab-prebuilds.tar.gz https://download.heptapod.net/gitlab-prebuilds/ci-$(cat VERSION).tar.gz
108
    - run_timed_command "tar xzf /tmp/gitlab-prebuilds.tar.gz"
109
    - ls -al tmp/tests/*
110
    - run_timed_command "gem install knapsack --no-document"
111
112
    - run_timed_command "scripts/gitaly-test-build"  # Do not use 'bundle exec' here
    - run_timed_command "scripts/gitaly-test-spawn"
113
114
115
    # python components already installed, but this will refresh them
    # and update subsequent conf (gitlab.yml etc)
    - run_timed_command "scripts/hgitaly-test-build"
116
    - run_timed_command "scripts/hgitaly-test-spawn"
117
118
    - grep -A3 'hgrc:' config/gitlab.yml
    - cat $PWD/config/tests.hgrc
119
    - scripts/heptapod_knapsack.sh
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136


tarball:
  stage: upload
  needs: []
  rules:
    - if: '$CI_COMMIT_TAG =~ /^heptapod-/'
      when: always
    - if: '$CI_PIPELINE_SOURCE == "web"'
      when: manual
      allow_failure: true
    - if: '$CI_PIPELINE_SOURCE == "push"'
      when: manual
      allow_failure: true  # necessary to not count as failure if not launched

  # this CI image may be overkill, but it gives us in particular a working
  # recent Mercurial, and it should already be present in all runners
137
  image: "registry.heptapod.net/heptapod/ci-images/heptapod-base:default"
138
139
  script:
    - scripts/heptapod-make-push-tarball.sh