.gitlab-ci.yml 6.85 KB
Newer Older
Tom Käsler's avatar
Tom Käsler committed
1
stages:
2
  - install
3
  - test
4
  - build
5
  - assets
Christopher Fullarton's avatar
Christopher Fullarton committed
6
  - sync_sentry
Tom Käsler's avatar
Tom Käsler committed
7
  - deploy
8 9
  - build-beta
  - assets-beta
Christopher Fullarton's avatar
Christopher Fullarton committed
10
  - sync_sentry-beta
11
  - deploy-beta
Tom Käsler's avatar
Tom Käsler committed
12

Tom Käsler's avatar
Tom Käsler committed
13 14 15 16
# Cache modules in between jobs
cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
17
    - node_modules/
Tom Käsler's avatar
Tom Käsler committed
18

Tom Käsler's avatar
Tom Käsler committed
19
install_node_modules:
20
  stage: install
Christopher Mark Fullarton's avatar
Christopher Mark Fullarton committed
21
  except:
22
    - /^i18n-change.*/ix
23 24 25
  tags:
    - nodejs
  script:
26
    - npm install
Tom Käsler's avatar
Tom Käsler committed
27

28
ts_lint:
29
  stage: test
Christopher Mark Fullarton's avatar
Christopher Mark Fullarton committed
30
  except:
31
    - /^i18n-change.*/ix
32 33 34
  tags:
    - nodejs
  script:
35
    - npm install
36
    - node_modules/tslint/bin/tslint -c tslint.json -p tsconfig.json
37

38
npm_test:
39
  stage: test
40
  allow_failure: true
41 42
  tags:
    - nodejs
43
    - angular
44
  script:
45 46 47
    - curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add
    - echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
    - apt-get -y update
48
    - apt-get -y install --allow-unauthenticated google-chrome-stable
49
    - npm install
50
    - npm test
51

Tom Käsler's avatar
Tom Käsler committed
52 53 54 55 56 57
build:
  stage: build
  only:
    - master
  tags:
    - nodejs
58
    - angular
59 60
  before_script:
    - sed -ri "s|\"VERSION\"|\"$CI_COMMIT_SHA\"|" src/environments/environment.thm.staging.ts
Tom Käsler's avatar
Tom Käsler committed
61
  script:
62
    - npm install
63
    - npm install typescript@3.5.3
64
    - npm run build:STAGING_THM
65 66 67 68 69
  artifacts:
    paths:
      - dist

generate_assets:
70 71 72
  stage: assets
  only:
    - master
73 74 75 76 77 78 79
  tags:
    - nodejs
  dependencies:
    - build
  script:
    - apt-get -y update
    - apt-get -y install --allow-unauthenticated gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
80
    - npm install -g angular-http-server
Christopher Fullarton's avatar
Christopher Fullarton committed
81
    - cd dist
82
    - angular-http-server --path browser/ --silent -p 4711 &
83 84 85
    - cd browser/assets/jobs
    - node GenerateMetaNodes.js --command=generateLinkImages --baseUrl=https://staging.arsnova.click
    - node GenerateMetaNodes.js --command=generateManifest --baseUrl=https://staging.arsnova.click
86 87 88 89
    - node --experimental-modules GenerateImages.mjs --command=generateLogoImages
    - node --experimental-modules GenerateImages.mjs --command=generateFrontendPreview --host=http://localhost:4711 --root=true
    - cd ../../../..
    - npm run compress
Tom Käsler's avatar
Tom Käsler committed
90 91
  artifacts:
    paths:
Tom Käsler's avatar
Tom Käsler committed
92
      - dist
Tom Käsler's avatar
Tom Käsler committed
93

94
sync_sentry:
Christopher Fullarton's avatar
Christopher Fullarton committed
95
  stage: sync_sentry
96
  allow_failure: true
97 98
  only:
    - master
99 100
  tags:
    - nodejs
101 102 103
  dependencies:
    - generate_assets
  script:
104
    - npm install @sentry/cli
105 106 107 108 109
    - echo "Create a new release $CI_COMMIT_SHA"
    #- export SENTRY_URL=$SENTRY_BASE_URL
    - export SENTRY_AUTH_TOKEN=$SENTRY_BASE_TOKEN
    - export SENTRY_ORG=$SENTRY_BASE_ORGANIZATION
    - export SENTRY_PROJECT=$SENTRY_BASE_PROJECT
110 111 112 113
    - node_modules/@sentry/cli/bin/sentry-cli releases new $CI_COMMIT_SHA
    - node_modules/@sentry/cli/bin/sentry-cli releases set-commits --auto $CI_COMMIT_SHA
    - node_modules/@sentry/cli/bin/sentry-cli releases files $CI_COMMIT_SHA upload-sourcemaps $CI_PROJECT_DIR/dist -x .js -x .map --validate --verbose --rewrite --strip-common-prefix
    - node_modules/@sentry/cli/bin/sentry-cli releases finalize $CI_COMMIT_SHA
114 115
    - echo "Finalized release for $CI_COMMIT_SHA"

Tom Käsler's avatar
Tom Käsler committed
116 117 118 119 120
deploy:
  stage: deploy
  only:
    - master
  tags:
