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_INT16', 'MRB_INT64'].each do |int_conf|
67 ['', 'MRB_NAN_BOXING', 'MRB_WORD_BOXING'].each do |boxing_conf|
68 ['', 'MRB_UTF8_STRING'].each do |utf8_conf|
69 next if (float_conf == 'MRB_USE_FLOAT') && (boxing_conf == 'MRB_NAN_BOXING')
70 next if (int_conf == 'MRB_INT64') && (boxing_conf == 'MRB_NAN_BOXING')
71 next if (int_conf == 'MRB_INT16') && (boxing_conf == 'MRB_WORD_BOXING')
72 next if (int_conf == 'MRB_INT64') && (boxing_conf == 'MRB_WORD_BOXING') && mode_32
73 env = [float_conf, int_conf, boxing_conf, utf8_conf].map do |conf|
74 conf == '' ? nil : "-D#{conf}=1"
76 bit = mode_32 ? '-m32 ' : ''
78 _info += mode_32 ? '32bit ' : '64bit '
79 _info += float_conf['USE'] ? 'float ' : ''
80 _info += int_conf['16'] ? 'int16 ' : ''
81 _info += int_conf['64'] ? 'int64 ' : ''
82 _info += boxing_conf['NAN'] ? 'nan ' : ''
83 _info += boxing_conf['word'] ? 'word ' : ''
84 _info += utf8_conf['UTF8'] ? 'utf8 ' : ''
85 _info = _info.gsub(/ +/, ' ').strip.tr(' ', '_')
86 configs << { '_info' => _info, 'CFLAGS' => "#{bit}#{env}", 'LDFLAGS' => bit.strip.to_s }
92 path = './.gitlab-ci.yml'
93 data = YAML.load_file(path)
94 data.keys.select do |key|
95 key.start_with? 'Test'
99 CI_COMPILERS.each do |compiler|
100 configs.each do |config|
101 name = "Test #{compiler} #{config['_info']}"
104 'CXX' => compiler.gsub('gcc', 'g++').gsub('clang', 'clang++'),
107 hash = hash.merge(config)
111 'image' => ci_docker_tag(compiler),
113 'script' => 'env; ./minirake --verbose all test'
117 File.open(path, 'w') { |f| YAML.dump(data, f) }