@@ -2,14 +2,15 @@ version: 2.1
22
33orbs :
445+ 56
67jobs :
78 test_linux :
89 parameters :
910 ruby_version :
1011 description : ' version tag for the cimg/ruby container'
1112 type : string
12-
13+
1314 machine :
1415 image : ubuntu-2004:current
1516
@@ -19,11 +20,13 @@ jobs:
1920
2021 - run :
2122 name : start docker-compose build environment
22- command : |
23+ command : |
2324 sudo ./test/bin/setup_volume_permissions.sh
2425 docker-compose up -d
2526 echo "Waiting for containers to start..."
2627 sleep 10
28+ environment :
29+ RUBY_VERSION : << parameters.ruby_version >>
2730
2831 - run :
2932 name : install sql prereqs
5861 - run :
5962 name : test gem
6063 command : |
61- docker exec cimg_ruby bash -c 'bundle exec rake test'
64+ docker exec cimg_ruby bash -c 'bundle exec rake test'
65+
66+ - store_test_results :
67+ path : test/reports
6268
6369 test_windows :
6470 parameters :
8490 - run :
8591 name : download and install ruby devkit
8692 command : |
93+ $ProgressPreference='SilentlyContinue'
94+
8795 $uri = 'https://api.github.com/repos/oneclick/rubyinstaller2/tags?per_page=200'
8896 $releases = ((Invoke-WebRequest $uri) | ConvertFrom-Json).name | select-string -Pattern '<< parameters.ruby_version >>'
8997 $target_release = (($releases | Sort-Object -Descending)[0] | Out-String).Trim()
93101
94102 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
95103 Invoke-WebRequest -UseBasicParsing -uri $download_uri -OutFile ruby-setup.exe
96- .\ruby-setup.exe /VERYSILENT /NORESTART /DIR=C:/Ruby<< parameters.ruby_version >>-x64
104+
105+ echo "Download finished, starting installation of $target_version"
106+ .\ruby-setup.exe /VERYSILENT /NORESTART /ALLUSERS /DIR=C:/Ruby<< parameters.ruby_version >>-x64
97107
98108 - run :
99109 name : ruby diagnostics
@@ -108,11 +118,10 @@ jobs:
108118 rm .\ruby-setup.exe
109119
110120 - run :
111- name : update build env
121+ name : install bundler
112122 command : |
113123 $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH"
114- ridk install 2
115- gem install bundler
124+ gem install bundler -v 2.3.26
116125
117126 - checkout
118127
@@ -127,57 +136,144 @@ jobs:
127136 name : bundle install gems
128137 command : |
129138 $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH"
130- bundle install
139+ bundle install --path vendor/bundle
131140
132141 - save_cache :
133142 name : save gem cache
134143 paths :
135144 - ./vendor/bundle
136145 key : v1-bundle-<< parameters.ruby_version >>-{{ .Branch }}-{{ checksum "tiny_tds.gemspec" }}
137146
147+ - attach_workspace :
148+ at : artifacts
149+
138150 - run :
139- name : build openssl
140- no_output_timeout : 30m
151+ name : install native gem and restore cross-compiled code from gem
141152 command : |
142153 $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH"
143- bundle exec rake ports:openssl
154+ $rubyArchitecture = (ruby -e 'puts RUBY_PLATFORM').Trim()
155+ $gemVersion = (Get-Content VERSION).Trim()
156+
157+ gem install --local --install-dir=./tmp "artifacts/gems/tiny_tds-$gemVersion-$rubyArchitecture.gem"
158+
159+ # Restore precompiled code
160+ $source = (Resolve-Path ".\tmp\gems\tiny_tds-$gemVersion-$rubyArchitecture\lib\tiny_tds").Path
161+ $destination = (Resolve-Path ".\lib\tiny_tds").Path
162+ Get-ChildItem $source -Recurse -Exclude "*.rb" | Copy-Item -Destination {Join-Path $destination $_.FullName.Substring($source.length)}
163+
164+ # Restore ports
165+ Copy-Item -Path ".\tmp\gems\tiny_tds-$gemVersion-$rubyArchitecture\ports" -Destination "." -Recurse
166+
167+ - restore_cache :
168+ name : restore mssql installation file
169+ key : downloads-{{ checksum "test/bin/install-mssql.ps1" }}
144170
145171 - run :
146- name : build libiconv
147- no_output_timeout : 30m
172+ name : setup mssql
148173 command : |
149- $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH"
150- bundle exec rake ports:libiconv
174+ .\test\bin\install-mssql.ps1
175+
176+ - save_cache :
177+ name : save downloads cache
178+ paths :
179+ - C:\Downloads
180+ key : downloads-{{ checksum "test/bin/install-mssql.ps1" }}
151181
152182 - run :
153- name : build freetds
154- no_output_timeout : 30m
183+ name : install toxiproxy-server
155184 command : |
156- $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH"
157- bundle exec rake ports:freetds
185+ choco install toxiproxy-server --version=2.5.0 -y
186+ Start-Process toxiproxy-server
158187
159188 - run :
160- name : build gem
161- no_output_timeout : 30m
189+ name : test gem
162190 command : |
163191 $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH"
164- bundle exec rake ports
192+ bundle exec rake test
193+ environment :
194+ TOXIPROXY_HOST : " localhost"
195+
196+ - store_test_results :
197+ path : test/reports
198+
199+ cross_compile_gem :
200+ machine :
201+ image : ubuntu-2004:current
202+
203+ steps :
204+ - ruby/install :
205+ version : ' 2.7'
206+ - checkout
207+ - restore_cache :
208+ name : restore gem cache
209+ keys :
210+ - v1-bundle-{{ .Branch }}-{{ checksum "tiny_tds.gemspec" }}
211+ - v1-bundle-{{ .Branch }}-
212+ - v1-bundle-
213+
214+ - run :
215+ name : bundle install gems
216+ command : |
217+ bundle install --path vendor/bundle
218+
219+ - save_cache :
220+ name : save gem cache
221+ paths :
222+ - ./vendor/bundle
223+ key : v1-bundle-{{ .Branch }}-{{ checksum "tiny_tds.gemspec" }}
224+
225+ - run :
226+ name : Write used versions for ports into file
227+ command : |
228+ bundle exec rake ports:version_file
229+
230+ - restore_cache :
231+ name : restore ports cache
232+ keys :
233+ - ports-{{ checksum ".ports_versions" }}
234+ - ports-
235+
236+ - run :
237+ name : Build gems
238+ command : |
239+ bundle exec rake gem
240+ bundle exec rake gem:native
241+
242+ - run :
243+ name : Move gems into separate directory before caching
244+ command : |
245+ mkdir -p artifacts/gems
246+ mv pkg/*.gem artifacts/gems
247+
248+ - store_artifacts :
249+ path : artifacts/gems
250+
251+ - save_cache :
252+ name : save ports cache
253+ paths :
254+ - ./ports
255+ key : ports-{{ checksum ".ports_versions" }}
256+
257+ - persist_to_workspace :
258+ name : save gems into workspace
259+ root : artifacts
260+ paths :
261+ - gems
165262
166263workflows :
167264 test_supported_ruby_versions :
168265 jobs :
169- - test_linux :
170- matrix :
266+ - cross_compile_gem
267+ - test_windows :
268+ requires :
269+ - cross_compile_gem
270+ matrix : &ruby_versions
171271 parameters :
172272 ruby_version :
273+ - ' 2.4'
173274 - ' 2.5'
174275 - ' 2.6'
175276 - ' 2.7'
176-
177- - test_windows :
178- matrix :
179- parameters :
180- ruby_version :
181- - ' 2.5'
182- - ' 2.6'
183- - ' 2.7'
277+ - ' 3.0'
278+ - test_linux :
279+ matrix : *ruby_versions
0 commit comments