|
| 1 | +version: 2.1 |
| 2 | + |
| 3 | +orbs: |
| 4 | + |
| 5 | + |
| 6 | +jobs: |
| 7 | + test_linux: |
| 8 | + parameters: |
| 9 | + ruby_version: |
| 10 | + description: 'version tag for the cimg/ruby container' |
| 11 | + type: string |
| 12 | + |
| 13 | + machine: |
| 14 | + image: ubuntu-2004:current |
| 15 | + |
| 16 | + # be sure to update the ./setup_cimgruby_dev.sh if changes are made to steps below |
| 17 | + steps: |
| 18 | + - checkout |
| 19 | + |
| 20 | + - run: |
| 21 | + name: start docker-compose build environment |
| 22 | + command: | |
| 23 | + sudo ./test/bin/setup_volume_permissions.sh |
| 24 | + docker-compose up -d |
| 25 | + echo "Waiting for containers to start..." |
| 26 | + sleep 10 |
| 27 | +
|
| 28 | + - run: |
| 29 | + name: install sql prereqs |
| 30 | + command: | |
| 31 | + docker exec cimg_ruby bash -c 'sudo -E ./test/bin/install-mssqltools.sh' |
| 32 | +
|
| 33 | + - run: |
| 34 | + name: setup tiny_tds test database |
| 35 | + command: | |
| 36 | + docker exec cimg_ruby bash -c './test/bin/setup_tinytds_db.sh' |
| 37 | +
|
| 38 | + - run: |
| 39 | + name: compile openssl library |
| 40 | + command: | |
| 41 | + docker exec cimg_ruby bash -c 'sudo -E ./test/bin/install-openssl.sh' |
| 42 | +
|
| 43 | + - run: |
| 44 | + name: compile freetds library |
| 45 | + command: | |
| 46 | + docker exec cimg_ruby bash -c 'sudo -E ./test/bin/install-freetds.sh' |
| 47 | +
|
| 48 | + - run: |
| 49 | + name: bundle install gems |
| 50 | + command: | |
| 51 | + docker exec cimg_ruby bash -c 'bundle install' |
| 52 | +
|
| 53 | + - run: |
| 54 | + name: build gem |
| 55 | + command: | |
| 56 | + docker exec cimg_ruby bash -c 'bundle exec rake build' |
| 57 | +
|
| 58 | + - run: |
| 59 | + name: test gem |
| 60 | + command: | |
| 61 | + docker exec cimg_ruby bash -c 'bundle exec rake test' |
| 62 | +
|
| 63 | + test_windows: |
| 64 | + parameters: |
| 65 | + ruby_version: |
| 66 | + description: 'version tag for rubydev environment' |
| 67 | + type: string |
| 68 | + |
| 69 | + executor: |
| 70 | + name: win/server-2022 |
| 71 | + shell: powershell.exe |
| 72 | + |
| 73 | + environment: |
| 74 | + RAKEOPT: '-rdevkit' |
| 75 | + TESTOPTS: '-v' |
| 76 | + MAKE: 'make V=1 -j2' |
| 77 | + |
| 78 | + steps: |
| 79 | + - run: |
| 80 | + name: remove pre-installed ruby |
| 81 | + command: | |
| 82 | + Get-ChildItem -path 'C:\tools\' -filter Ruby* | Remove-Item -Force -Recurse |
| 83 | +
|
| 84 | + - run: |
| 85 | + name: download and install ruby devkit |
| 86 | + command: | |
| 87 | + $uri = 'https://api.github.com/repos/oneclick/rubyinstaller2/tags?per_page=200' |
| 88 | + $releases = ((Invoke-WebRequest $uri) | ConvertFrom-Json).name | select-string -Pattern '<< parameters.ruby_version >>' |
| 89 | + $target_release = (($releases | Sort-Object -Descending)[0] | Out-String).Trim() |
| 90 | + $target_version = $target_release.Substring($target_release.Length - 7) |
| 91 | + $download_uri = "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-$target_version/rubyinstaller-devkit-$target_version-x64.exe" |
| 92 | + echo "Ruby Target Version Found: $target_version" |
| 93 | +
|
| 94 | + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 |
| 95 | + Invoke-WebRequest -UseBasicParsing -uri $download_uri -OutFile ruby-setup.exe |
| 96 | + .\ruby-setup.exe /VERYSILENT /NORESTART /DIR=C:/Ruby<< parameters.ruby_version >>-x64 |
| 97 | +
|
| 98 | + - run: |
| 99 | + name: ruby diagnostics |
| 100 | + command: | |
| 101 | + $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" |
| 102 | + echo "Perl Version:" |
| 103 | + perl --version |
| 104 | + echo "Ruby Version:" |
| 105 | + ruby --version |
| 106 | + echo "Gem Version:" |
| 107 | + gem --version |
| 108 | + rm .\ruby-setup.exe |
| 109 | +
|
| 110 | + - run: |
| 111 | + name: update build env |
| 112 | + command: | |
| 113 | + $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" |
| 114 | + ridk install 2 |
| 115 | + gem install bundler |
| 116 | +
|
| 117 | + - checkout |
| 118 | + |
| 119 | + - restore_cache: |
| 120 | + name: restore gem cache |
| 121 | + keys: |
| 122 | + - v1-bundle-<< parameters.ruby_version >>-{{ .Branch }}-{{ checksum "tiny_tds.gemspec" }} |
| 123 | + - v1-bundle-<< parameters.ruby_version >>-{{ .Branch }}- |
| 124 | + - v1-bundle-<< parameters.ruby_version >>- |
| 125 | + |
| 126 | + - run: |
| 127 | + name: bundle install gems |
| 128 | + command: | |
| 129 | + $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" |
| 130 | + bundle install |
| 131 | +
|
| 132 | + - save_cache: |
| 133 | + name: save gem cache |
| 134 | + paths: |
| 135 | + - ./vendor/bundle |
| 136 | + key: v1-bundle-<< parameters.ruby_version >>-{{ .Branch }}-{{ checksum "tiny_tds.gemspec" }} |
| 137 | + |
| 138 | + - run: |
| 139 | + name: build openssl |
| 140 | + no_output_timeout: 30m |
| 141 | + command: | |
| 142 | + $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" |
| 143 | + bundle exec rake ports:openssl |
| 144 | +
|
| 145 | + - run: |
| 146 | + name: build libiconv |
| 147 | + no_output_timeout: 30m |
| 148 | + command: | |
| 149 | + $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" |
| 150 | + bundle exec rake ports:libiconv |
| 151 | +
|
| 152 | + - run: |
| 153 | + name: build freetds |
| 154 | + no_output_timeout: 30m |
| 155 | + command: | |
| 156 | + $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" |
| 157 | + bundle exec rake ports:freetds |
| 158 | +
|
| 159 | + - run: |
| 160 | + name: build gem |
| 161 | + no_output_timeout: 30m |
| 162 | + command: | |
| 163 | + $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" |
| 164 | + bundle exec rake ports |
| 165 | +
|
| 166 | +workflows: |
| 167 | + test_supported_ruby_versions: |
| 168 | + jobs: |
| 169 | + - test_linux: |
| 170 | + matrix: |
| 171 | + parameters: |
| 172 | + ruby_version: |
| 173 | + - '2.5' |
| 174 | + - '2.6' |
| 175 | + - '2.7' |
| 176 | + |
| 177 | + - test_windows: |
| 178 | + matrix: |
| 179 | + parameters: |
| 180 | + ruby_version: |
| 181 | + - '2.5' |
| 182 | + - '2.6' |
| 183 | + - '2.7' |
0 commit comments