.gitlab-ci.yml 5.86 KB
Newer Older
1
variables:
2
  GIT_DEPTH: 1
3
  GIT_SUBMODULE_STRATEGY: recursive
4 5 6
  BURP_VERSION: 2.2.18
  PG_VERSION: 10
  SRC_DIR: burpui
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
7
  DOCKER_DRIVER: overlay2
8 9 10
  DOCKER_HOST: tcp://docker:2375
  # docker TLS issue. see: https://gitlab.com/gitlab-org/gitlab-runner/issues/4501
  DOCKER_TLS_CERTDIR: ""
11 12 13 14 15

image: docker:git

services:
  - docker:dind
16

17 18 19 20 21
stages:
  - test
  - build
  - deploy

22
test:lint:3.6:
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
23
  stage: test
24
  image: python:3.6
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
25
  script:
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
26 27
  - pip install tox
  - tox -e pep8
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
28 29 30 31
  tags:
  - lint
  except:
  - tags
32
  - rc
33
  - demo
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
34

35
test:lint:3.7:
36
  stage: test
37
  image: python:3.7
38
  script:
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
39 40
  - pip install tox
  - tox -e pep8
41 42 43 44 45 46 47
  tags:
  - lint
  except:
  - tags

test:lint:3.8:
  stage: test
48
  image: python:3.8-rc
49
  script:
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
50 51
  - pip install tox
  - tox -e pep8
52 53 54 55
  tags:
  - lint
  except:
  - tags
56
  - rc
57
  - demo
58 59 60

test:py:3.6:
  stage: test
61
  image: python:3.6
62 63
  script:
  - pip install tox
64
  - mkdir .reports
65
  - tox -e py36
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
66 67 68 69
  tags:
  - docker
  except:
  - tags
70
  - rc
71
  - demo
72 73 74
  artifacts:
    reports:
      junit: .reports/burpui.junit.xml
75

76 77
test:py:3.7:
  stage: test
78
  image: python:3.7
79 80 81 82 83 84 85 86 87 88 89 90
  script:
  - pip install tox
  - mkdir .reports
  - tox -e py37
  tags:
  - docker
  except:
  - tags
  artifacts:
    reports:
      junit: .reports/burpui.junit.xml

91
# This test is temporarily disabled because werkzeug doesn't run yet on 3.8
92
test:py:3.8:
93
  stage: test
94
  image: python:3.8-rc
95 96 97 98 99 100 101 102
  script:
  - pip install tox
  - mkdir .reports
  - tox -e py38
  tags:
  - docker
  except:
  - tags
103
  - rc
104
  - demo
105 106 107 108
  artifacts:
    reports:
      junit: .reports/burpui.junit.xml

Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
109 110
build:py3:
  stage: build
111
  image: python:3.7
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
112
  script:
113
  - tests/build.sh
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
114 115 116
  tags:
  - build
  only:
117
  - master@ziirish/burp-ui
118
  - demo@ziirish/burp-ui
119
  - stable@ziirish/burp-ui
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
120 121 122 123
  artifacts:
    paths:
    - dist/
    - meta/
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
124
    expire_in: 2 mos
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
125

Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
126 127
build:doc:
  stage: build
128
  image: python:3.7
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
129
  script:
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
130
  - pip install -U .[rtd]
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
131
  - cd docs && make html
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
132 133 134
  tags:
  - build
  only:
135
  - master@ziirish/burp-ui
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
136 137 138 139
  artifacts:
    paths:
    - docs/_build/html
    expire_in: 2 mos
140
  allow_failure: true
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
141

142 143 144
build:docker:latest:
  stage: build
  script:
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
145
  - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
146 147 148
  - docker build --pull -t $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest -f docker/Dockerfile .
  - (cd docker/demo/docker-pg && docker build --pull -t $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/pgsql:$PG_VERSION .)
  - (cd docker/components/docker-burp && docker build --pull -t $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/burp:$BURP_VERSION .)
