Skip to content

Commit d6af659

Browse files
Merge pull request #116 from FRRouting/master
Release 2.4.3
2 parents b6b4ec8 + c332df7 commit d6af659

File tree

14 files changed

+266
-27
lines changed

14 files changed

+266
-27
lines changed

lib/bamboo_ci/stop_plan.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def self.build(bamboo_ci_ref)
2626
end
2727

2828
def self.comment(check_suite, new_check_suite)
29-
new_url = "https://ci1.netdef.org/browse/#{new_check_suite.bamboo_ci_ref}"
29+
new_url = "https://#{GitHubApp::Configuration.instance.ci_url}/browse/#{new_check_suite.bamboo_ci_ref}"
3030
comment = "This execution was cancelled due to a new commit or `ci:rerun` (#{new_url})"
3131

3232
add_comment_to_ci(check_suite.bamboo_ci_ref, comment)

lib/github/build/action.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def create_jobs(rerun)
7777
if rerun
7878
next unless ci_job.stage.configuration.can_retry?
7979

80-
url = "https://ci1.netdef.org/browse/#{ci_job.job_ref}"
80+
url = "https://#{GitHubApp::Configuration.instance.ci_url}/browse/#{ci_job.job_ref}"
8181
ci_job.enqueue(@github, { title: ci_job.name, summary: "Details at [#{url}](#{url})" })
8282
else
8383
ci_job.create_check_run
@@ -156,7 +156,7 @@ def create_stage(stage_config)
156156
status: 'queued',
157157
name: name)
158158

159-
url = "https://ci1.netdef.org/browse/#{stage.check_suite.bamboo_ci_ref}"
159+
url = "https://#{GitHubApp::Configuration.instance.ci_url}/browse/#{stage.check_suite.bamboo_ci_ref}"
160160
output = { title: "#{stage.name} summary", summary: "Uninitialized stage\nDetails at [#{url}](#{url})" }
161161

162162
stage.enqueue(@github, output: output)
@@ -172,7 +172,7 @@ def create_stage(stage_config)
172172
# @return [Hash] The initial output.
173173
def initial_output(ci_job)
174174
output = { title: '', summary: '' }
175-
url = "https://ci1.netdef.org/browse/#{ci_job.check_suite.bamboo_ci_ref}"
175+
url = "https://#{GitHubApp::Configuration.instance.ci_url}/browse/#{ci_job.check_suite.bamboo_ci_ref}"
176176

177177
output[:title] = "#{ci_job.name} summary"
178178
output[:summary] = "Details at [#{url}](#{url})"

lib/github/build/retry.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def enqueued_stages
3636
next if stage.nil?
3737
next if stage.success?
3838

39-
url = "https://ci1.netdef.org/browse/#{stage.check_suite.bamboo_ci_ref}"
39+
url = "https://#{GitHubApp::Configuration.instance.ci_url}/browse/#{stage.check_suite.bamboo_ci_ref}"
4040
output = { title: "#{stage.name} summary", summary: "Uninitialized stage\nDetails at [#{url}](#{url})" }
4141

4242
stage.enqueue(@github, output: output)

lib/github/build/summary.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def must_continue_next_stage(current_stage)
101101
end
102102

