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

Éloïs's avatar
Éloïs committed
10
push_to_github:
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  stage: github-sync
  variables:
    GIT_STRATEGY: none
  tags:
    - redshift
  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:
    - nodes/typescript/duniter
Stéphane Veyret's avatar
Stéphane Veyret committed
29
30

.nvm_env: &nvm_env
releaser-duniter's avatar
releaser-duniter committed
31
32
33
34
35
  tags:
    - redshift
  before_script:
    - export NVM_DIR="$HOME/.nvm"
    - . "$NVM_DIR/nvm.sh"
36

Cédric Moreau's avatar
Cédric Moreau committed
37
.cached_nvm: &cached_nvm
38
  <<: *nvm_env
39
40
41
42
  cache:
    untracked: true
    paths:
      - node_modules/
43
44
  
build:
Cédric Moreau's avatar
Cédric Moreau committed
45
  <<: *cached_nvm
46
  stage: build
releaser-duniter's avatar
releaser-duniter committed
47
48
49
  script:
    - yarn

50
51
52
pages:
  <<: *nvm_env
  stage: pages
Cédric Moreau's avatar
Cédric Moreau committed
53
  cache: {}
54
55
56
57
  script:
    - yarn
    - yarn doc
    - mkdir -p public
58
59
    - cp .gitlab/pages/pages-index.html public/index.html
    - sed -i "s/{BRANCH}/$CI_COMMIT_REF_NAME/g" public/index.html
60
    - mv typedoc public/
Cédric Moreau's avatar
Cédric Moreau committed
61
62
63
    - 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
64
    - mv coverage "public/coverage"
65
66
67
68
69
70
71
    - ls public
  artifacts:
    untracked: true
    paths:
      - public
  only:
    - loki
72
    - dev
Cédric Moreau's avatar
Cédric Moreau committed
73

Éloïs's avatar
Éloïs committed
74
test:
75
  <<: *cached_nvm
Éloïs's avatar
Éloïs committed
76
77
  stage: test
  script:
Cédric Moreau's avatar
Cédric Moreau committed
78
    - yarn test
79
    # Push coverage to GitLab pages
Cédric Moreau's avatar
Cédric Moreau committed
80
    - tar cvzf coverage.tar.gz coverage/
81
    # Code coverage display in GitLab
Cédric Moreau's avatar
Cédric Moreau committed
82
    - sed -n 23p coverage/index.html | grep -Po "\d+.\d+" | sed -e "s/\(.*\)/<coverage>\1%<\/coverage>/"
83
  coverage: '/<coverage>(\d+.\d+\%)<\/coverage>/'
84
  artifacts:
85
    paths:
86
      - coverage.tar.gz
87
88
    expire_in: 4h

89
sync_g1:
90
  <<: *cached_nvm
91
92
93
  stage: test
  script:
    - bash .gitlab/test/check_g1_sync.sh
94
95

sync_gtest:
96
  <<: *cached_nvm
97
98
  stage: test
  script:
99
100
    - bash .gitlab/test/check_gt_sync.sh

Stéphane Veyret's avatar
Stéphane Veyret committed
101
.build_releases: &build_releases
Stéphane Veyret's avatar
Stéphane Veyret committed
102
  stage: package
Stéphane Veyret's avatar
Stéphane Veyret committed
103
  allow_failure: false
104
  image: duniter/release-builder:v1.2.0
105
106
  cache: {}
  when: manual
Stéphane Veyret's avatar
Stéphane Veyret committed
107
  tags:
Éloïs's avatar
Éloïs committed
108
    - redshift-duniter-builder
Stéphane Veyret's avatar
Stéphane Veyret committed
109
110
111
112
113
114
  artifacts:
    paths: &releases_artifacts
      - work/bin/

releases:test:
  <<: *build_releases
Stéphane Veyret's avatar
Stéphane Veyret committed
115
  script:
116
    - rm -rf node_modules/
releaser-duniter's avatar
releaser-duniter committed
117
    - 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
118
  artifacts:
Stéphane Veyret's avatar
Stéphane Veyret committed
119
120
    paths: *releases_artifacts
    expire_in: 4h
121
122
  except:
    - tags
Stéphane Veyret's avatar
Stéphane Veyret committed
123

Stéphane Veyret's avatar
Stéphane Veyret committed
124
releases:x64:
Stéphane Veyret's avatar
Stéphane Veyret committed
125
  <<: *build_releases
Stéphane Veyret's avatar
Stéphane Veyret committed
126
  script:
127
    - rm -rf node_modules/
Stéphane Veyret's avatar
Stéphane Veyret committed
128
129
    - bash "release/arch/linux/build-lin.sh" "${CI_COMMIT_TAG#v}"
  artifacts:
Stéphane Veyret's avatar
Stéphane Veyret committed
130
131
    paths: *releases_artifacts
    expire_in: 2 weeks
Stéphane Veyret's avatar
Stéphane Veyret committed
132
  only:
Stéphane Veyret's avatar
Stéphane Veyret committed
133
134
    - tags

Stéphane Veyret's avatar
Stéphane Veyret committed
135
.release_jobs: &release_jobs
Éloïs's avatar
Éloïs committed
136
  image: tensorflow/tensorflow:latest-py3
Éloïs's avatar
Éloïs committed
137
138
  tags:
    - redshift-duniter-builder
Cédric Moreau's avatar
Cédric Moreau committed
139
  script:
140
    - python3 .gitlab/releaser
141
  only:
Stéphane Veyret's avatar
Stéphane Veyret committed
142
    - tags
Stéphane Veyret's avatar
Stéphane Veyret committed
143
144
145
146
147
148
149
150
151
152
153
154

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

publish:
  <<: *release_jobs
  stage: release
  variables:
155
    RELEASE_BIN_DIR: work/bin/
Stéphane Veyret's avatar
Stéphane Veyret committed
156
157
158
    WIKI_RELEASE: Releases
  allow_failure: false
  when: manual