a328c0309dc3440a19514a5eab0d66d98a912b48
[oweals/peertube.git] / .gitlab-ci.yml
1 image: chocobozzz/peertube-ci:10
2
3 stages:
4   - build-and-lint
5   - test
6   - docker-nightly
7   - clients
8
9 #before_script:
10 #  - 'sed -i -z "s/database:\n  hostname: ''localhost''/database:\n  hostname: ''postgres''/" config/test.yaml'
11 #  - 'sed -i -z "s/redis:\n  hostname: ''localhost''/redis:\n  hostname: ''redis''/" config/test.yaml'
12 #  - if [[ $CI_JOB_STAGE == "test" ]]; then psql -c "create user peertube with password 'peertube';"; fi
13 #  - NOCLIENT=1 yarn install --pure-lockfile --cache-folder .yarn-cache
14
15 cache:
16   key: yarn
17   paths:
18     - .yarn-cache
19     - cached-fixtures
20
21 ###
22 ## Jobs templates
23 #
24 #.build-and-lint: &build-and-lint
25 #  stage: build-and-lint
26 #
27 #.tests: &tests
28 #  stage: test
29 #  dependencies:
30 #    - build-server
31 #  services:
32 #    - name: postgres:9.6
33 #      alias: postgres
34 #    - name: redis:latest
35 #      alias: redis
36 #  variables:
37 #    PGHOST: postgres
38 #    PGUSER: postgres
39 #    REDIS_HOST: redis
40 #  artifacts:
41 #    expire_in: 1 day
42 #    paths:
43 #      - test*/logs
44 #    when: always
45 #
46 ####
47 ### Build and lint
48 ##
49 #build-server:
50 #  <<: *build-and-lint
51 #  artifacts:
52 #    expire_in: 5h
53 #    paths:
54 #      - dist/
55 #  script:
56 #    - npm run build:server
57 #
58 #lint:
59 #  <<: *build-and-lint
60 #  script:
61 #    - yarn install --pure-lockfile --cache-folder .yarn-cache
62 #    - npm run ci -- "lint"
63 #
64 ####
65 ### Tests
66 #
67 #test-misc:
68 #  <<: *tests
69 #  script:
70 #    - yarn install --pure-lockfile --cache-folder .yarn-cache
71 #    - npm run ci -- "misc"
72 #
73 #test-cli:
74 #  <<: *tests
75 #  retry:
76 #    max: 1
77 #  script:
78 #    - npm run ci -- "cli"
79 #
80 #api:
81 #  <<: *tests
82 #  parallel: 4
83 #  retry:
84 #    max: 1
85 #  script:
86 #    - NODE_PENDING_JOB_WAIT=1000 npm run ci -- api-$CI_NODE_INDEX
87
88 build-openapi-clients:
89   stage: clients
90   needs: []
91   only:
92     refs:
93       - master
94       - schedules
95     changes:
96       - support/doc/api/openapi.yaml
97   script: 
98     - apt-get update -qq
99     - apt-get -yqqq install openjdk-8-jre
100     - yarn install --pure-lockfile
101     - scripts/openapi-peertube-version.sh
102     - scripts/openapi-clients.sh
103
104 build-nightly:
105   stage: docker-nightly
106   only:
107     - schedules
108   script:
109     - yarn install --pure-lockfile --cache-folder .yarn-cache
110     - npm run nightly
111     - mkdir "${HOME}/.ssh"
112     - chmod 700 "${HOME}/.ssh"
113     - if [ ! -z ${DEPLOYEMENT_KNOWN_HOSTS+x} ]; then echo -e "${DEPLOYEMENT_KNOWN_HOSTS}" > ${HOME}/.ssh/known_hosts; fi
114     - eval `ssh-agent -s`
115     - if [ ! -z ${DEPLOYEMENT_KEY+x} ]; then ssh-add <(echo "${DEPLOYEMENT_KEY}"); fi
116     - if [ ! -z ${DEPLOYEMENT_KEY+x} ]; then scp ./peertube-nightly-* ${DEPLOYEMENT_USER}@${DEPLOYEMENT_HOST}:../../web/nightly; fi
117
118 .docker: &docker
119   stage: docker-nightly
120   cache: {}
121   image:
122     name: gcr.io/kaniko-project/executor:debug
123     entrypoint: [""]
124   before_script:
125     - echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$CI_REGISTRY_AUTH\",\"email\":\"$CI_REGISTRY_EMAIL\"}}}" > /kaniko/.docker/config.json
126   script:
127     - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/support/docker/production/Dockerfile.buster --destination $DOCKER_IMAGE_NAME
128
129 build-docker-develop:
130   <<: *docker
131   only:
132     - schedules
133   variables:
134     DOCKER_IMAGE_NAME: chocobozzz/peertube:develop-buster
135
136 build-docker-tag:
137   <<: *docker
138   only:
139     - tags
140   variables:
141     DOCKER_IMAGE_NAME: chocobozzz/peertube:$CI_COMMIT_TAG-buster
142
143 build-docker-master:
144   <<: *docker
145   only:
146     - master
147   variables:
148     DOCKER_IMAGE_NAME: chocobozzz/peertube:production-buster