Skip to content

Commit 8849935

Browse files
committed
Install Go in .gitlab-ci.yml
1 parent 8e615ab commit 8849935

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

bundler/lib/bundler/templates/newgem/gitlab-ci.yml.tt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ default:
55
<%- if config[:ext] == 'rust' -%>
66
- apt-get update && apt-get install -y clang
77
- gem update --system '<%= ::Gem.rubygems_version %>'
8+
<%- end -%>
9+
<%- if config[:ext] == 'go' -%>
10+
- wget https://go.dev/dl/go$GO_VERSION.linux-amd64.tar.gz -O /tmp/go.tar.gz
11+
- tar -C /usr/local -xzf /tmp/go.tar.gz
12+
- export PATH=/usr/local/go/bin:$PATH
813
<%- end -%>
914
- gem install bundler -v <%= Bundler::VERSION %>
1015
- bundle install
@@ -13,6 +18,10 @@ example_job:
1318
<%- if config[:ext] == 'rust' -%>
1419
variables:
1520
RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN: 'true'
21+
<%- end -%>
22+
<%- if config[:ext] == 'go' -%>
23+
variables:
24+
GO_VERSION: '1.23.0'
1625
<%- end -%>
1726
script:
1827
- bundle exec rake

bundler/spec/commands/newgem_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,6 +1711,25 @@ def create_temporary_dir(dir)
17111711
end
17121712
end
17131713

1714+
context "--ci set to gitlab" do
1715+
let(:flags) { "--ext=go --ci=gitlab" }
1716+
1717+
it "generates a .gitlab-ci.yml" do
1718+
expect(bundled_app("#{gem_name}/.gitlab-ci.yml")).to exist
1719+
1720+
expect(bundled_app("#{gem_name}/.gitlab-ci.yml").read).to include(<<-YAML)
1721+
- wget https://go.dev/dl/go$GO_VERSION.linux-amd64.tar.gz -O /tmp/go.tar.gz
1722+
- tar -C /usr/local -xzf /tmp/go.tar.gz
1723+
- export PATH=/usr/local/go/bin:$PATH
1724+
YAML
1725+
1726+
expect(bundled_app("#{gem_name}/.gitlab-ci.yml").read).to include(<<-YAML.strip)
1727+
variables:
1728+
GO_VERSION:
1729+
YAML
1730+
end
1731+
end
1732+
17141733
context "when Go is installed" do
17151734
before do
17161735
skip "Go isn't installed" unless system("go version")

0 commit comments

Comments
 (0)