Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to GitHub Actions #556

Merged
merged 13 commits into from
May 10, 2024

Conversation

andyundso
Copy link
Contributor

@andyundso andyundso commented Apr 23, 2024

This PR switches the pipeline for tiny_tds from CircleCI to GitHub Actions.

Functionality-wise, they should be equivalent, although I made a couple of additions:

  • The ports are compiled in one step for all the Linux jobs, similar to how we do this for Windows.
  • Test summary is displayed for each job, e.g. here.
  • The built gem versions for Windows can also be downloaded from that page.
  • I also test the installation of the gem on Mac with M1 processors. This was something I added once to CircleCI for Add /opt/homebrew to search path on Apple Silicon #545, only to realise it is only available for paid organizations.

Open questions / points from my side:

  • Currently, the installation on Windows for MSSQL 2017 is broken, so I commented it out in the matrix and reported an issue upstream (MSSQL 2017 on Windows does not work potatoqualitee/mssqlsuite#27). Worst case we could re-activate the solution we used for CircleCI, as I did not find another action that can install multiple versions of SQL server and on different platforms. I could also fork (or re-implemented) a similar solution on my own time.
  • docker-composee.yml currently uses the CircleCI Ruby image. I like having this compose file around for a quick start into tiny tds development, but I would suggest to switch the official Ruby images from Docker Hub.
  • There are a bunch of scripts we no longer would need (like setup_cimgruby_dev).

Copy link
Contributor

@aharpervc aharpervc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Mostly just offering pedantic comments/reflections...

- name: Build gem
shell: bash
run: bundle exec rake gem:for_platform[${{ matrix.platform }}]
- name: Move gems into separate directory before persisting
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this step still required? I vaguely recall difficulties on CircleCI, not sure if that'll still be a problem here...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, CircleCI did not support wildcard pattern, that's why we added this step.

I addressed removed this with 1d9a7c9.

- name: Download precompiled gem
uses: actions/download-artifact@v4
with:
name: gem-x64-mingw32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can't/won't parameterize this for the install task, because we're matching the VM?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically we are matching the Ruby version, everything below 3.0 is mingw32, 3.1 and newer is ucrt.

we probably could make a parameter out of it, or combine it with matrix, but to keep it simple I would suggest to spell it out explicitly for now.

Comment on lines +83 to +84
ruby -e "require 'tiny_tds'; puts TinyTds::Gem.root_path"
exit $LASTEXITCODE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend splitting this to it's own step, for better clarity on failure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed with dc3b1e4.

- 2.7
- '3.0'

name: Test on Windows (MingW)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for PR check clarity, we'll benefit from seeing the ruby version (and maybe sql server version) directly in the job name. Probably same comment for all jobs as applicable. Also, I'm big fan of consistency across jobs, so maybe something like test-$os (ruby $ruby_version), build- ..., etc. Looking at the list here: https://github.com/andyundso/tiny_tds/actions/runs/8806805186/job/24172426029

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a suggestion with 0b12511.

Copy-Item -Path ".\tmp\gems\tiny_tds-$gemVersion-$rubyArchitecture\ports" -Destination "." -Recurse

- name: Setup MSSQL
uses: potatoqualitee/[email protected]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we able to use service containers here instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linux service containers are not available on Windows for GitHub Actions. On Linux, the referenced action will use containers.

re: the action from ankane: would also work, also misses support for MSSQL 2017.

& sqlcmd -S localhost -U sa -P "c0MplicatedP@ssword" -i ./test/sql/db-create.sql
& sqlcmd -S localhost -U sa -P "c0MplicatedP@ssword" -i ./test/sql/db-login.sql

- name: Install toxiproxy-server
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible to cache this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... maybe?

I think it's just an executable for Windows, which we could cache. Chocolatey is just comfortable to get it running quickly. Installation also only takes about 1min, compared to MSSQL (~4min) and Ruby (~3min) it is "fast".

uses: test-summary/action@v2
with:
paths: "test/reports/TEST-*.xml"
if: always()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious, how do test failures show up here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a branch with a test that fails intentionally. here is the result: https://github.com/andyundso/tiny_tds/actions/runs/8900358242

here is also a screenshot:

image

@@ -0,0 +1,443 @@
name: Build and test gem
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also with the question(s) of how checks show up in the PR UI, this might be better as name: ci

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed with 6c4e643.

name: Build and test gem

on:
push:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to limit push to master, keeping the rest of the on's as you have it. Another way to say it, I don't think pushes to branches w/o PR's needs to run this CI workflow...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you fork the repository and want to run the actions, you would have to open a PR. therefore, I added this on: push, because it makes development in forks easier.

- name: Install gems
shell: bash
run: bundle install
- name: Write used versions into file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My fake undiagnosed OCD demands more newlines for this job, same as you have the others 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed with e994b63.

Copy link
Contributor

@bf4 bf4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given the complexity of this PR, it might be better to begin adding a GitHub ci action and then testing extending it before removing the circle ci config

@bf4
Copy link
Contributor

bf4 commented Apr 30, 2024

quick and dirty brainless importer didn't work. but now that there's an action on main with workflow dispatch, you can test it in a PR

example failures https://github.com/rails-sqlserver/tiny_tds/actions/runs/8888886154

Copy link
Contributor Author

@andyundso andyundso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aharpervc I think I addressed all your feedback.

I would adjust the development docker compose in a second PR, to not make this one even more bloated. :)

