Skip to content

Instantly share code, notes, and snippets.

@sallyhall
Last active December 12, 2024 14:28

Revisions

  1. sallyhall renamed this gist Dec 12, 2024. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.txt → mssql_ci.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    #Things that didn't work:
    # Things that didn't work:

    I started by adding a service to the test
    step, using the same Docker image and passing the env vars the test used.
    @@ -73,7 +73,7 @@ This failed because it needed Libnettle 3.4.1. So I added a step to install nett
    && sudo make install
    ```
    What finally did work:
    # What finally did work:
    Nettle installed successfully, but I still got the error `Libnettle 3.4.1 was
    not found.` when installing GnuTLS. At this point, I had exhausted my limited
  2. sallyhall created this gist Dec 12, 2024.
    94 changes: 94 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,94 @@
    #Things that didn't work:

    I started by adding a service to the test
    step, using the same Docker image and passing the env vars the test used.

    ```yml
    name: Tests
    runs-on: ubuntu-latest
    services:
    mssql:
    image: mcr.microsoft.com/mssql/server:2022-latest
    env:
    MSSQL_SA_PASSWORD: yourStrongPassword1
    ACCEPT_EULA: "Y"
    ports:
    - 1433:1433
    steps: - name: Checkout code
    uses: actions/checkout@v3

    ....
    ```

    The test step was already installing FreeTDS, which TinyTDS depends on. When I
    originally set it up, all the documentation I found pointed me toward [getting
    the source and building and installing it](https://github.com/rails-sqlserver/tiny_tds?tab=readme-ov-file#install). I followed advice in documentation
    and ended up installing it like this:

    ```yml
    - name: Install freetds
    run: |
    sudo apt-get install -y build-essential wget \
    && wget http://www.freetds.org/files/stable/freetds-1.1.24.tar.gz \
    && tar -xzf freetds-1.1.24.tar.gz \
    && cd freetds-1.1.24 \
    && ./configure --prefix=/usr/local --with-tdsver=7.3 \
    && sudo make \
    && sudo make install
    ```

    Now when I ran specs on CI, I got an error saying that the connection failed. I
    first confirmed the host and port I was using to connect to the local service.
    When I changed either of these, I got a new error message saying that the
    database server could not be found, so I was confident the host and port were
    correct. After a bunch of googling, I found a [related GitHub
    issue](https://github.com/rails-sqlserver/tiny_tds/issues/441) which points to a
    [problem with the TLS handshake on
    FreeTDS](https://github.com/FreeTDS/freetds/issues/299). [This
    comment](https://github.com/FreeTDS/freetds/issues/299#issuecomment-620729458)
    suggested using GnuTLS instead of OpenSSL for FreeTDS. I added a step to install
    GnuTLS in the GitHub workflow for running tests:

    ```yml
    - name: Install gnutls
    run: |
    wget https://www.gnupg.org/ftp/gcrypt/gnutls/v3.6/gnutls-3.6.16.tar.xz \
    && tar -xf gnutls-3.6.16.tar.xz \
    && cd gnutls-3.6.16 \
    && ./configure --prefix=/usr/local \
    && sudo make \
    && sudo make install
    ```

    This failed because it needed Libnettle 3.4.1. So I added a step to install nettle:

    ```yml
    - name: Install nettle
    run: |
    wget https://ftp.gnu.org/gnu/nettle/nettle-3.4.1.tar.gz \
    && tar -xzf nettle-3.4.1.tar.gz \
    && cd nettle-3.4.1 \
    && ./configure --prefix=/usr/local --disable-openssl --enable-shared \
    && sudo make \
    && sudo make install
    ```

    What finally did work:

    Nettle installed successfully, but I still got the error `Libnettle 3.4.1 was
    not found.` when installing GnuTLS. At this point, I had exhausted my limited
    understanding of package management on unix and reached out for help.
    [Mike](https://thoughtbot.com/blog/authors/mike-burns) jumped in to help and
    noted that the FreeTDS package on Debian stable is version 1.3.17, and it uses
    GnuTLS by default. This means that I could replace all the messy wget/tar/make
    attempts with calls to apt-get:

    ```yml
    - name: Install gnutls
    run: |
    sudo apt-get install gnutls-bin

    - name: Install freetds
    run: |
    sudo apt-get install -y freetds-bin freetds-common freetds-dev libct4 libsybdb5
    ```