.gitlab-ci.yml 3.72 KB
Newer Older
Éloïs's avatar
Éloïs committed
1
stages:
2
  - github-sync
releaser-duniter's avatar
releaser-duniter committed
3
  - build
Éloïs's avatar
Éloïs committed
4
  - test
5
  - integration
Stéphane Veyret's avatar
Stéphane Veyret committed
6 7 8
  - package
  - prerelease
  - release
9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
push_to_github:
  stage: github-sync
  variables:
    GIT_STRATEGY: none
  tags:
    - github
  script:
    - rm -rf ./*
    - rm -rf .git
    - git clone --mirror $CI_REPOSITORY_URL .
    - git remote add github $GITHUB_URL_AND_KEY
    - git config --global user.email "contact@duniter.org"
    - git config --global user.name "Duniter"
    # Job would fail if we don't remove refs about pull requests
    - bash -c "cat packed-refs | grep -v 'refs/pull' > packed-refs-new; echo 'Removed pull refs.'"
    - mv packed-refs-new packed-refs
    - bash -c "git push --force --mirror github 2>&1 | grep -v duniter-gitlab; echo $?"
  only:
    - master
    - dev
Stéphane Veyret's avatar
Stéphane Veyret committed
30

31 32 33 34 35 36 37 38 39 40 41
.changes: &changes
  only:
    changes:
      - app/**/*
      - bin/duniter
      - .gitlab-ci.yml
      - index.ts
      - package.json
      - releases/**/*
      - server.ts
      - test/**/*
