Skip to content

Commit 5baa708

Browse files
authored
Merge pull request #587 from andyundso/remove-old-ci-files
Remove unused CI files and provide a devcontainer setup
2 parents 9955437 + 5e2ef2b commit 5baa708

14 files changed

+111
-196
lines changed

.devcontainer/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM mcr.microsoft.com/devcontainers/ruby:2.7
2+
3+
# Install the SQL Server command-line tools and the Artistic Style code formatter
4+
RUN curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc \
5+
&& curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list \
6+
&& apt-get update \
7+
&& ACCEPT_EULA=Y apt-get install -y astyle mssql-tools18 unixodbc-dev
8+
ENV PATH=$PATH:/opt/mssql-tools18/bin
9+
10+
# Install FreeTDS
11+
ENV FREETDS_VERSION=1.5.1
12+
COPY test/bin/install-freetds.sh /tmp/
13+
RUN /tmp/install-freetds.sh
14+
15+
# Add the tiny_tds main Gemfile and install the gems.
16+
RUN mkdir -p /tmp/tiny_tds
17+
COPY Gemfile VERSION tiny_tds.gemspec /tmp/tiny_tds/
18+
RUN cd /tmp/tiny_tds \
19+
&& bundle install \
20+
&& rm -rf /tmp/tiny_tds
21+
RUN chown -R vscode:vscode /usr/local/rvm && chown -R vscode:vscode /usr/local/bundle

.devcontainer/boot.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Setup test databases and users.
2+
sqlcmd -C -S sqlserver -U sa -P 'c0MplicatedP@ssword' -i ./test/sql/db-create.sql
3+
sqlcmd -C -S sqlserver -U sa -P 'c0MplicatedP@ssword' -i ./test/sql/db-login.sql
4+
5+
# Mark directory as safe in Git so that commands run without warnings.
6+
git config --global --add safe.directory /workspaces/tiny_tds

.devcontainer/compose.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
version: '3'
2+
3+
services:
4+
tiny_tds:
5+
build:
6+
context: ..
7+
dockerfile: .devcontainer/Dockerfile
8+
9+
volumes:
10+
- ../..:/workspaces:cached
11+
12+
# Overrides default command so things don't shut down after the process ends.
13+
command: sleep infinity
14+
15+
networks:
16+
- default
17+
depends_on:
18+
- sqlserver
19+
20+
toxiproxy:
21+
image: ghcr.io/shopify/toxiproxy:2.5.0
22+
23+
sqlserver:
24+
image: mcr.microsoft.com/mssql/server:2022-latest
25+
restart: unless-stopped
26+
networks:
27+
- default
28+
volumes:
29+
- sqlserver-data:/var/opt/mssql
30+
ports:
31+
- "1433:1433"
32+
environment:
33+
MSSQL_SA_PASSWORD: 'c0MplicatedP@ssword'
34+
ACCEPT_EULA: Y
35+
36+
networks:
37+
default:
38+
39+
volumes:
40+
sqlserver-data:

.devcontainer/devcontainer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// For format details, see https://aka.ms/devcontainer.json.
2+
{
3+
"name": "tiny_tds project development",
4+
"dockerComposeFile": "compose.yaml",
5+
"service": "tiny_tds",
6+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
7+
8+
// Features to add to the dev container. More info: https://containers.dev/features.
9+
"features": {
10+
"ghcr.io/devcontainers/features/docker-in-docker:2": {
11+
// Moby is not installable in Debian 11
12+
"moby": false
13+
}
14+
},
15+
16+
"containerEnv": {
17+
"TINYTDS_UNIT_HOST": "sqlserver",
18+
"TOXIPROXY_HOST": "toxiproxy"
19+
},
20+
21+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
22+
// This can be used to network with other containers or the host.
23+
// "forwardPorts": [3000, 5432],
24+
25+
// Use 'postCreateCommand' to run commands after the container is created.
26+
"postCreateCommand": ".devcontainer/boot.sh",
27+
28+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
29+
// "remoteUser": "root"
30+
}

