.gitlab-ci.yml 4.61 KB
Newer Older
Ludan Stoecklé's avatar
Ludan Stoecklé committed
1
stages:
Ludan Stoecklé's avatar
1.5.2  
Ludan Stoecklé committed
2 3 4 5 6
  - code_build
  - code_publish
  - docker_build
  - docker_test
  - docker_release
Ludan Stoecklé's avatar
Ludan Stoecklé committed
7

Ludan Stoecklé's avatar
1.5.2  
Ludan Stoecklé committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21

# stuff for some steps only

.template_for_docker: &template_for_docker
  image: docker:git
  services:
    - docker:dind

.docker_repo_login: &docker_repo_login
  - echo "$CI_BUILD_TOKEN" | docker login -u gitlab-ci-token --password-stdin registry.gitlab.com

# variables etc.

variables:
Ludan Stoecklé's avatar
1.14.0  
Ludan Stoecklé committed
22
  ROSAENLG_VERSION: 1.14.0
Ludan Stoecklé's avatar
1.5.2  
Ludan Stoecklé committed
23 24 25 26 27 28 29 30 31
  DOCKER_REGISTRY: registry.gitlab.com/rosaenlg-projects/rosaenlg
  DOCKER_CLI_ROOT: ${DOCKER_REGISTRY}/cli
  DOCKER_SERVER_ROOT: ${DOCKER_REGISTRY}/server
  DOCKER_TEST_TAG: test_${CI_COMMIT_REF_SLUG}

# code build and publish

build_the_code:
  stage: code_build
Ludan Stoecklé's avatar
Ludan Stoecklé committed
32
  image: node
Ludan Stoecklé's avatar
Ludan Stoecklé committed
33 34
  cache:
    paths:
Ludan Stoecklé's avatar
1.5.2  
Ludan Stoecklé committed
35
      - node_modules/
Ludan Stoecklé's avatar
Ludan Stoecklé committed
36 37 38
      - packages/*/node_modules
    untracked: true
  script:
Ludan Stoecklé's avatar
Ludan Stoecklé committed
39 40
    - npm -v
    - node --version
Ludan Stoecklé's avatar
Ludan Stoecklé committed
41 42 43
    - npm install -g pegjs
    - npm install -g lerna
    - lerna bootstrap --concurrency 8
Ludan Stoecklé's avatar
1.8.0  
Ludan Stoecklé committed
44
    - rm -f packages/rosaenlg/dist/rollup/*.js
Ludan Stoecklé's avatar
Ludan Stoecklé committed
45 46 47 48 49 50 51
    - lerna run build
    - lerna run test
  artifacts:
    paths:
      - packages/*/resources_pub
      - packages/*/dist
    expire_in: 1 day
Ludan Stoecklé's avatar
Ludan Stoecklé committed
52 53
  except:
    - master
Ludan Stoecklé's avatar
Ludan Stoecklé committed
54

Ludan Stoecklé's avatar
1.5.2  
Ludan Stoecklé committed
55 56
publish_on_npm:
  stage: code_publish
Ludan Stoecklé's avatar
Ludan Stoecklé committed
57
  image: node
Ludan Stoecklé's avatar
Ludan Stoecklé committed
58 59
  script:
    - npm install -g lerna
Ludan Stoecklé's avatar
Ludan Stoecklé committed
60 61
    - npm install -g snyk
    - snyk auth $SNYK_TOKEN
Ludan Stoecklé's avatar
Ludan Stoecklé committed
62 63 64 65 66 67 68
    - npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
    - npm config set always-auth=true
    - npm config set [email protected]
    - npm config list
    - npm whoami
    - lerna publish from-package --yes
  only:
69
    - /^v[0-9]+\.[0-9]+\.[0-9]+$/
Ludan Stoecklé's avatar
1.5.3  
Ludan Stoecklé committed
70
  # when: manual
Ludan Stoecklé's avatar
1.5.2  
Ludan Stoecklé committed
71

Ludan Stoecklé's avatar
1.12.0  
Ludan Stoecklé committed
72
publish_browser_ide_s3_and_swaggers:
Ludan Stoecklé's avatar
1.5.2  
Ludan Stoecklé committed
73 74 75 76 77 78 79 80 81 82 83
  stage: code_publish
  image: node
  cache:
    paths:
      - node_modules/
      - packages/*/node_modules
    untracked: true
  script:
    - npm install -g lerna
    - lerna bootstrap --concurrency 8
    - node node_modules/gulp/bin/gulp.js --gulpfile packages/browser-ide-demo/gulpfile.js s3
Ludan Stoecklé's avatar
1.6.0  
Ludan Stoecklé committed
84
    - node node_modules/gulp/bin/gulp.js --gulpfile packages/rosaenlg-node-server/gulpfile.js s3
Ludan Stoecklé's avatar
1.12.0  
Ludan Stoecklé committed
85
    - node node_modules/gulp/bin/gulp.js --gulpfile packages/rosaenlg-lambda/gulpfile.js s3
Ludan Stoecklé's avatar
1.5.2  
Ludan Stoecklé committed
86 87
  only:
   - /^v[0-9]+\.[0-9]+\.[0-9]+$/