42
      - .gitlab/test/*
43

Stéphane Veyret's avatar
Stéphane Veyret committed
44
.nvm_env: &nvm_env
45
  image: registry.duniter.org/docker/duniter-ci:v0.0.4
releaser-duniter's avatar
releaser-duniter committed
46 47 48 49 50
  tags:
    - redshift
  before_script:
    - export NVM_DIR="$HOME/.nvm"
    - . "$NVM_DIR/nvm.sh"
51

Cédric Moreau's avatar
Cédric Moreau committed
52
.cached_nvm: &cached_nvm
53
  <<: *nvm_env
54 55 56 57
  cache:
    untracked: true
    paths:
      - node_modules/
Stéphane Veyret's avatar
Stéphane Veyret committed
58 59
  
build:
60
  <<: *changes
Cédric Moreau's avatar
Cédric Moreau committed
61
  <<: *nvm_env
Stéphane Veyret's avatar
Stéphane Veyret committed
62
  stage: build
releaser-duniter's avatar
releaser-duniter committed
63 64 65
  script:
    - yarn

66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
#pages:
#  <<: *nvm_env
#  stage: pages
#  cache: {}
#  script:
#    - yarn
#    - yarn doc
#    - mkdir -p public
#    - cp .gitlab/pages/pages-index.html public/index.html
#    - sed -i "s/{BRANCH}/$CI_COMMIT_REF_NAME/g" public/index.html
#    - mv typedoc public/
#    - echo "$CI_JOB_ID"
#    - curl "https://git.duniter.org/nodes/typescript/duniter/-/jobs/$CI_JOB_ID/artifacts/raw/coverage.tar.gz"
#    - tar xzf coverage.tar.gz
#    - mv coverage "public/coverage"
#    - ls public
#  artifacts:
#    untracked: true
#    paths:
#      - public
#  only:
#    - loki
#    - dev
Cédric Moreau's avatar
Cédric Moreau committed
89

Éloïs's avatar
Éloïs committed
90
test:
91
  <<: *changes
92
  <<: *nvm_env
Éloïs's avatar
Éloïs committed
93 94
  stage: test
  script:
95
    - yarn
Cédric Moreau's avatar
Cédric Moreau committed
96
    - yarn test
97
    # Push coverage to GitLab pages
Cédric Moreau's avatar
Cédric Moreau committed
98
    - tar cvzf coverage.tar.gz coverage/
99
    # Code coverage display in GitLab
Cédric Moreau's avatar
Cédric Moreau committed
100
    - sed -n 23p coverage/index.html | grep -Po "\d+.\d+" | sed -e "s/\(.*\)/<coverage>\1%<\/coverage>/"
101
  coverage: '/<coverage>(\d+.\d+\%)<\/coverage>/'
102 103
  except:
    - tags
104
  artifacts:
105
    paths:
106
      - coverage.tar.gz
107 108
    expire_in: 4h

109
sync_g1:
110
  <<: *changes
Éloïs's avatar
Éloïs committed
111
  <<: *nvm_env
112
  stage: integration
Éloïs's avatar
Éloïs committed
113 114
  script:
    - yarn
115
    - bash .gitlab/test/check_g1_sync.sh
116 117
  except:
    - tags
118 119

sync_gtest:
120
  <<: *changes
121
  <<: *nvm_env
122
  stage: integration
123
  script:
124
    - yarn
125
    - bash .gitlab/test/check_gt_sync.sh
126 127
  except:
    - tags
Éloïs's avatar
Éloïs committed
128

Stéphane Veyret's avatar
Stéphane Veyret committed
129
.build_releases: &build_releases
Stéphane Veyret's avatar
Stéphane Veyret committed
130
  stage: package
Stéphane Veyret's avatar
Stéphane Veyret committed
131
  allow_failure: false
132
  image: duniter/release-builder:v1.2.0
133 134
  cache: {}
  when: manual
Stéphane Veyret's avatar
Stéphane Veyret committed
135
  tags:
Éloïs's avatar
Éloïs committed
136
    - redshift-duniter-builder
Stéphane Veyret's avatar
Stéphane Veyret committed
137 138 139 140 141 142
  artifacts:
    paths: &releases_artifacts
      - work/bin/

releases:test:
  <<: *build_releases
Stéphane Veyret's avatar
Stéphane Veyret committed
143
  script:
144
    - rm -rf node_modules/
releaser-duniter's avatar
releaser-duniter committed
145
    - bash "release/arch/linux/build-lin.sh" "$(date +%Y%m%d).$(date +%H%M).$(date +%S)"
Stéphane Veyret's avatar
Stéphane Veyret committed
146
  artifacts:
Stéphane Veyret's avatar
Stéphane Veyret committed
147
    paths: *releases_artifacts
148
    expire_in: 72h
149 150
  except:
    - tags
Stéphane Veyret's avatar
Stéphane Veyret committed
151

Stéphane Veyret's avatar
Stéphane Veyret committed
152
releases:x64:
Stéphane Veyret's avatar
Stéphane Veyret committed
153
  <<: *build_releases
Stéphane Veyret's avatar
Stéphane Veyret committed
154
  script:
155
    - rm -rf node_modules/
Stéphane Veyret's avatar
Stéphane Veyret committed
156 157
    - bash "release/arch/linux/build-lin.sh" "${CI_COMMIT_TAG#v}"
  artifacts:
Stéphane Veyret's avatar
Stéphane Veyret committed
158
    paths: *releases_artifacts
159
    expire_in: 6 mos
Stéphane Veyret's avatar
Stéphane Veyret committed
160
  only:
Stéphane Veyret's avatar
Stéphane Veyret committed
161 162
    - tags

Stéphane Veyret's avatar
Stéphane Veyret committed
163
.release_jobs: &release_jobs
164
  image: rdadev/jinja2:py3.6
Éloïs's avatar
Éloïs committed
165 166
  tags:
    - redshift-duniter-builder
Cédric Moreau's avatar
Cédric Moreau committed
167
  script:
168
    - python3 .gitlab/releaser
169
  only:
Stéphane Veyret's avatar
Stéphane Veyret committed
170
    - tags
Stéphane Veyret's avatar
Stéphane Veyret committed
171 172 173 174 175 176 177 178 179 180 181 182

prerelease:
  <<: *release_jobs
  stage: prerelease
  variables:
    RELEASE_BIN_DIR: work/bin/
    SOURCE_EXT: '["tar.gz", "zip"]'

publish:
  <<: *release_jobs
  stage: release
  variables:
183
    RELEASE_BIN_DIR: work/bin/
Stéphane Veyret's avatar
Stéphane Veyret committed
184 185 186
    WIKI_RELEASE: Releases
  allow_failure: false
  when: manual