README.md

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -401,42 +401,26 @@ First, clone the repo using the command line or your Git GUI of choice.
401401
$ git clone [email protected]:rails-sqlserver/tiny_tds.git
402402
```
403403

404-
After that, the quickest way to get setup for development is to use [Docker](https://www.docker.com/). Assuming you have [downloaded docker](https://www.docker.com/products/docker) for your platform, you can use [docker-compose](https://docs.docker.com/compose/install/) to run the necessary containers for testing.
404+
After that, the quickest way to get setup for development is to use the provided devcontainers setup.
405405

406406
```shell
407-
$ docker-compose up -d
407+
npm install -g @devcontainers/cli
408+
devcontainer up --workspace-folder .
409+
devcontainer exec --workspace-folder . bash
408410
```
409411

410-
This will download the official SQL Server for Linux Docker image from [Microsoft](https://hub.docker.com/r/microsoft/mssql-server-linux/). This will also download a [toxiproxy](https://github.com/shopify/toxiproxy) Docker image which we can use to simulate network failures for tests. Basically, it does the following:
412+
From within the container, you can run the tests using the following command:
411413

412414
```shell
413-
$ docker network create main-network
414-
$ docker pull mcr.microsoft.com/mssql/server:2017-latest
415-
$ docker run -p 1433:1433 -d --name sqlserver --network main-network mcr.microsoft.com/mssql/server:2017-latest
416-
$ docker pull shopify/toxiproxy
417-
$ docker run -p 8474:8474 -p 1234:1234 -d --name toxiproxy --network main-network shopify/toxiproxy
415+
bundle install
416+
bundle exec rake test
418417
```
419418

420-
Make sure to run these SQL scripts as SA to get the test database and user installed. If needed, install [sqlcmd as described by Microsoft for your platform](https://learn.microsoft.com/en-us/sql/tools/sqlcmd/sqlcmd-utility?view=sql-server-ver16&tabs=go%2Clinux&pivots=cs1-bash).
419+
You can customize the environment variables to run the tests against a different environment
421420

422-
```shell
423-
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P super01S3cUr3 -i ./test/sql/db-create.sql
424-
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P super01S3cUr3 -i ./test/sql/db-login.sql
425-
```
426-
427-
From here you can build and run tests against an installed version of FreeTDS.
428-
429-
```shell
430-
$ bundle install
431-
$ bundle exec rake
432-
```
433-
434-
Examples us using enviornment variables to customize the test task.
435-
436-
```
437-
$ rake TINYTDS_UNIT_DATASERVER=mydbserver
438-
$ rake TINYTDS_UNIT_DATASERVER=mydbserver TINYTDS_SCHEMA=sqlserver_2017
439-
$ rake TINYTDS_UNIT_HOST=mydb.host.net TINYTDS_SCHEMA=sqlserver_azure
421+
```shell
422+
rake test TINYTDS_UNIT_DATASERVER=mydbserver TINYTDS_SCHEMA=sqlserver_2017
423+
rake test TINYTDS_UNIT_HOST=mydb.host.net TINYTDS_SCHEMA=sqlserver_azure
440424
```
441425

442426
### Code formatting
@@ -450,7 +434,7 @@ We are using `standardrb` to format the Ruby code and Artistic Style for the C c
450434
451435
For the convenience, TinyTDS ships pre-compiled gems for supported versions of Ruby on Windows and Linux. In order to generate these gems, [rake-compiler-dock](https://github.com/rake-compiler/rake-compiler-dock) is used.
452436

453-
Run the following rake task to compile the gems. This will check the availability of [Docker](https://www.docker.com/) and will give some advice for download and installation. When docker is running, it will download the docker image (once-only) and start the build:
437+
Run the following rake task to compile the gems. You can run these commands from inside the devcontainers setup, or outside if neeed. The command will check the availability of [Docker](https://www.docker.com/) and will give some advice for download and installation. When docker is running, it will download the docker image (once-only) and start the build:
454438

455439
```shell
456440
bundle exec rake gem:native

docker-compose.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

setup_cimgruby_dev.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.

start_dev.sh

Lines changed: 0 additions & 21 deletions
This file was deleted.

test/bin/install-mssql.ps1

Lines changed: 0 additions & 42 deletions
This file was deleted.

test/bin/install-mssqltools.sh

Lines changed: 0 additions & 9 deletions
This file was deleted.

test/bin/install-openssl.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

test/bin/setup_tinytds_db.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

test/bin/setup_volume_permissions.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

tiny_tds.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
2-
require "tiny_tds/version"
2+
version = File.read(File.expand_path("VERSION", __dir__)).strip
33

44
Gem::Specification.new do |s|
55
s.name = "tiny_tds"
6-
s.version = TinyTds::VERSION
6+
s.version = version
77
s.platform = Gem::Platform::RUBY
88
s.authors = ["Ken Collins", "Erik Bryn", "Will Bond"]
99

0 commit comments

Comments
 (0)