.gitlab-ci.yml 3.51 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"
Stéphane Veyret's avatar
Stéphane Veyret committed
36
37
38
39
  
build:
  <<: *nvm_env
  stage: build
40
41
42
43
  cache:
    untracked: true
    paths:
      - node_modules/
releaser-duniter's avatar
releaser-duniter committed
44
45
46
  script:
    - yarn

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

Éloïs's avatar
Éloïs committed
71
72
73
test:
  <<: *nvm_env
  stage: test
74
75
76
77
  cache:
    untracked: true
    paths:
      - node_modules/
Éloïs's avatar
Éloïs committed
78
  script:
Cédric Moreau's avatar
Cédric Moreau committed
79
80
81
82
83
84
85
    - yarn test
    # Clean the dump directory before testing
    - rm -rf /tmp/duniter_ci_dump/
    - mkdir -p /tmp/duniter_ci_dump/
    # Code coverage display in GitLab
    - tar cvzf coverage.tar.gz coverage/
    - sed -n 23p coverage/index.html | grep -Po "\d+.\d+" | sed -e "s/\(.*\)/<coverage>\1%<\/coverage>/"
86
  coverage: '/<coverage>(\d+.\d+\%)<\/coverage>/'
87
  artifacts:
88
    paths:
89
      - coverage.tar.gz
90
91
    expire_in: 4h

92
93
94
95
96
97
98
99
100
101
102
103
104
105
test_sync:
  <<: *nvm_env
  stage: test
  cache:
    untracked: true
    paths:
      - node_modules/
  script:
    # Clean the dump directory before testing
    - rm -rf /tmp/duniter_ci_dump/
    - mkdir -p /tmp/duniter_ci_dump/
    - bash .gitlab/test/check_g1_sync.sh
    - bash .gitlab/test/check_gt_sync.sh

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

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

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

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

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

publish:
  <<: *release_jobs
  stage: release
  variables:
160
    RELEASE_BIN_DIR: work/bin/
Stéphane Veyret's avatar
Stéphane Veyret committed
161
162
163
    WIKI_RELEASE: Releases
  allow_failure: false
  when: manual