-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CI improvements #525
Merged
andyundso
merged 16 commits into
rails-sqlserver:master
from
simplificator:circle-ci-improvements
Apr 2, 2023
Merged
CI improvements #525
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7e8cb9f
Lock Bundler to v2.3.26
andyundso 7b33fe3
Remove fix to use rake-compiler-dock on Windows for libiconv
andyundso 4da29c5
Bump openssl to v1.1.1s
andyundso fc83d92
Define task to compile native extensions
andyundso be92579
Skip dead connection test on Windows
andyundso f7e3656
Extend pipeline to test gem on Windows
andyundso 55c342d
Package gems on CI before Windows tests
andyundso dd3fd22
Ensure test container uses Ruby version defined in CI matrix
andyundso 00480bc
Test against Ruby 2.4
andyundso 43d252c
Publish test results to CircleCI
andyundso 741d1c5
Rename artifact for gems
andyundso 9d12f78
Restore cross-compiled code from final gem file
andyundso 2a071ad
Store precompiled gem into workspace instead of cache
andyundso 05e66f2
Fix order for compiling ports
andyundso 1f2bea0
Disable progress bar for Invoke-WebRequest
andyundso bb5c964
Add `/ALLUSERS` option to RubyInstaller
andyundso File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,15 @@ version: 2.1 | |
|
||
orbs: | ||
win: circleci/windows@4.1 | ||
ruby: circleci/ruby@2.0.0 | ||
|
||
jobs: | ||
test_linux: | ||
parameters: | ||
ruby_version: | ||
description: 'version tag for the cimg/ruby container' | ||
type: string | ||
|
||
machine: | ||
image: ubuntu-2004:current | ||
|
||
|
@@ -19,11 +20,13 @@ jobs: | |
|
||
- run: | ||
name: start docker-compose build environment | ||
command: | | ||
command: | | ||
sudo ./test/bin/setup_volume_permissions.sh | ||
docker-compose up -d | ||
echo "Waiting for containers to start..." | ||
sleep 10 | ||
environment: | ||
RUBY_VERSION: << parameters.ruby_version >> | ||
|
||
- run: | ||
name: install sql prereqs | ||
|
@@ -58,7 +61,10 @@ jobs: | |
- run: | ||
name: test gem | ||
command: | | ||
docker exec cimg_ruby bash -c 'bundle exec rake test' | ||
docker exec cimg_ruby bash -c 'bundle exec rake test' | ||
|
||
- store_test_results: | ||
path: test/reports | ||
|
||
test_windows: | ||
parameters: | ||
|
@@ -84,6 +90,8 @@ jobs: | |
- run: | ||
name: download and install ruby devkit | ||
command: | | ||
$ProgressPreference='SilentlyContinue' | ||
|
||
$uri = 'https://api.github.com/repos/oneclick/rubyinstaller2/tags?per_page=200' | ||
$releases = ((Invoke-WebRequest $uri) | ConvertFrom-Json).name | select-string -Pattern '<< parameters.ruby_version >>' | ||
$target_release = (($releases | Sort-Object -Descending)[0] | Out-String).Trim() | ||
|
@@ -93,7 +101,9 @@ jobs: | |
|
||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | ||
Invoke-WebRequest -UseBasicParsing -uri $download_uri -OutFile ruby-setup.exe | ||
.\ruby-setup.exe /VERYSILENT /NORESTART /DIR=C:/Ruby<< parameters.ruby_version >>-x64 | ||
|
||
echo "Download finished, starting installation of $target_version" | ||
.\ruby-setup.exe /VERYSILENT /NORESTART /ALLUSERS /DIR=C:/Ruby<< parameters.ruby_version >>-x64 | ||
|
||
- run: | ||
name: ruby diagnostics | ||
|
@@ -108,11 +118,10 @@ jobs: | |
rm .\ruby-setup.exe | ||
|
||
- run: | ||
name: update build env | ||
name: install bundler | ||
command: | | ||
$Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" | ||
ridk install 2 | ||
gem install bundler | ||
gem install bundler -v 2.3.26 | ||
|
||
- checkout | ||
|
||
|
@@ -127,57 +136,143 @@ jobs: | |
name: bundle install gems | ||
command: | | ||
$Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" | ||
bundle install | ||
bundle install --path vendor/bundle | ||
|
||
- save_cache: | ||
name: save gem cache | ||
paths: | ||
- ./vendor/bundle | ||
key: v1-bundle-<< parameters.ruby_version >>-{{ .Branch }}-{{ checksum "tiny_tds.gemspec" }} | ||
|
||
- attach_workspace: | ||
at: artifacts | ||
|
||
- run: | ||
name: build openssl | ||
no_output_timeout: 30m | ||
name: install native gem and restore cross-compiled code from gem | ||
command: | | ||
$Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" | ||
bundle exec rake ports:openssl | ||
$rubyArchitecture = (ruby -e 'puts RUBY_PLATFORM').Trim() | ||
$gemVersion = (Get-Content VERSION).Trim() | ||
|
||
gem install --local --install-dir=./tmp "artifacts/gems/tiny_tds-$gemVersion-$rubyArchitecture.gem" | ||
|
||
# Restore precompiled code | ||
$source = (Resolve-Path ".\tmp\gems\tiny_tds-$gemVersion-$rubyArchitecture\lib\tiny_tds").Path | ||
$destination = (Resolve-Path ".\lib\tiny_tds").Path | ||
Get-ChildItem $source -Recurse -Exclude "*.rb" | Copy-Item -Destination {Join-Path $destination $_.FullName.Substring($source.length)} | ||
|
||
# Restore ports | ||
Copy-Item -Path ".\tmp\gems\tiny_tds-$gemVersion-$rubyArchitecture\ports" -Destination "." -Recurse | ||
|
||
- restore_cache: | ||
name: restore mssql installation file | ||
key: downloads-{{ checksum "test/bin/install-mssql.ps1" }} | ||
|
||
- run: | ||
name: build libiconv | ||
no_output_timeout: 30m | ||
name: setup mssql | ||
command: | | ||
$Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" | ||
bundle exec rake ports:libiconv | ||
.\test\bin\install-mssql.ps1 | ||
|
||
- save_cache: | ||
name: save downloads cache | ||
paths: | ||
- C:\Downloads | ||
key: downloads-{{ checksum "test/bin/install-mssql.ps1" }} | ||
|
||
- run: | ||
name: build freetds | ||
no_output_timeout: 30m | ||
name: install toxiproxy-server | ||
command: | | ||
$Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" | ||
bundle exec rake ports:freetds | ||
choco install toxiproxy-server --version=2.5.0 -y | ||
Start-Process toxiproxy-server | ||
|
||
- run: | ||
name: build gem | ||
no_output_timeout: 30m | ||
name: test gem | ||
command: | | ||
$Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" | ||
bundle exec rake ports | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ha, oops |
||
bundle exec rake test | ||
environment: | ||
TOXIPROXY_HOST: "localhost" | ||
|
||
- store_test_results: | ||
path: test/reports | ||
|
||
cross_compile_gem: | ||
machine: | ||
image: ubuntu-2004:current | ||
|
||
steps: | ||
- ruby/install: | ||
version: '2.7' | ||
- checkout | ||
- restore_cache: | ||
name: restore gem cache | ||
keys: | ||
- v1-bundle-{{ .Branch }}-{{ checksum "tiny_tds.gemspec" }} | ||
- v1-bundle-{{ .Branch }}- | ||
- v1-bundle- | ||
|
||
- run: | ||
name: bundle install gems | ||
command: | | ||
bundle install --path vendor/bundle | ||
|
||
- save_cache: | ||
name: save gem cache | ||
paths: | ||
- ./vendor/bundle | ||
key: v1-bundle-{{ .Branch }}-{{ checksum "tiny_tds.gemspec" }} | ||
|
||
- run: | ||
name: Write used versions for ports into file | ||
command: | | ||
bundle exec rake ports:version_file | ||
|
||
- restore_cache: | ||
name: restore ports cache | ||
keys: | ||
- ports-{{ checksum ".ports_versions" }} | ||
- ports- | ||
|
||
- run: | ||
name: Build gems | ||
command: | | ||
bundle exec rake gem | ||
bundle exec rake gem:native | ||
|
||
- run: | ||
name: Move gems into separate directory before caching | ||
command: | | ||
mkdir -p artifacts/gems | ||
mv pkg/*.gem artifacts/gems | ||
|
||
- store_artifacts: | ||
path: artifacts/gems | ||
|
||
- save_cache: | ||
name: save ports cache | ||
paths: | ||
- ./ports | ||
key: ports-{{ checksum ".ports_versions" }} | ||
|
||
- persist_to_workspace: | ||
name: save gems into workspace | ||
root: artifacts | ||
paths: | ||
- gems | ||
|
||
workflows: | ||
test_supported_ruby_versions: | ||
jobs: | ||
- test_linux: | ||
matrix: | ||
- cross_compile_gem | ||
- test_windows: | ||
requires: | ||
- cross_compile_gem | ||
matrix: &ruby_versions | ||
parameters: | ||
ruby_version: | ||
- '2.4' | ||
- '2.5' | ||
- '2.6' | ||
- '2.7' | ||
|
||
- test_windows: | ||
matrix: | ||
parameters: | ||
ruby_version: | ||
- '2.5' | ||
- '2.6' | ||
- '2.7' | ||
- test_linux: | ||
matrix: *ruby_versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,5 @@ misc | |
/exe/* | ||
/ports/* | ||
!/ports/patches/ | ||
test/reports | ||
.ports_versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,2 @@ | ||
source 'https://rubygems.org' | ||
gemspec | ||
|
||
group :development do | ||
end | ||
|
||
group :test do | ||
gem 'minitest' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
# encoding: UTF-8 | ||
|
||
desc 'Build the windows binary gems per rake-compiler-dock' | ||
task 'gem:windows' => ['ports:cross'] do | ||
desc 'Build the native binary gems using rake-compiler-dock' | ||
task 'gem:native' => ['ports:cross'] do | ||
require 'rake_compiler_dock' | ||
|
||
# make sure to install our bundle | ||
build = ['bundle'] | ||
sh "bundle package --all" # Avoid repeated downloads of gems by using gem files from the host. | ||
|
||
# and finally build the native gem | ||
build << 'rake cross native gem RUBY_CC_VERSION=2.7.0:2.6.0:2.5.0:2.4.0 CFLAGS="-Wall" MAKE="make -j`nproc`"' | ||
|
||
RakeCompilerDock.sh build.join(' && ') | ||
GEM_PLATFORM_HOSTS.keys.each do |plat| | ||
RakeCompilerDock.sh "bundle --local && RUBY_CC_VERSION=#{RUBY_CC_VERSION} rake native:#{plat} gem", platform: plat | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify the benefit of caching this installation script? It's just another source file in the repo, so it should already be available on disk in the job step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't cache the PowerShell script, but the
C:/Downloads
folder where I download the MSSQL installation file into. As the URL is hardcoded into this script, I thought it was fine to use the script for the checksum.Potential side-effect is that if you change something in the script, it'll re-download the installation file. But it was also continue to use the cache even if Microsoft updates the SQL installation file on their side. I wouldn't say it's too important that the CI uses the latest version and rather take the 2 minute speed-up from caching the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah... duh.