121
    - rsync
Tom Käsler's avatar
Tom Käsler committed
122
  dependencies:
Christopher Fullarton's avatar
Christopher Fullarton committed
123
    - generate_assets
124
  environment:
Christopher Fullarton's avatar
Christopher Fullarton committed
125
    name: Staging
Tom Käsler's avatar
Tom Käsler committed
126
  script:
Tom Käsler's avatar
Tom Käsler committed
127
    - chmod -R a+rX,ug+w .
Tom Käsler's avatar
Tom Käsler committed
128
    - eval $(ssh-agent -s)
Tom Käsler's avatar
Tom Käsler committed
129 130
    - mkdir ~/.ssh
    - ssh-keyscan "$STAGING_FRONTEND_URL" >> ~/.ssh/known_hosts
Tom Käsler's avatar
Tom Käsler committed
131
    - ssh-add <(echo "$STAGING_SSH_PRIVATE_KEY")
132
    #- rm dist/*.map
Tom Käsler's avatar
Tom Käsler committed
133
    - rsync -rltgoDqv --delete -e "ssh" dist/* "$STAGING_FRONTEND_SCP_URL"
134
    - ssh $STAGING_SSH 'touch /home/arsnova/arsnova.click-v2/frontend/deploy.touch'
135

136 137
build-beta:
  stage: build-beta
138
  only:
139
    - beta
140 141 142
  tags:
    - nodejs
    - angular
143 144
  before_script:
    - sed -ri "s|\"VERSION\"|\"$CI_COMMIT_SHA\"|" src/environments/environment.thm.beta.ts
145 146
  script:
    - npm install
147
    - npm install typescript@3.5.3
148
    - npm run build:BETA_THM
149 150
  artifacts:
    paths:
151
      - dist
152

153 154
generate_assets-beta:
  stage: assets-beta
155
  only:
156
    - beta
157 158 159
  tags:
    - nodejs
  dependencies:
160
    - build-beta
161 162 163 164
  script:
    - apt-get -y update
    - apt-get -y install --allow-unauthenticated gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
    - npm install -g angular-http-server
165
    - cd dist
166 167 168 169
    - angular-http-server --path browser/ --silent -p 4711 &
    - cd browser/assets/jobs
    - node GenerateMetaNodes.js --command=generateLinkImages --baseUrl=https://beta.arsnova.click
    - node GenerateMetaNodes.js --command=generateManifest --baseUrl=https://beta.arsnova.click
170 171 172 173
    - node --experimental-modules GenerateImages.mjs --command=generateLogoImages
    - node --experimental-modules GenerateImages.mjs --command=generateFrontendPreview --host=http://localhost:4711 --root=true
    - cd ../../../..
    - npm run compress
174 175
  artifacts:
    paths:
176
      - dist
177

178
sync_sentry-beta:
Christopher Fullarton's avatar
Christopher Fullarton committed
179
  stage: sync_sentry-beta
180
  allow_failure: true
181 182
  only:
    - beta
183 184
  tags:
    - nodejs
185 186 187
  dependencies:
    - generate_assets-beta
  script:
188
    - npm install @sentry/cli
189 190 191 192 193
    - echo "Create a new release $CI_COMMIT_SHA"
    #- export SENTRY_URL=$SENTRY_BASE_URL
    - export SENTRY_AUTH_TOKEN=$SENTRY_BASE_TOKEN
    - export SENTRY_ORG=$SENTRY_BASE_ORGANIZATION
    - export SENTRY_PROJECT=$SENTRY_BASE_PROJECT
194 195 196 197
    - node_modules/@sentry/cli/bin/sentry-cli releases new $CI_COMMIT_SHA
    - node_modules/@sentry/cli/bin/sentry-cli releases set-commits --auto $CI_COMMIT_SHA
    - node_modules/@sentry/cli/bin/sentry-cli releases files $CI_COMMIT_SHA upload-sourcemaps $CI_PROJECT_DIR/dist -x .js -x .map --validate --verbose --rewrite --strip-common-prefix
    - node_modules/@sentry/cli/bin/sentry-cli releases finalize $CI_COMMIT_SHA
198 199
    - echo "Finalized release for $CI_COMMIT_SHA"

200 201
deploy-beta:
  stage: deploy-beta
202
  only:
203
    - beta
204 205 206
  tags:
    - rsync
  dependencies:
Christopher Fullarton's avatar
Christopher Fullarton committed
207
    - generate_assets-beta
208
  environment:
Christopher Fullarton's avatar
Christopher Fullarton committed
209
    name: Beta
210 211 212 213 214 215
  script:
    - chmod -R a+rX,ug+w .
    - eval $(ssh-agent -s)
    - mkdir ~/.ssh
    - ssh-keyscan "$STAGING_FRONTEND_URL" >> ~/.ssh/known_hosts
    - ssh-add <(echo "$STAGING_SSH_PRIVATE_KEY")
216
    #- rm dist/*.map
217
    - rsync -rltgoDqv --delete -e "ssh" dist/* "$BETA_FRONTEND_SCP_URL"
218
    - ssh $STAGING_SSH 'touch /home/arsnova/arsnova.click-v2-beta/frontend/deploy.touch'