149
  - docker push $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest
150 151
  - docker push $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/pgsql:$PG_VERSION
  - docker push $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/burp:$BURP_VERSION
152 153 154
  tags:
  - registry
  only:
155
  - rc@ziirish/burp-ui
156 157 158 159

build:docker:release:
  stage: build
  script:
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
160
  - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
161 162 163
  - docker build --pull -t $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:$CI_COMMIT_TAG -f docker/Dockerfile .
  - (cd docker/demo/docker-pg && docker build --pull -t $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/pgsql:$PG_VERSION .)
  - (cd docker/components/docker-burp && docker build --pull -t $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/burp:$BURP_VERSION .)
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
164
  - docker push $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:$CI_COMMIT_TAG
165 166
  - docker push $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/pgsql:$PG_VERSION
  - docker push $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/burp:$BURP_VERSION
167 168 169 170 171
  only:
  - tags
  tags:
  - registry

172 173 174 175
build:docker:stable:
  stage: build
  script:
  - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
176 177 178
  - docker build --pull -t $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:stable -f docker/Dockerfile .
  - (cd docker/demo/docker-pg && docker build --pull -t $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/pgsql:$PG_VERSION .)
  - (cd docker/components/docker-burp && docker build --pull -t $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/burp:$BURP_VERSION .)
179
  - docker push $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:stable
180 181
  - docker push $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/pgsql:$PG_VERSION
  - docker push $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/burp:$BURP_VERSION
182
  only:
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
183
  - stable@ziirish/burp-ui
184 185 186
  tags:
  - registry

187 188 189
build:docker:demo:
  stage: build
  script:
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
190
  - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
191
  - docker build --pull -t $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:demo -f docker/Dockerfile .
192
  - docker push $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:demo
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
193
  - apk add --no-cache curl
194
  - "curl $SENTRY_WEBHOOK -X POST -H 'Content-Type: application/json' -d '{\"version\": \"'$CI_COMMIT_REF_NAME'_'$CI_COMMIT_SHA'\"}'"
195
  only:
196
  - demo@ziirish/burp-ui
197 198 199
  tags:
  - registry

Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
200 201 202
deploy:demo:
  stage: deploy
  script:
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
203
  - find docker/demo/ -name "install" -o -name "init" | xargs sed -i "s/@build@/$CI_COMMIT_SHA/"
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
204
  - cd docker/demo/ && find . -maxdepth 1 -type d -a ! -name dist -exec cp -r ../../dist "{}/" \; -exec cp -r ../../meta "{}/" \; && cd ../..
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
205
  - find docker/demo/ -name "Dockerfile" | xargs sed -i "s,^.*@ARTIFACTS@.*$,COPY dist/*.tar.gz /tmp/burpui.dev.tar.gz,;s,^.*@BUIAGENT_ARTIFACTS@.*$,COPY meta/burp-ui-agent*.tar.gz /tmp/burp-ui-agent.dev.tar.gz,;s,^.*@BUIMONITOR_ARTIFACTS@.*$,COPY meta/burp-ui-monitor*.tar.gz /tmp/burp-ui-monitor.dev.tar.gz,"
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
206
  - test -d /srv/demo/docker && rm -rf /srv/demo/docker
207
  - cp -r docker/demo/ /srv/demo/docker
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
208
  - cd /srv/demo/docker/
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
209
  - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
210
  - docker-compose build --pull
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
211
  - docker-compose stop
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
212
  - docker-compose rm -f
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
213 214 215 216
  - docker-compose up -d
  tags:
  - deploy
  only:
217
  - demo@ziirish/burp-ui
218 219 220
  environment:
    name: demo
    url: https://demo.burp-ui.org/
Benjamin "Ziirish" SANS's avatar
Benjamin "Ziirish" SANS committed
221 222
  variables:
    DOCKER_HOST: unix:///var/run/docker.sock