Skip to content

Commit

Permalink
Switch to CircleCI (rails-sqlserver#514)
Browse files Browse the repository at this point in the history
Co-authored-by: Bryan Wiegand <[email protected]>
  • Loading branch information
bryanwieg and Bryan Wiegand authored Nov 15, 2022
1 parent e3e79a0 commit c8111e6
Show file tree
Hide file tree
Showing 19 changed files with 356 additions and 182 deletions.
183 changes: 183 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
version: 2.1

orbs:
win: circleci/[email protected]

jobs:
test_linux:
parameters:
ruby_version:
description: 'version tag for the cimg/ruby container'
type: string

machine:
image: ubuntu-2004:current

# be sure to update the ./setup_cimgruby_dev.sh if changes are made to steps below
steps:
- checkout

- run:
name: start docker-compose build environment
command: |
sudo ./test/bin/setup_volume_permissions.sh
docker-compose up -d
echo "Waiting for containers to start..."
sleep 10
- run:
name: install sql prereqs
command: |
docker exec cimg_ruby bash -c 'sudo -E ./test/bin/install-mssqltools.sh'
- run:
name: setup tiny_tds test database
command: |
docker exec cimg_ruby bash -c './test/bin/setup_tinytds_db.sh'
- run:
name: compile openssl library
command: |
docker exec cimg_ruby bash -c 'sudo -E ./test/bin/install-openssl.sh'
- run:
name: compile freetds library
command: |
docker exec cimg_ruby bash -c 'sudo -E ./test/bin/install-freetds.sh'
- run:
name: bundle install gems
command: |
docker exec cimg_ruby bash -c 'bundle install'
- run:
name: build gem
command: |
docker exec cimg_ruby bash -c 'bundle exec rake build'
- run:
name: test gem
command: |
docker exec cimg_ruby bash -c 'bundle exec rake test'
test_windows:
parameters:
ruby_version:
description: 'version tag for rubydev environment'
type: string

executor:
name: win/server-2022
shell: powershell.exe

environment:
RAKEOPT: '-rdevkit'
TESTOPTS: '-v'
MAKE: 'make V=1 -j2'

steps:
- run:
name: remove pre-installed ruby
command: |
Get-ChildItem -path 'C:\tools\' -filter Ruby* | Remove-Item -Force -Recurse
- run:
name: download and install ruby devkit
command: |
$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()
$target_version = $target_release.Substring($target_release.Length - 7)
$download_uri = "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-$target_version/rubyinstaller-devkit-$target_version-x64.exe"
echo "Ruby Target Version Found: $target_version"
[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
- run:
name: ruby diagnostics
command: |
$Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH"
echo "Perl Version:"
perl --version
echo "Ruby Version:"
ruby --version
echo "Gem Version:"
gem --version
rm .\ruby-setup.exe
- run:
name: update build env
command: |
$Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH"
ridk install 2
gem install bundler
- checkout

- restore_cache:
name: restore gem cache
keys:
- v1-bundle-<< parameters.ruby_version >>-{{ .Branch }}-{{ checksum "tiny_tds.gemspec" }}
- v1-bundle-<< parameters.ruby_version >>-{{ .Branch }}-
- v1-bundle-<< parameters.ruby_version >>-

- run:
name: bundle install gems
command: |
$Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH"
bundle install
- save_cache:
name: save gem cache
paths:
- ./vendor/bundle
key: v1-bundle-<< parameters.ruby_version >>-{{ .Branch }}-{{ checksum "tiny_tds.gemspec" }}

- run:
name: build openssl
no_output_timeout: 30m
command: |
$Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH"
bundle exec rake ports:openssl
- run:
name: build libiconv
no_output_timeout: 30m
command: |
$Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH"
bundle exec rake ports:libiconv
- run:
name: build freetds
no_output_timeout: 30m
command: |
$Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH"
bundle exec rake ports:freetds
- run:
name: build gem
no_output_timeout: 30m
command: |
$Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH"
bundle exec rake ports
workflows:
test_supported_ruby_versions:
jobs:
- test_linux:
matrix:
parameters:
ruby_version:
- '2.5'
- '2.6'
- '2.7'

- test_windows:
matrix:
parameters:
ruby_version:
- '2.5'
- '2.6'
- '2.7'
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# TinyTDS - Simple and fast FreeTDS bindings for Ruby using DB-Library.

* [![TravisCI](https://travis-ci.org/rails-sqlserver/tiny_tds.svg?branch=master)](https://travis-ci.org/rails-sqlserver/tiny_tds) - TravisCI
* [![Build Status](https://ci.appveyor.com/api/projects/status/g2bhhbsdkx0mal55/branch/master?svg=true)](https://ci.appveyor.com/project/rails-sqlserver/tiny-tds/branch/master) - Appveyor
* [![CircleCI](https://circleci.com/gh/rails-sqlserver/tiny_tds.svg?style=svg)](https://app.circleci.com/pipelines/github/rails-sqlserver/tiny_tds) - CircleCi
* [![Gem Version](https://img.shields.io/gem/v/tiny_tds.svg)](https://rubygems.org/gems/tiny_tds) - Gem Version
* [![Gitter chat](https://img.shields.io/badge/%E2%8A%AA%20GITTER%20-JOIN%20CHAT%20%E2%86%92-brightgreen.svg?style=flat)](https://gitter.im/rails-sqlserver/activerecord-sqlserver-adapter) - Community


## About TinyTDS

The TinyTDS gem is meant to serve the extremely common use-case of connecting, querying and iterating over results to Microsoft SQL Server or Sybase databases from Ruby using the FreeTDS's DB-Library API.
Expand Down
1 change: 0 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,3 @@ end

task build: [:clean, :compile]
task default: [:build, :test]

72 changes: 0 additions & 72 deletions appveyor.yml

This file was deleted.

26 changes: 19 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,28 @@ services:
mssql:
image: metaskills/mssql-server-linux-tinytds:2017-GA
container_name: sqlserver
environment:
ACCEPT_EULA: Y
SA_PASSWORD: super01S3cUr3
ports:
- "1433:1433"
networks:
- main-network
network_mode: "host"

toxiproxy:
image: shopify/toxiproxy
container_name: toxiproxy
ports:
- "8474:8474"
- "1234:1234"
networks:
- main-network
command: '/toxiproxy -host=127.0.0.1'
network_mode: "host"

cimgruby:
image: cimg/ruby:2.7.0
container_name: cimg_ruby
environment:
TESTOPTS: '-v'
TINYTDS_UNIT_HOST: '127.0.0.1'
SA_PASSWORD: super01S3cUr3
TOXIPROXY_HOST: '127.0.0.1'
command: tail -F anything
volumes:
- .:/home/circleci/project
network_mode: "host"
25 changes: 25 additions & 0 deletions setup_cimgruby_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -x
set -e

# this should mirror the steps outlined in the circleci yml
echo "Installing mssql-tools..."
sleep 5
sudo -E ./test/bin/install-mssqltools.sh

echo "Configurating tinytds test database..."
sleep 5
./test/bin/setup_tinytds_db.sh

echo "Building openssl library..."
sleep 5
sudo -E ./test/bin/install-openssl.sh

echo "Building freetds library..."
sleep 5
sudo -E ./test/bin/install-freetds.sh

echo "Installing gems..."
sleep 5
bundle install
21 changes: 21 additions & 0 deletions start_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

set -x
set -e

# set volume read/write permissions to work both outside and inside container
sudo ./test/bin/setup_volume_permissions.sh

docker-compose up -d
echo "Waiting for containers to start..."
sleep 10

# setup circleci ruby container for development
docker exec cimg_ruby bash -c './setup_cimgruby_dev.sh'

# enter container
set +x
echo "cimg/ruby container is ready for tiny_tds development.........."
echo "To enter container run: docker exec -it cimg_ruby /bin/bash"
echo "To build solution run: docker exec cimg_ruby bash -c 'bundle exec rake build'"
echo "To test solution run: docker exec cimg_ruby bash -c 'bundle exec rake test'"
Loading

0 comments on commit c8111e6

Please sign in to comment.