.gitlab-ci.yml 4.29 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.5.3  
Ludan Stoecklé committed
22
  ROSAENLG_VERSION: 1.5.3
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
Ludan Stoecklé committed
44
    - rm packages/rosaenlg/dist/browser/*.js
Ludan Stoecklé's avatar
Ludan Stoecklé committed
45 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
1.5.2  
Ludan Stoecklé committed
53 54
publish_on_npm:
  stage: code_publish
Ludan Stoecklé's avatar
Ludan Stoecklé committed
55
  image: node
Ludan Stoecklé's avatar
Ludan Stoecklé committed
56 57
  script:
    - npm install -g lerna
Ludan Stoecklé's avatar
Ludan Stoecklé committed
58 59
    - npm install -g snyk
    - snyk auth $SNYK_TOKEN
Ludan Stoecklé's avatar
Ludan Stoecklé committed
60 61 62 63 64 65 66
    - 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:
67
    - /^v[0-9]+\.[0-9]+\.[0-9]+$/
Ludan Stoecklé's avatar
1.5.3  
Ludan Stoecklé committed
68
  # when: manual
Ludan Stoecklé's avatar
1.5.2  
Ludan Stoecklé committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83

publish_browser_ide_s3:
  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
  only:
   - /^v[0-9]+\.[0-9]+\.[0-9]+$/
Ludan Stoecklé's avatar
1.5.3  
Ludan Stoecklé committed
84
  # when: manual
Ludan Stoecklé's avatar
1.5.2  
Ludan Stoecklé committed
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123



# 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

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

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
124
  # when: manual
Ludan Stoecklé's avatar
1.5.2  
Ludan Stoecklé committed
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167


# 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

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

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
168
  # when: manual