- name: Build gem
shell: bash
run: bundle exec rake gem:for_platform[${{ matrix.platform }}]
- name: Move gems into separate directory before persisting
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, CircleCI did not support wildcard pattern, that's why we added this step.

I addressed removed this with 1d9a7c9.

@@ -0,0 +1,443 @@
name: Build and test gem
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed with 6c4e643.

name: Build and test gem

on:
push:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you fork the repository and want to run the actions, you would have to open a PR. therefore, I added this on: push, because it makes development in forks easier.

- name: Install gems
shell: bash
run: bundle install
- name: Write used versions into file
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed with e994b63.

Comment on lines 56 to 57
- 2.7
- '3.0'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed with c7ae011.

& sqlcmd -S localhost -U sa -P "c0MplicatedP@ssword" -i ./test/sql/db-create.sql
& sqlcmd -S localhost -U sa -P "c0MplicatedP@ssword" -i ./test/sql/db-login.sql

- name: Install toxiproxy-server
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... maybe?

I think it's just an executable for Windows, which we could cache. Chocolatey is just comfortable to get it running quickly. Installation also only takes about 1min, compared to MSSQL (~4min) and Ruby (~3min) it is "fast".

uses: test-summary/action@v2
with:
paths: "test/reports/TEST-*.xml"
if: always()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a branch with a test that fails intentionally. here is the result: https://github.com/andyundso/tiny_tds/actions/runs/8900358242

here is also a screenshot:

image


- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we only need to compile the ports once for all the Linux jobs, so no matrix (aka parallel jobs) needed.

steps:
- uses: actions/checkout@v4

- name: Install FreeTDS
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apparently possible, but looks messy:
https://stackoverflow.com/a/65056232


- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think was just an oversight. I added it now to all jobs: 49c557d.

@andyundso andyundso marked this pull request as ready for review April 30, 2024 19:41
Copy link
Contributor

@aharpervc aharpervc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@bf4 bf4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to see this green.

If it's ok to merge I'm happy to merge it.

Then I'll remove the not-actually-working circleci->gh-actions import I added whilst trying to be helpful (.github/workflows/test.yml and .github/actions/install-ruby-windows/action.yml) and if y'all have admin to remove the circleci check we can remove that else put in a no-op config till we can get Ken to remove it

@andyundso andyundso merged commit 13acf23 into rails-sqlserver:master May 10, 2024
44 of 45 checks passed
@bf4 bf4 mentioned this pull request May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants