Docs: Fixed gitlab-runner ssh-key env variable
[leap_platform.git] / .gitlab-ci.yml
1 ---
2 image: 0xacab.org:4567/leap/docker/ruby:latest
3
4 # This is for caching the gems not only between the stages, but also
5 # persistent on the gitlab-runner so we don't need to install from
6 # scratch on every pipeline
7 cache:
8   key: "global_platform_cache_between_pipelines"
9   untracked: true
10   paths:
11     - tests/platform-ci/vendor/
12
13 before_script:
14   - cd tests/platform-ci
15   # Check if running locally ($CI_PROJECT_ID is 0 then) and run setup.sh in
16   # this case
17   - if [ "$CI_PROJECT_ID" = "0" ]; then ./setup.sh; fi
18
19 stages:
20   - setup
21   - syntax
22   - deploy
23
24 setup:
25   stage: setup
26   script:
27     - ./setup.sh
28
29 lint:
30   stage: syntax
31   script:
32     - su -c '/usr/local/bin/bundle exec rake lint' cirunner
33
34 syntax:
35   stage: syntax
36   script:
37     - su -c '/usr/local/bin/bundle exec rake syntax' cirunner
38
39 validate:
40   stage: syntax
41   script:
42     - su -c '/usr/local/bin/bundle exec rake validate' cirunner
43
44 templates:
45   stage: syntax
46   script:
47     - su -c '/usr/local/bin/bundle exec rake templates' cirunner
48
49 catalog:
50   stage: syntax
51   script:
52     - su -c '/usr/local/bin/bundle exec rake catalog' cirunner
53
54 deploy_test:master:
55   stage: deploy
56   except:
57     - master
58   script:
59     - su -c 'set -o pipefail; stdbuf -oL -eL ./ci-build.sh | ts' cirunner
60
61 deploy_test:staging:
62   stage: deploy
63   variables:
64     COMPONENT: "staging"
65   script:
66     - su -c 'set -o pipefail; stdbuf -oL -eL ./ci-build.sh | ts' cirunner
67
68 # However, sometimes it's important to have a way of triggering a deploy
69 # from scratch manually even from the master branch, when i.e. new packages
70 # got uploaded to the master component of the platform deb repo.
71 deploy_test:manual:
72   stage: deploy
73   only:
74     - master
75   when: manual
76   allow_failure: false
77   script:
78     - su -c 'set -o pipefail; stdbuf -oL -eL ./ci-build.sh | ts' cirunner
79
80 # Test upgrades from the latetest release to latest HEAD
81 upgrade_test:
82   stage: deploy
83   script:
84     # Allow unpriviledged user to checkout last release of leap_platform
85     - chown cirunner:cirunner -R ../..
86     - su -c 'set -o pipefail; stdbuf -oL -eL ./ci-build.sh | ts' cirunner
87
88 # Latest job will only run on the master branch, which means all merge requests
89 # that are created from branches don't get to deploy to the latest-ci server.
90 # When a merge request is merged, then the latest job will deploy the code to
91 # the latest provider, and the deployment will be recorded in an environment
92 # named 'latest'
93 ci.leap.se:
94   stage: deploy
95   environment:
96     name: staging
97   only:
98     - master@leap/platform
99   script:
100     - >
101       su -c '/usr/bin/unbuffer /bin/bash -o pipefail ./ci-build.sh |
102       /usr/bin/ts' cirunner
103
104 demo.bitmask.net:
105   stage: deploy
106   environment:
107     name: production/demo/vpn
108   only:
109     - master
110   when: manual
111   script:
112     - >
113       su -c '/usr/bin/unbuffer /bin/bash -o pipefail ./ci-build.sh |
114       /usr/bin/ts' cirunner
115
116 mail.bitmask.net:
117   stage: deploy
118   environment:
119     name: production/demo/mail
120   only:
121     - master
122   when: manual
123   script:
124     - >
125       su -c '/usr/bin/unbuffer /bin/bash -o pipefail ./ci-build.sh |
126       /usr/bin/ts' cirunner