|
| 1 | +name: rails-sqlserver/tiny_tds/test_supported_ruby_versions |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | +jobs: |
| 7 | + cross_compile_gem: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + container: |
| 10 | + image: "${{ matrix.platform }}" |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + platform: |
| 14 | + - x86-mingw32 |
| 15 | + - x64-mingw32 |
| 16 | + - x64-mingw-ucrt |
| 17 | + steps: |
| 18 | + |
| 19 | + - name: bundle install gems |
| 20 | + run: bundle install |
| 21 | + - name: Write used versions for ports into file |
| 22 | + run: rake ports:version_file[${{ matrix.platform }}] |
| 23 | + - name: restore_cache |
| 24 | + |
| 25 | + with: |
| 26 | + key: ports-win-{{ arch }}-{{ checksum ".ports_versions" }} |
| 27 | + path: "./ports" |
| 28 | + restore-keys: |- |
| 29 | + ports-win-{{ arch }}-{{ checksum ".ports_versions" }} |
| 30 | + ports-win-{{ arch }}- |
| 31 | + - name: Build gem |
| 32 | + run: rake gem:for_platform[${{ matrix.platform }}] |
| 33 | + - name: Move gems into separate directory before caching |
| 34 | + run: |- |
| 35 | + mkdir -p artifacts-${{ matrix.platform }}/gems |
| 36 | + mv pkg/*.gem artifacts-${{ matrix.platform }}/gems |
| 37 | + - name: Remove non-native gem to avoid conflict in workspace |
| 38 | + run: |- |
| 39 | + gemVersion=$(cat VERSION | tr -d "[:space:]") |
| 40 | + rm -rf artifacts-${{ matrix.platform }}/gems/tiny_tds-$gemVersion.gem |
| 41 | + |
| 42 | + with: |
| 43 | + path: artifacts-${{ matrix.platform }}/gems |
| 44 | + |
| 45 | + with: |
| 46 | + path: artifacts-${{ matrix.platform }}/gems |
| 47 | + test_windows: |
| 48 | + runs-on: ubuntu-latest |
| 49 | + needs: |
| 50 | + - cross_compile_gem |
| 51 | + env: |
| 52 | + RAKEOPT: "-rdevkit" |
| 53 | + TESTOPTS: "-v" |
| 54 | + MAKE: make V=1 -j2 |
| 55 | + strategy: |
| 56 | + matrix: |
| 57 | + mssql_version: |
| 58 | + - '2017' |
| 59 | + - '2019' |
| 60 | + - '2022' |
| 61 | + ruby_version: |
| 62 | + - '2.7' |
| 63 | + - '3.0' |
| 64 | + - '3.1' |
| 65 | + - '3.2' |
| 66 | + - '3.3' |
| 67 | + steps: |
| 68 | + - uses: "./.github/actions/install-ruby-windows" |
| 69 | + with: |
| 70 | + ruby_version: "${{ matrix.ruby_version }}" |
| 71 | + |
| 72 | + - name: restore_cache |
| 73 | + |
| 74 | + with: |
| 75 | + key: v1-bundle-${{ matrix.ruby_version }}-{{ arch }}-{{ .Branch }}-{{ checksum "tiny_tds.gemspec" }} |
| 76 | + path: "./vendor/bundle" |
| 77 | + restore-keys: |- |
| 78 | + v1-bundle-${{ matrix.ruby_version }}-{{ arch }}-{{ .Branch }}-{{ checksum "tiny_tds.gemspec" }} |
| 79 | + v1-bundle-${{ matrix.ruby_version }}-{{ arch }}-{{ .Branch }}- |
| 80 | + v1-bundle-${{ matrix.ruby_version }}-{{ arch }}- |
| 81 | + - name: bundle install gems |
| 82 | + run: |- |
| 83 | + $Env:PATH = "C:\\Ruby${{ matrix.ruby_version }}-x64\\bin;$Env:PATH" |
| 84 | + bundle install --path vendor/bundle |
| 85 | + |
| 86 | + with: |
| 87 | + path: artifacts |
| 88 | + - name: install native gem and restore cross-compiled code from gem |
| 89 | + run: |- |
| 90 | + $Env:PATH = "C:\\Ruby${{ matrix.ruby_version }}-x64\\bin;$Env:PATH" |
| 91 | + $rubyArchitecture = (ruby -e 'puts RUBY_PLATFORM').Trim() |
| 92 | + $gemVersion = (Get-Content VERSION).Trim() |
| 93 | + gem install --local --install-dir=./tmp "artifacts/gems/tiny_tds-$gemVersion-$rubyArchitecture.gem" |
| 94 | + # Restore precompiled code |
| 95 | + $source = (Resolve-Path ".\tmp\gems\tiny_tds-$gemVersion-$rubyArchitecture\lib\tiny_tds").Path |
| 96 | + $destination = (Resolve-Path ".\lib\tiny_tds").Path |
| 97 | + Get-ChildItem $source -Recurse -Exclude "*.rb" | Copy-Item -Destination {Join-Path $destination $_.FullName.Substring($source.length)} |
| 98 | + # Restore ports |
| 99 | + Copy-Item -Path ".\tmp\gems\tiny_tds-$gemVersion-$rubyArchitecture\ports" -Destination "." -Recurse |
| 100 | + - name: restore_cache |
| 101 | + |
| 102 | + with: |
| 103 | + key: downloads-${{ matrix.mssql_version }}-{{ checksum "test/bin/install-mssql.ps1" }} |
| 104 | + path: C:\Downloads |
| 105 | + - name: setup mssql |
| 106 | + run: ".\\test\\bin\\install-mssql.ps1 -Version ${{ matrix.mssql_version }}" |
| 107 | + - name: install toxiproxy-server |
| 108 | + run: |- |
| 109 | + choco install toxiproxy-server --version=2.5.0 -y |
| 110 | + Start-Process toxiproxy-server |
| 111 | + - name: test gem |
| 112 | + run: |- |
| 113 | + $Env:PATH = "C:\\Ruby${{ matrix.ruby_version }}-x64\\bin;$Env:PATH" |
| 114 | + bundle exec rake test |
| 115 | + env: |
| 116 | + TOXIPROXY_HOST: localhost |
| 117 | + |
| 118 | + with: |
| 119 | + path: test/reports |
| 120 | + - name: Rename gem to a consistent name to store artifact |
| 121 | + run: |- |
| 122 | + $Env:PATH = "C:\\Ruby${{ matrix.ruby_version }}-x64\\bin;$Env:PATH" |
| 123 | + $rubyArchitecture = (ruby -e 'puts RUBY_PLATFORM').Trim() |
| 124 | + $gemVersion = (Get-Content VERSION).Trim() |
| 125 | + New-Item -Path . -Name "tested_artifact" -ItemType "directory" |
| 126 | + Move-Item "artifacts/gems/tiny_tds-$gemVersion-$rubyArchitecture.gem" "tested_artifact" |
| 127 | + |
| 128 | + with: |
| 129 | + path: tested_artifact |
| 130 | + test_linux: |
| 131 | + runs-on: ubuntu-20.04 |
| 132 | + strategy: |
| 133 | + matrix: |
| 134 | + mssql_version: |
| 135 | + - '2017' |
| 136 | + - '2019' |
| 137 | + - '2022' |
| 138 | + ruby_version: |
| 139 | + - '2.7' |
| 140 | + - '3.0' |
| 141 | + - '3.1' |
| 142 | + - '3.2' |
| 143 | + - '3.3' |
| 144 | + steps: |
| 145 | + |
| 146 | + - name: start docker-compose build environment |
| 147 | + run: |- |
| 148 | + sudo ./test/bin/setup_volume_permissions.sh |
| 149 | + docker-compose up -d |
| 150 | + echo "Waiting for containers to start..." |
| 151 | + sleep 10 |
| 152 | + env: |
| 153 | + MSSQL_VERSION: "${{ matrix.mssql_version }}" |
| 154 | + RUBY_VERSION: "${{ matrix.ruby_version }}" |
| 155 | + - name: install sql prereqs |
| 156 | + run: docker exec cimg_ruby bash -c 'sudo -E ./test/bin/install-mssqltools.sh' |
| 157 | + - name: setup tiny_tds test database |
| 158 | + run: docker exec cimg_ruby bash -c './test/bin/setup_tinytds_db.sh' |
| 159 | + - name: bundle install gems |
| 160 | + run: docker exec cimg_ruby bash -c 'bundle install' |
| 161 | + - name: Write used versions into file |
| 162 | + run: docker exec cimg_ruby bash -c 'bundle exec rake ports:version_file' |
| 163 | + - name: restore_cache |
| 164 | + |
| 165 | + with: |
| 166 | + key: ports-${{ matrix.ruby_version }}-{{ arch }}-{{ checksum ".ports_versions" }} |
| 167 | + path: UPDATE_ME |
| 168 | + restore-keys: |- |
| 169 | + ports-${{ matrix.ruby_version }}-{{ arch }}-{{ checksum ".ports_versions" }} |
| 170 | + ports-${{ matrix.ruby_version }}-{{ arch }}- |
| 171 | + - name: compile ports |
| 172 | + run: docker exec cimg_ruby bash -c 'bundle exec rake ports' |
| 173 | + - name: build gem |
| 174 | + run: docker exec cimg_ruby bash -c 'bundle exec rake build' |
| 175 | + - name: Fix permissions on ports directory |
| 176 | + run: docker exec cimg_ruby bash -c 'sudo chown -R $(id -u):$(id -g) ports' |
| 177 | + - name: test gem |
| 178 | + run: docker exec cimg_ruby bash -c 'bundle exec rake test' |
| 179 | + - name: save_cache |
| 180 | + |
| 181 | + with: |
| 182 | + path: "./ports" |
| 183 | + key: ports-${{ matrix.ruby_version }}-{{ arch }}-{{ arch }}-{{ checksum ".ports_versions" }} |
| 184 | + |
| 185 | + with: |
| 186 | + path: test/reports |
| 187 | + install_windows: |
| 188 | + runs-on: ubuntu-latest |
| 189 | + env: |
| 190 | + RAKEOPT: "-rdevkit" |
| 191 | + TESTOPTS: "-v" |
| 192 | + MAKE: make V=1 -j2 |
| 193 | + strategy: |
| 194 | + matrix: |
| 195 | + ruby_version: |
| 196 | + - '2.7' |
| 197 | + - '3.0' |
| 198 | + - '3.1' |
| 199 | + - '3.2' |
| 200 | + - '3.3' |
| 201 | + steps: |
| 202 | + - uses: "./.github/actions/install-ruby-windows" |
| 203 | + with: |
| 204 | + ruby_version: "${{ matrix.ruby_version }}" |
| 205 | + - name: Ensure msys2 installation is complete |
| 206 | + run: |- |
| 207 | + $Env:PATH = "C:\\Ruby${{ matrix.ruby_version }}-x64\\bin;$Env:PATH" |
| 208 | + # on older Ruby version, the msys version shipped with RubyInstaller is quite old |
| 209 | + # and RubyInstaller will be unable to install anything because of outdated keys |
| 210 | + # With this those commands, we force to get a new set of keys |
| 211 | + # see https://www.msys2.org/docs/updating/#potential-issues |
| 212 | + ridk exec pacman-key --init |
| 213 | + ridk exec pacman-key --refresh-keys |
| 214 | + ridk install 1 2 3 |
| 215 | + |
| 216 | + - name: restore_cache |
| 217 | + |
| 218 | + with: |
| 219 | + key: v1-bundle-${{ matrix.ruby_version }}-{{ arch }}-{{ .Branch }}-{{ checksum "tiny_tds.gemspec" }} |
| 220 | + path: "./vendor/bundle" |
| 221 | + restore-keys: |- |
| 222 | + v1-bundle-${{ matrix.ruby_version }}-{{ arch }}-{{ .Branch }}-{{ checksum "tiny_tds.gemspec" }} |
| 223 | + v1-bundle-${{ matrix.ruby_version }}-{{ arch }}-{{ .Branch }}- |
| 224 | + v1-bundle-${{ matrix.ruby_version }}-{{ arch }}- |
| 225 | + - name: bundle install gems |
| 226 | + run: |- |
| 227 | + $Env:PATH = "C:\\Ruby${{ matrix.ruby_version }}-x64\\bin;$Env:PATH" |
| 228 | + bundle install --path vendor/bundle |
| 229 | + - name: build gem |
| 230 | + run: |- |
| 231 | + $Env:PATH = "C:\\Ruby${{ matrix.ruby_version }}-x64\\bin;$Env:PATH" |
| 232 | + gem build tiny_tds.gemspec |
| 233 | + - name: Install gem |
| 234 | + run: |- |
| 235 | + $Env:PATH = "C:\\Ruby${{ matrix.ruby_version }}-x64\\bin;$Env:PATH" |
| 236 | + $gemVersion = (Get-Content VERSION).Trim() |
| 237 | + gem install --local "tiny_tds-$gemVersion.gem" |
| 238 | + - name: Check if gem loads correctly |
| 239 | + run: |- |
| 240 | + $Env:PATH = "C:\\Ruby${{ matrix.ruby_version }}-x64\\bin;$Env:PATH" |
| 241 | + ruby -e "require 'tiny_tds'; puts TinyTds::Gem.root_path" |
| 242 | + exit $LASTEXITCODE |
0 commit comments