forked from jdalrymple/gitbeaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
167 lines (151 loc) · 4.35 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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
124
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
default:
image: node:lts-alpine
# Cache modules in between jobs
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- packages/gitbeaker-core/node_modules/
- packages/gitbeaker-cli/node_modules/
- packages/gitbeaker-browser/node_modules/
- packages/gitbeaker-node/node_modules/
- packages/gitbeaker-requester-utils/node_modules/
- node_modules/
stages:
- install
- build
- lint
- test
- canary
- release
#Link and Install all required dependancies
install:
image: node:lts
stage: install
variables:
PLAYWRIGHT_BROWSERS_PATH: 0
script:
- yarn
# Build core (cjs, es, and browser) and cli packages
# Uses work around to allow for linking of the cli packages
build:
stage: build
script:
- yarn build
artifacts:
paths:
- packages/core/dist/
- packages/cli/dist/
- packages/browser/dist/
- packages/node/dist/
- packages/requester-utils/dist/
# Lint all code, tests and supporting documentation (README, CHANGELOG etc)
lint:src:
needs: ['install']
stage: lint
script: yarn lint
lint:docs:
needs: ['install']
stage: lint
script: yarn lint:docs
# Unit Tests
test:unit:cli:
needs: ['install']
stage: test
script: yarn workspace @gitbeaker/cli test:unit && yarn codecov -F cli
test:unit:core:
needs: ['install']
stage: test
script: yarn workspace @gitbeaker/core test:unit && yarn codecov -F core
test:unit:node:
needs: ['install']
stage: test
script: yarn workspace @gitbeaker/node test:unit && yarn codecov -F node
test:unit:browser:
needs: ['install']
stage: test
image: mcr.microsoft.com/playwright:bionic
variables:
PLAYWRIGHT_BROWSERS_PATH: 0
script: yarn workspace @gitbeaker/browser test:unit && yarn codecov -F browser
test:unit:utils:
needs: ['install']
stage: test
script: yarn workspace @gitbeaker/requester-utils test:unit && yarn codecov -F utils
#Integration Tests
# .test:integration: &integration-test
# stage: test
# needs: ['build']
# image:
# name: jdalrymple/docker-compose-with-node
# entrypoint: ['/bin/sh', '-c']
# variables:
# GITLAB_PERSONAL_ACCESS_TOKEN: superduperstrongtoken
# DOCKER_HOST: tcp://docker:2375
# GITLAB_URL: http://docker:8080
# services:
# - docker:dind
# retry: 2
# timeout: 45 minutes
# before_script:
# - apk add jq curl
#
# # Spin up container
# - docker-compose -f scripts/docker-compose.yml up -d
#
# # Verify Gitlab instance is up and running
# - echo "Waiting for service to start"
# - sleep 180
# - while [[ "$(curl --fail --silent -X GET "$GITLAB_URL/-/readiness?all=1" --insecure | jq -r '.master_check[0].status')" != "ok" ]]; do echo "Polling service - not alive yet"; sleep 10; done;
# - echo "Service is up and running!"
# after_script:
# - sleep 30
# - docker cp gitlab:/var/log/gitlab runner_logs
# - echo $(docker exec -i gitlab sh -c "grep -v -e '^#' -e '^$' /etc/gitlab/gitlab.rb") > runner_logs/gitlab.rb
# artifacts:
# when: on_failure
# paths:
# - runner_logs
# test:integration:browser:
# <<: *integration-test
# image: mcr.microsoft.com/playwright:bionic
# variables:
# PLAYWRIGHT_BROWSERS_PATH: 0
# script:
# - yarn workspace @gitbeaker/browser test:integration
# test:integration:
# <<: *integration-test
# script:
# - yarn workspace @gitbeaker/cli test:integration
# - yarn workspace @gitbeaker/node test:integration
# Canary
canary:
stage: canary
only:
- external_pull_requests
before_script:
- apk add --no-cache git
- git remote set-url origin https://jdalrymple:${GITHUB_TOKEN}@github.com/jdalrymple/gitbeaker.git
- git checkout $CI_COMMIT_REF_NAME
- npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
- npm config set always-auth=true
script: |
if yarn auto label --pr $CI_EXTERNAL_PULL_REQUEST_IID | grep 'canary'; then
echo "canary label found, starting canary deployment!"
yarn auto canary
else
echo "Skipping, canary label isn't present."
fi
# Release
release:
needs: ['build']
only:
refs:
- master
stage: release
before_script:
- apk add --no-cache git
- git remote set-url origin https://jdalrymple:${GITHUB_TOKEN}@github.com/jdalrymple/gitbeaker.git
- git checkout master
- npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
- npm config set always-auth=true
script: yarn release