Ludan Stoecklé's avatar
1.5.3  
Ludan Stoecklé committed
88
  # when: manual
Ludan Stoecklé's avatar
1.5.2  
Ludan Stoecklé committed
89 90 91 92 93 94 95 96 97 98 99 100 101


# docker for CLI

docker_build_cli:
  stage: docker_build
  <<: *template_for_docker
  before_script:
    - *docker_repo_login
  script:
    - cd packages/rosaenlg-cli/docker/
    - docker build --build-arg ROSAENLG_VERSION=$ROSAENLG_VERSION --pull -t $DOCKER_CLI_ROOT:$DOCKER_TEST_TAG .
    - docker push $DOCKER_CLI_ROOT:$DOCKER_TEST_TAG
Ludan Stoecklé's avatar
Ludan Stoecklé committed
102 103
  except:
    - master
Ludan Stoecklé's avatar
1.5.2  
Ludan Stoecklé committed
104 105 106 107 108 109 110 111 112

docker_test_cli:
  stage: docker_test
  <<: *template_for_docker
  script:
    - cd packages/rosaenlg-cli/docker/
    - docker pull $DOCKER_CLI_ROOT:$DOCKER_TEST_TAG
    - chmod +x ./test.sh
    - /bin/sh ./test.sh $DOCKER_CLI_ROOT:$DOCKER_TEST_TAG
Ludan Stoecklé's avatar
Ludan Stoecklé committed
113 114
  except:
    - master
Ludan Stoecklé's avatar
1.5.2  
Ludan Stoecklé committed
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130

docker_release_cli:
  stage: docker_release
  <<: *template_for_docker
  before_script:
    - *docker_repo_login
  script:
    - docker pull $DOCKER_CLI_ROOT:$DOCKER_TEST_TAG
    # tag and push latest
    - docker tag $DOCKER_CLI_ROOT:$DOCKER_TEST_TAG $DOCKER_CLI_ROOT:latest
    - docker push $DOCKER_CLI_ROOT:latest
    # tag and push version
    - docker tag $DOCKER_CLI_ROOT:$DOCKER_TEST_TAG $DOCKER_CLI_ROOT:$ROSAENLG_VERSION
    - docker push $DOCKER_CLI_ROOT:$ROSAENLG_VERSION
  only:
   - /^v[0-9]+\.[0-9]+\.[0-9]+$/
Ludan Stoecklé's avatar
1.5.3  
Ludan Stoecklé committed
131
  # when: manual
Ludan Stoecklé's avatar
1.5.2  
Ludan Stoecklé committed
132 133 134 135 136 137 138 139 140 141 142 143 144


# docker for server

docker_build_server:
  stage: docker_build
  <<: *template_for_docker
  before_script:
    - *docker_repo_login
  script:
    - cd packages/rosaenlg-node-server/docker/
    - docker build --build-arg ROSAENLG_VERSION=$ROSAENLG_VERSION --pull -t $DOCKER_SERVER_ROOT:$DOCKER_TEST_TAG .
    - docker push $DOCKER_SERVER_ROOT:$DOCKER_TEST_TAG
Ludan Stoecklé's avatar
Ludan Stoecklé committed
145 146
  except:
    - master
Ludan Stoecklé's avatar
1.5.2  
Ludan Stoecklé committed
147 148 149 150 151 152 153 154 155 156 157 158 159 160

docker_test_server:
  stage: docker_test
  <<: *template_for_docker
  before_script:
    - apk add --update curl && rm -rf /var/cache/apk/*
  script:
    - cd packages/rosaenlg-node-server/docker/
    - docker pull $DOCKER_SERVER_ROOT:$DOCKER_TEST_TAG
    - docker run -d -p 5000:5000 $DOCKER_SERVER_ROOT:$DOCKER_TEST_TAG
    - sleep 20
    - ps -ef
    - chmod +x ./test.sh
    - /bin/sh ./test.sh
Ludan Stoecklé's avatar
Ludan Stoecklé committed
161 162
  except:
    - master
Ludan Stoecklé's avatar
1.5.2  
Ludan Stoecklé committed
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178

docker_release_server:
  stage: docker_release
  <<: *template_for_docker
  before_script:
    - *docker_repo_login
  script:
    - docker pull $DOCKER_SERVER_ROOT:$DOCKER_TEST_TAG
    # tag and push latest
    - docker tag $DOCKER_SERVER_ROOT:$DOCKER_TEST_TAG $DOCKER_SERVER_ROOT:latest
    - docker push $DOCKER_SERVER_ROOT:latest
    # tag and push version
    - docker tag $DOCKER_SERVER_ROOT:$DOCKER_TEST_TAG $DOCKER_SERVER_ROOT:$ROSAENLG_VERSION
    - docker push $DOCKER_SERVER_ROOT:$ROSAENLG_VERSION
  only:
   - /^v[0-9]+\.[0-9]+\.[0-9]+$/
Ludan Stoecklé's avatar
1.5.3  
Ludan Stoecklé committed
179
  # when: manual
Ludan Stoecklé's avatar
1.7.1  
Ludan Stoecklé committed
180