-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
103 lines (93 loc) · 3.56 KB
/
.gitlab-ci.yml
File metadata and controls
103 lines (93 loc) · 3.56 KB
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
stages:
- tests
- build
- deploy
.test:
image: rnds/ruby:3.0-test
stage: tests
variables:
COMPOSE_PROJECT_NAME: main_loop_${CI_PIPELINE_ID}_${CI_JOB_ID}
GIT_BRANCH: ${CI_COMMIT_REF_NAME}
GIT_COMMIT: ${CI_COMMIT_SHA}
script:
- docker-compose build --force-rm --pull test
- docker-compose up --force-recreate -t 1 --remove-orphans -d test
- docker-compose exec -T test bundle exec rspec | tee .coverage
- docker-compose exec -T test cat rspec.xml > rspec-${RUBY_VERSION}.xml
- docker-compose exec -T test cat coverage/coverage.xml > coverage-${RUBY_VERSION}.xml
after_script:
- docker-compose down -v --remove-orphans
coverage: '/\(\d+.\d+\%\) covered/'
artifacts:
reports:
junit: rspec*.xml
coverage_report:
coverage_format: cobertura
path: coverage*.xml
name: "coverage"
paths:
- .coverage
- coverage
ruby-3.2:
extends: .test
variables:
RUBY_VERSION: '3.2'
ruby-3.4:
extends: .test
variables:
RUBY_VERSION: '3.4'
ruby-4.0:
extends: .test
variables:
RUBY_VERSION: '4.0'
build:
image: rnds/ruby:3.0-test
stage: build
variables:
BUILDVERSION: ${CI_PIPELINE_ID}
script:
- bundle install --jobs=3 --path vendor/bundle && bundle package --all
- gem build `ls | grep gemspec` && gem install `ls | grep -e '.gem$'`
cache:
paths:
- vendor/bundle
- vendor/cache
artifacts:
name: "gem"
paths:
- ./*.gem
- coverage/*
- rubycritic/*
pushgem:
image: rnds/ruby:3.0-test
stage: deploy
script:
- mkdir -p ~/.gem
- 'echo ":rubygems_api_key: ${RUBYGEMS_KEY}" > ~/.gem/credentials'
- chmod 600 ~/.gem/credentials
- export GEMFILE=`ls *.gem | tail -n 1`
- gem push $GEMFILE
only:
- master
badges:
image: rnds/ruby:3.0-test
stage: deploy
allow_failure: true
variables:
BRANCH_LOCK: ci/${CI_PROJECT_NAME}/${CI_COMMIT_REF_SLUG}
ENV_LOCK: ci/${CI_PROJECT_NAME}/${CI_ENVIRONMENT_SLUG}
BADGES: https://lysander.rnds.pro/api/v1/badges/main_loop
script:
- bundle audit update
- bundle audit || true
- bundle outdated --only-explicit --no-pre --group default || true
- vulnerable=$(bundle audit | grep "Name:" | sort | uniq | wc -l) || true
- outdated=$(bundle outdated --only-explicit --no-pre --group default | grep "*" | wc -l) || true
- quality=$(rubycritic -f lint lib | tail -n 1 | cut -d ' ' -f2) || true
- coverage=$(cat .coverage | ruby -e 'puts /\((\d+.\d+)\%\) covered/.match(STDIN.read)[1]') || true
- curl -X PUT -m 3.0 --oauth2-bearer ${BADGE_TOKEN} -H "Content-Type:application/json" -d "{\"badge\":{\"label\":\"vulnerable\", \"color\":\"red\", \"message\":\"${vulnerable} gems\", \"redirect_url\":\"${CI_PROJECT_URL}\"}}" "${BADGES}_vulnerable.json" || true
- curl -X PUT -m 3.0 --oauth2-bearer ${BADGE_TOKEN} -H "Content-Type:application/json" -d "{\"badge\":{\"label\":\"outdated\", \"color\":\"orange\", \"message\":\"${outdated} gems\", \"redirect_url\":\"${CI_PROJECT_URL}\"}}" "${BADGES}_outdated.json" || true
- curl -X PUT -m 3.0 --oauth2-bearer ${BADGE_TOKEN} -H "Content-Type:application/json" -d "{\"badge\":{\"label\":\"quality\", \"color\":\"lightgray\", \"message\":\"${quality}%\", \"redirect_url\":\"${CI_PROJECT_URL}\"}}" "${BADGES}_quality.json" || true
- curl -X PUT -m 3.0 --oauth2-bearer ${BADGE_TOKEN} -H "Content-Type:application/json" -d "{\"badge\":{\"label\":\"coverage\", \"color\":\"brightgreen\", \"message\":\"${coverage}%\", \"redirect_url\":\"${CI_PROJECT_URL}\"}}" "${BADGES}_coverage.json" || true
only:
- master