.gitlab-ci.yml 5.11 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
1.7.1  
Ludan Stoecklé committed
7
  - docker_release_mirror
Ludan Stoecklé's avatar
Ludan Stoecklé committed
8

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

# 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.7.1  
Ludan Stoecklé committed
23
  ROSAENLG_VERSION: 1.7.1
Ludan Stoecklé's avatar
1.5.2  
Ludan Stoecklé committed
24 25 26 27 28 29 30 31 32
  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
33
  image: node
Ludan Stoecklé's avatar
Ludan Stoecklé committed
34 35
  cache:
    paths:
Ludan Stoecklé's avatar
1.5.2  
Ludan Stoecklé committed
36
      - node_modules/
Ludan Stoecklé's avatar
Ludan Stoecklé committed
37 38 39
      - packages/*/node_modules
    untracked: true
  script:
Ludan Stoecklé's avatar
Ludan Stoecklé committed
40 41
    - npm -v
    - node --version
Ludan Stoecklé's avatar
Ludan Stoecklé committed
42 43 44
    - npm install -g pegjs
    - npm install -g lerna
    - lerna bootstrap --concurrency 8
Ludan Stoecklé's avatar
Ludan Stoecklé committed
45
    - rm -f packages/rosaenlg/dist/browser/*.js
Ludan Stoecklé's avatar
Ludan Stoecklé committed
46 47 48 49 50 51 52
    - lerna run build
    - lerna run test
  artifacts:
    paths:
      - packages/*/resources_pub
      - packages/*/dist
    expire_in: 1 day
Ludan Stoecklé's avatar
Ludan Stoecklé committed
53 54
  except:
    - master
Ludan Stoecklé's avatar
Ludan Stoecklé committed
55

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

Ludan Stoecklé's avatar
1.6.0  
Ludan Stoecklé committed
73
publish_browser_ide_s3_and_swagger:
Ludan Stoecklé's avatar
1.5.2  
Ludan Stoecklé committed
74 75 76 77 78 79 80 81 82 83 84
  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
85
    - node node_modules/gulp/bin/gulp.js --gulpfile packages/rosaenlg-node-server/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 181 182 183 184 185 186 187 188 189 190 191 192 193 194


mirror_on_ecr:
  stage: docker_release_mirror
  image: guss77/dind-awscli
  services:
    - docker:dind
  script:
    - aws --version
    - docker --version
    - docker pull registry.gitlab.com/rosaenlg-projects/rosaenlg/server:$ROSAENLG_VERSION
    - $(aws ecr get-login --no-include-email --region eu-west-1)
    - docker tag registry.gitlab.com/rosaenlg-projects/rosaenlg/server:$ROSAENLG_VERSION 581498010210.dkr.ecr.eu-west-1.amazonaws.com/rosaenlg/server:$ROSAENLG_VERSION
    - docker push 581498010210.dkr.ecr.eu-west-1.amazonaws.com/rosaenlg/server:$ROSAENLG_VERSION