103103
def cancelling_next_stage(pending_stage)
104-
url = "https://ci1.netdef.org/browse/#{pending_stage.check_suite.bamboo_ci_ref}"
104+
url = "https://#{GitHubApp::Configuration.instance.ci_url}/browse/#{pending_stage.check_suite.bamboo_ci_ref}"
105105
output = {
106106
title:
107107
"#{pending_stage.name} summary",
@@ -122,7 +122,7 @@ def finished_summary(stage)
122122
end
123123

124124
def finished_stage_summary(stage)
125-
url = "https://ci1.netdef.org/browse/#{stage.check_suite.bamboo_ci_ref}"
125+
url = "https://#{GitHubApp::Configuration.instance.ci_url}/browse/#{stage.check_suite.bamboo_ci_ref}"
126126
output = {
127127
title: "#{stage.name} summary",
128128
summary: "#{summary_basic_output(stage)}\nDetails at [#{url}](#{url}).".force_encoding('utf-8')
@@ -146,7 +146,7 @@ def finished_stage_update(stage, output)
146146
end
147147

148148
def update_summary(stage)
149-
url = "https://ci1.netdef.org/browse/#{@check_suite.bamboo_ci_ref}"
149+
url = "https://#{GitHubApp::Configuration.instance.ci_url}/browse/#{@check_suite.bamboo_ci_ref}"
150150
output = {
151151
title: "#{stage.name} summary",
152152
summary: "#{summary_basic_output(stage)}\nDetails at [#{url}](#{url}).".force_encoding('utf-8')
@@ -196,7 +196,7 @@ def in_progress_message(jobs)
196196
message = "\n\n:arrow_right: Jobs in progress: #{in_progress.size}/#{jobs.size}\n\n"
197197

198198
message + jobs.where(status: %i[in_progress]).map do |job|
199-
"- **#{job.name}** -> https://ci1.netdef.org/browse/#{job.job_ref}\n"
199+
"- **#{job.name}** -> https://#{GitHubApp::Configuration.instance.ci_url}/browse/#{job.job_ref}\n"
200200
end.join("\n")
201201
end
202202

@@ -206,13 +206,13 @@ def queued_message(jobs)
206206
message = ":arrow_right: Jobs queued: #{queued.size}/#{jobs.size}\n\n"
207207
message +
208208
queued.map do |job|
209-
"- **#{job.name}** -> https://ci1.netdef.org/browse/#{job.job_ref}\n"
209+
"- **#{job.name}** -> https://#{GitHubApp::Configuration.instance.ci_url}/browse/#{job.job_ref}\n"
210210
end.join("\n")
211211
end
212212

213213
def success_message(jobs)
214214
jobs.where(status: :success).map do |job|
215-
"- **#{job.name}** -> https://ci1.netdef.org/browse/#{job.job_ref}\n"
215+
"- **#{job.name}** -> https://#{GitHubApp::Configuration.instance.ci_url}/browse/#{job.job_ref}\n"
216216
end.join("\n")
217217
end
218218

@@ -227,7 +227,7 @@ def generate_message(name, job)
227227
failures = build_message(job) if name.downcase.match?('build')
228228
failures = checkout_message(job) if name.downcase.match?('source')
229229

230-
"- #{job.name} -> https://ci1.netdef.org/browse/#{job.job_ref}\n#{failures}"
230+
"- #{job.name} -> https://#{GitHubApp::Configuration.instance.ci_url}/browse/#{job.job_ref}\n#{failures}"
231231
end
232232

233233
def tests_message(job)
@@ -243,7 +243,7 @@ def checkout_message(job)
243243

244244
return '' if failures.nil?
245245

246-
"```\n#{failures}\n```\n"
246+
"```\n#{failures.gsub('<br>', "\n")}\n```\n"
247247
end
248248

249249
def build_message(job)

lib/github/plan_execution/finished.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@ class Finished
3434
#
3535
# @param [Hash] payload The payload containing information about the CheckSuite.
3636
def initialize(payload)
37-
@check_suite = CheckSuite.find_by(bamboo_ci_ref: payload['bamboo_ref']) if payload['bamboo_ref']
38-
@check_suite = CheckSuite.find(payload['check_suite_id']) if payload['check_suite_id']
37+
@check_suite = CheckSuite.where(
38+
bamboo_ci_ref: payload['bamboo_ref']
39+
).or(
40+
CheckSuite.where(id: payload['check_suite_id'])
41+
).last
42+
3943
@logger = GithubLogger.instance.create('github_plan_execution_finished.log', Logger::INFO)
4044
@hanged = payload['hanged'] || false
4145
end
@@ -180,7 +184,7 @@ def update_ci_job_status(github_check, ci_job, state)
180184
# @param [CiJob] ci_job The CI job to create the message for.
181185
# @return [Hash] The output message.
182186
def create_output_message(ci_job)
183-
url = "https://ci1.netdef.org/browse/#{ci_job.job_ref}"
187+
url = "https://#{GitHubApp::Configuration.instance.ci_url}/browse/#{ci_job.job_ref}"
184188

185189
{
186190
title: ci_job.name,

lib/helpers/configuration.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ def debug?
2727
config.key? 'debug' and config['debug']
2828
end
2929

30+
def ci_url
31+
return @config['ci']['url'] if @config.key?('ci') && @config['ci'].key?('url')
32+
33+
'https://ci1.netdef.org'
34+
end
35+
3036
private
3137

3238
def configuration

lib/models/stage.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,19 @@ def github_stage_full_name(name)
117117
end
118118

119119
def output_in_progress
120+
url = GitHubApp::Configuration.instance.ci_url
120121
in_progress = jobs.where(status: :in_progress)
121122

122123
header = ":arrow_right: Jobs in progress: #{in_progress.size}/#{jobs.size}\n\n"
123-
in_progress_jobs = jobs.where(status: :in_progress).map do |job|
124-
"- **#{job.name}** -> https://ci1.netdef.org/browse/#{job.job_ref}\n"
125-
end.join("\n")
124+
in_progress_jobs = mount_in_progress_jobs(jobs)
126125

127-
url = "https://ci1.netdef.org/browse/#{check_suite.bamboo_ci_ref}"
126+
url = "https://#{url}/browse/#{check_suite.bamboo_ci_ref}"
128127
{ title: "#{name} summary", summary: "#{header}#{in_progress_jobs}\nDetails at [#{url}](#{url})" }
129128
end
129+
130+
def mount_in_progress_jobs(jobs)
131+
jobs.where(status: :in_progress).map do |job|
132+
"- **#{job.name}** -> https://#{url}/browse/#{job.job_ref}\n"
133+
end.join("\n")
134+
end
130135
end

lib/slack_bot/slack_bot.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def send_stage_notification(stage, pull_request, subscription)
149149
url = "#{GitHubApp::Configuration.instance.config['slack_bot_url']}/github/user"
150150

151151
pr_url = "https://github.com/#{pull_request.repository}/pull/#{pull_request.github_pr_id}"
152-
bamboo_link = "https://ci1.netdef.org/browse/#{stage.check_suite.bamboo_ci_ref}"
152+
bamboo_link = "https://#{GitHubApp::Configuration.instance.ci_url}/browse/#{stage.check_suite.bamboo_ci_ref}"
153153

154154
post_request(URI(url),
155155
machine: 'slack_bot.netdef.org',
@@ -197,15 +197,15 @@ def pull_request_message(check_suite, status)
197197
pr = check_suite.pull_request
198198

199199
pr_url = "https://github.com/#{pr.repository}/pull/#{pr.github_pr_id}"
200-
bamboo_link = "https://ci1.netdef.org/browse/#{check_suite.bamboo_ci_ref}"
200+
bamboo_link = "https://#{GitHubApp::Configuration.instance.ci_url}/browse/#{check_suite.bamboo_ci_ref}"
201201

202202
"PR <#{pr_url}|##{pr.github_pr_id}>. <#{bamboo_link}|#{status}> "
203203
end
204204

205205
def generate_notification_message(job, status)
206206
pr = job.check_suite.pull_request
207207
pr_url = "https://github.com/#{pr.repository}/pull/#{pr.github_pr_id}/checks?check_run_id=#{job.check_ref}"
208-
bamboo_link = "https://ci1.netdef.org/browse/#{job.job_ref}"
208+
bamboo_link = "https://#{GitHubApp::Configuration.instance.ci_url}/browse/#{job.job_ref}"
209209

210210
"PR <#{pr_url}|##{pr.github_pr_id}>. <#{bamboo_link}|#{job.name} - #{status}> "
211211
end

rbenv-setup.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
---
2+
- name: Install RbEnv and Ruby build dependencies
3+
hosts: all
4+
become: yes
5+
6+
vars:
7+
rbenv_packages:
8+
- git
9+
- curl
10+
- build-essential
11+
- libssl-dev
12+
- zlib1g-dev
13+
- libpq-dev
14+
- rbenv
15+
- libffi-dev
16+
- libyaml-dev
17+
- autoconf
18+
- bison
19+
20+
tasks:
21+
- name: Update apt cache
22+
apt:
23+
update_cache: yes
24+
25+
- name: Install required packages for rbenv and Ruby
26+
apt:
27+
name: "{{ rbenv_packages }}"
28+
state: present
29+
install_recommends: yes
30+
31+
- name: Ensure rbenv is initialized in .bashrc
32+
lineinfile:
33+
path: ~/.bashrc
34+
line: 'eval "$(rbenv init -)"'
35+
state: present
36+
insertafter: EOF
37+
become: no
38+
39+
- name: Install rbenv using git
40+
git:
41+
repo: 'https://github.com/rbenv/rbenv.git'
42+
dest: ~/.rbenv
43+
update: no
44+
become: no
45+
46+
- name: Add rbenv to PATH
47+
lineinfile:
48+
path: ~/.bashrc
49+
line: 'export PATH="$HOME/.rbenv/bin:$PATH"'
50+
state: present
51+
insertafter: EOF
52+
become: no
53+
54+
- name: Install ruby-build as rbenv plugin
55+
git:
56+
repo: 'https://github.com/rbenv/ruby-build.git'
57+
dest: ~/.rbenv/plugins/ruby-build
58+
update: no
59+
become: no
60+
61+
- name: Ensure rbenv is initialized in .bashrc
62+
lineinfile:
63+
path: ~/.bashrc
64+
line: 'eval "$(rbenv init -)"'
65+
state: present
66+
insertafter: EOF
67+
become: no
68+
69+
- name: Reload shell to use rbenv
70+
shell: |
71+
export PATH="$HOME/.rbenv/bin:$PATH"
72+
eval "$(rbenv init -)"
73+
args:
74+
executable: /bin/bash
75+
become: no
76+
77+
- name: Install Ruby 3.1.2
78+
shell: |
79+
export PATH="$HOME/.rbenv/bin:$PATH"
80+
eval "$(rbenv init -)"
81+
rbenv install -s 3.1.2
82+
args:
83+
creates: ~/.rbenv/versions/3.1.2
84+
executable: /bin/bash
85+
become: no
86+
87+
- name: Set Ruby 3.1.2 as local version
88+
shell: |
89+
export PATH="$HOME/.rbenv/bin:$PATH"
90+
eval "$(rbenv init -)"
91+
rbenv local 3.1.2
92+
args:
93+
chdir: "{{ ansible_env.PWD }}"
94+
executable: /bin/bash
95+
become: no
96+
97+
- name: Install bundler gem
98+
shell: |
99+
export PATH="$HOME/.rbenv/bin:$PATH"
100+
eval "$(rbenv init -)"
101+
gem install bundler
102+
rbenv rehash
103+
args:
104+
executable: /bin/bash
105+
become: no
106+
107+
- name: Run bundle install
108+
shell: |
109+
export PATH="$HOME/.rbenv/bin:$PATH"
110+
eval "$(rbenv init -)"
111+
bundle install
112+
args:
113+
chdir: "{{ ansible_env.PWD }}"
114+
executable: /bin/bash
115+
become: no

reports/build_stage_failed.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
.where(jobs: { created_at: [begin_date..end_date], status: %i[failure skipped] })
2424
.where(check_suites: { author: author })
2525
.each do |stage|
26-
message = "Check Suite ID: https://ci1.netdef.org/browse/#{stage.check_suite.bamboo_ci_ref}"
26+
message = "Check Suite ID: https://#{GitHubApp::Configuration.instance.ci_url}/browse/#{stage.check_suite.bamboo_ci_ref}"
2727
check_suites << message unless check_suites.include? message
2828
end
2929

0 commit comments

Comments
 (0)