1 CI_VERSION = '0.7'.freeze
2 CI_BASE = 'ubuntu:16.10'.freeze
3 CI_COMPILERS = ['gcc-4.7',
14 def ci_image_tag(compiler)
15 compiler.tr('+', 'c').delete('-').delete('.')
18 def ci_docker_tag(compiler)
19 tag = ci_image_tag(compiler)
20 "registry.gitlab.com/dabroz/mruby:#{tag}_#{CI_VERSION}"
25 raise 'error' unless system cmd
28 desc 'recreate docker images for GitLab builds'
29 task :gitlab_dockers do
30 CI_COMPILERS.each do |compiler|
31 tag = ci_image_tag(compiler)
32 filename = "Dockerfile.#{tag}"
33 File.open(filename, 'wb') do |f|
34 f << "# #{compiler} - #{tag}\n"
35 f << "FROM #{CI_BASE}\n"
36 f << "RUN apt-get update && apt-get install -y git ruby2.3 ruby2.3-dev bison\n"
37 f << "RUN apt-get update && apt-get install -y binutils manpages\n"
38 f << "RUN apt-get update && apt-get install -y #{compiler}\n"
40 f << "RUN apt-get update && apt-get install -y libx32#{compiler}-dev\n"
41 f << "RUN apt-get update && apt-get install --no-install-recommends -y #{compiler}-multilib\n"
43 f << "RUN dpkg --add-architecture i386\n"
44 f << "RUN apt-get update && apt-get install -y linux-libc-dev:i386\n"
46 f << "RUN apt-get update && apt-get install --no-install-recommends -y libc6-dev-i386\n"
47 f << "RUN apt-get update && apt-get install -y gcc gcc-multilib\n"
50 docker_tag = ci_docker_tag(compiler)
51 cmd1 = "docker build -t #{docker_tag} -f #{filename} ."
52 cmd2 = "docker push #{docker_tag}"
59 desc 'create build configurations and update .gitlab-ci.yml'
60 task :gitlab_config do
64 [true, false].each do |mode_32|
65 ['', 'MRB_USE_FLOAT'].each do |float_conf|
66 ['', 'MRB_NAN_BOXING', 'MRB_WORD_BOXING'].each do |boxing_conf|
67 ['', 'MRB_UTF8_STRING'].each do |utf8_conf|
68 next if (float_conf == 'MRB_USE_FLOAT') && (boxing_conf == 'MRB_NAN_BOXING')
69 next if (int_conf == 'MRB_INT64') && (boxing_conf == 'MRB_NAN_BOXING')
70 next if (int_conf == 'MRB_INT64') && (boxing_conf == 'MRB_WORD_BOXING') && mode_32
71 env = [float_conf, int_conf, boxing_conf, utf8_conf].map do |conf|
72 conf == '' ? nil : "-D#{conf}=1"
74 bit = mode_32 ? '-m32 ' : ''
76 _info += mode_32 ? '32bit ' : '64bit '
77 _info += float_conf['USE'] ? 'float ' : ''
78 _info += int_conf['16'] ? 'int16 ' : ''
79 _info += int_conf['64'] ? 'int64 ' : ''
80 _info += boxing_conf['NAN'] ? 'nan ' : ''
81 _info += boxing_conf['WORD'] ? 'word ' : ''
82 _info += utf8_conf['UTF8'] ? 'utf8 ' : ''
83 _info = _info.gsub(/ +/, ' ').strip.tr(' ', '_')
84 configs << { '_info' => _info, 'CFLAGS' => "#{bit}#{env}", 'LDFLAGS' => bit.strip.to_s }
89 path = './.gitlab-ci.yml'
90 data = YAML.load_file(path)
91 data.keys.select do |key|
92 key.start_with? 'Test'
96 CI_COMPILERS.each do |compiler|
97 configs.each do |config|
98 name = "Test #{compiler} #{config['_info']}"
101 'CXX' => compiler.gsub('gcc', 'g++').gsub('clang', 'clang++'),
104 hash = hash.merge(config)
108 'image' => ci_docker_tag(compiler),
110 'script' => 'env; rake --verbose all test'
114 File.open(path, 'w') { |f| YAML.dump(data, f) }