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

Migrate from Travis to GitHub Actions for CI #1534

Merged
merged 50 commits into from
Sep 20, 2021
Merged

Migrate from Travis to GitHub Actions for CI #1534

merged 50 commits into from
Sep 20, 2021

Conversation

aliciapaz
Copy link
Collaborator

@aliciapaz aliciapaz commented Aug 24, 2021

Fixes #1489

Based on #1491 and publiclab/spectral-workbench#647

Jobs to perform in CI/CD Pipeline based on Travis.yml:

  • Models Tests
  • Integration Tests
  • Controllers Tests
  • System Tests
  • Rubocop Linter
  • Development Docker Build
  • Production Docker Build
  • Asset Precompilation

@welcome
Copy link

welcome bot commented Aug 24, 2021

Thanks for opening this pull request! Dangerbot will test out your code and reply in a bit with some pointers and requests.
There may be some errors, but don't worry! We're here to help! 👍🎉😄

@aliciapaz
Copy link
Collaborator Author

Mysql2::Error::ConnectionError: Access denied for user 'runner'@'localhost' (using password: NO)

@codeclimate
Copy link

codeclimate bot commented Aug 24, 2021

Code Climate has analyzed commit d83a53d and detected 0 issues on this pull request.

View more on Code Climate.

@codecov
Copy link

codecov bot commented Aug 24, 2021

Codecov Report

Merging #1534 (2a496a9) into main (4331ef0) will decrease coverage by 0.64%.
The diff coverage is 61.53%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1534      +/-   ##
==========================================
- Coverage   72.98%   72.33%   -0.65%     
==========================================
  Files          40       40              
  Lines        1399     1406       +7     
==========================================
- Hits         1021     1017       -4     
- Misses        378      389      +11     
Impacted Files Coverage Δ
app/channels/concurrent_editing_channel.rb 0.00% <0.00%> (-83.34%) ⬇️
app/helpers/users_helper.rb 21.73% <0.00%> (ø)
app/models/map.rb 92.25% <ø> (-1.30%) ⬇️
app/helpers/application_helper.rb 50.00% <20.00%> (ø)
app/controllers/annotations_controller.rb 59.25% <22.22%> (ø)
app/controllers/sessions_controller.rb 32.91% <22.22%> (ø)
app/controllers/front_ui_controller.rb 74.28% <33.33%> (ø)
app/controllers/application_controller.rb 88.88% <50.00%> (ø)
app/controllers/images_controller.rb 76.54% <61.90%> (ø)
app/controllers/maps_controller.rb 86.95% <70.00%> (ø)
... and 14 more

@aliciapaz
Copy link
Collaborator Author

Ok, at least tests are running now, but with errors:

Minitest::UnexpectedError:         ArgumentError: You are passing an instance of ActiveRecord::Base to `find`. Please pass the id of the object by calling `.id`.
          app/channels/application_cable/connection.rb:12:in `find_verified_user'
          app/channels/application_cable/connection.rb:6:in `connect'
          test/channels/connection_test.rb:9:in `test_connection_with_user'

In unit tests:

FAIL ExporterTest#test_should_export_warpable_using_isolated_exporter_lib (7.71s)
       Expected false to be truthy.
       test/models/exporter_test.rb:38:in `block in <class:ExporterTest>'

In system tests:

Minitest::UnexpectedError:         Selenium::WebDriver::Error::UnknownError: unknown error: Chrome failed to start: exited abnormally.
       (unknown error: DevToolsActivePort file doesn't exist)
       (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
         test/system/searches_test.rb:5:in `block in <class:SearchesTest>'

@aliciapaz
Copy link
Collaborator Author

Hhhmmm I'm getting this error despite this gem not being inherited anywhere 🤔

Unable to find gem rubocop-discourse; is the gem installed? Gem::MissingSpecError

@aliciapaz
Copy link
Collaborator Author

Now I'm seeing:

Error: Ambiguous cop name `Style/VariableName` used in /home/runner/work/mapknitter/mapknitter/vendor/bundle/ruby/2.4.0/gems/geokit-1.13.1/.rubocop.yml needs department qualifier. Did you mean Naming/VariableName or RSpec/VariableName?

Weird...I can't see anything like "Style/VariableName" inside .rubocop.yml, nor inside the files from which it inherits (.rubocop_shopify_styleguide.yml and .rubocop_todo.yml)

@@ -15,7 +15,7 @@ AllCops:
- '/Rakefile'
- '/config.ru'
Exclude:
- 'vendor/*'
- 'vendor/**/*'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This line did the trick!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Except that I know have errors in code climate 🌦️

Copy link
Member

Choose a reason for hiding this comment

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

oof wow that was obscure! Glad you're figuring it out though!

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, i see:

We had trouble running the rubocop engine.
The engine's output shown below may indicate the cause of the error.
If not, please contact us so we can investigate further.

.rubocop.yml: `require` is concealed by duplicate
/usr/local/bundle/gems/rubocop-0.70.0/lib/rubocop/config_loader_resolver.rb:196:in `rescue in gem_config_path': Unable to find gem rubocop-shopify; is the gem installed? Gem::MissingSpecError (Gem::LoadError)
	from /usr/local/bundle/gems/rubocop-0.70.0/lib/rubocop/config_loader_resolver.rb:192:in `gem_config_path'
	from /usr/local/bundle/gems/rubocop-0.70.0/lib/rubocop/config_loader_resolver.rb:48:in `block (2 levels) in resolve_inheritance_from_gems'
	from /usr/local/bundle/gems/rubocop-0.70.0/lib/rubocop/config_loader_resolver.rb:46:in `reverse_each'

Copy link
Member

Choose a reason for hiding this comment

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

Isn't CodeClimate just running rubocop? So maybe we just need one or the other. Rubocop's job ran fine!

32 files inspected, no offenses detected

Gosh surprising that this is a lot more complex seeming than our other Rails repos. I guess the setup is relatively different?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right, I removed the rubocop plugin from codeclimate as it is in GH Actions now.

@aliciapaz
Copy link
Collaborator Author

I get this error in step 6 of development dockerfile:

RUN apt-get update -qq && apt-get install -y \
  nodejs gdal-bin curl procps git imagemagick python-gdal zip
W: GPG error: http://packages.laboratoriopublico.org/publiclab stretch InRelease: The following signatures were invalid: EXPKEYSIG BF26EE05EA6A68F0 Public Lab (Tycho) <[email protected]>

E: There were unauthenticated packages and -y was used without --allow-unauthenticated

@aliciapaz
Copy link
Collaborator Author

@jywarren any idea on how to go about the codecov failures?

Apart from that, all the other jobs are successful 🎉

Thanks!!

@jywarren
Copy link
Member

OK!!! So i think we could ignore the patch codecov because it's just saying that only 61% of your newly added/changed code is covered, which makes sense because you haven't really touched much testable code. The project one, well, we dropped below the 1% change (delta) threshold, which is supposed to ensure no PR lowers coverage by more than 1%. Again i think we can bypass that because it's clear we're not adding code that's really covered by a test suite.

So I'm going to change the job names a little bit for style/friendliness and to match plots2 if I can, but otherwise this looks good!

@@ -3,7 +3,7 @@ class ConcurrentEditingChannel < ApplicationCable::Channel

def subscribed
# Called first to connect user to the channel.
stream_from "concurrent_editing_channel:#{params[:mapSlug]}"
stream_from("concurrent_editing_channel:#{params[:mapSlug]}")
Copy link
Member

Choose a reason for hiding this comment

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

Were these changes from Rubocop telling you how it should be formatted? I think that's outside the scope of this PR ideally... it's fine that it's included but I'm sorry I should have caught this and made it clear you don't have to fix everyone else's syntax! Thank you though!!!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, the reason for those changes is that while I was setting up the Rubocop job I ran into lots of errors as you can see by the commit history... In my attempts to make this work, I changed the setup of the linter a bit (like adding the style guide as a gem instead of requiring it as a static file). After I made those changes, I had to run Rubocop again so it wouldn't fail due to linter offenses.

@@ -51,6 +51,7 @@ RUN git config --global url."https://".insteadOf git://
COPY . /app/
WORKDIR /app

RUN gem install bundler
Copy link
Member

Choose a reason for hiding this comment

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

aha!

@@ -41,6 +41,6 @@ WORKDIR /app
RUN apt-get clean && \
apt-get autoremove -y

RUN bundle install
RUN gem install bundler && bundle install
Copy link
Member

Choose a reason for hiding this comment

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

ok!

Copy link
Member

Choose a reason for hiding this comment

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

So, is it possible to move these development and production dockerfiles into a folder called dockerfiles or something? They're just a little mysterious sitting in the root folder. I don't recall we have them this way in plots2- but for comparison i think we have docker compose files in this directory:

https://github.com/publiclab/plots2/tree/main/containers/

Copy link
Member

Choose a reason for hiding this comment

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

I made some code suggestions for dockerfile/development etc below which you can accept, then we just need to move the files themselves. Almost there!!!

name: system-test-screenshots
path: tmp/screenshots/*

docker-development:
Copy link
Member

Choose a reason for hiding this comment

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

Can we rename this? What is its role? It looks good but even familiar with MapKnitter and docker, it's not super clear what the purpose of this job is, so i wonder if we could explain it a bit using the name? Thanks @aliciapaz!!!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, could it be development-docker-build and production-docker-build?
From what I understand, these jobs ensure that changes made to the source code do not break those docker builds. Does that make sense?
Thank you @jywarren!

bundler-cache: true
- uses: ./.github/actions/setup-test-environment
- name: 'Development Docker Build'
run: docker build -t mapknitter -f production .
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
run: docker build -t mapknitter -f production .
run: docker build -t mapknitter -f dockerfiles/production .

@jywarren
Copy link
Member

jywarren commented Sep 14, 2021 via email

@jywarren jywarren merged commit d2d45db into main Sep 20, 2021
@jywarren
Copy link
Member

Wooohoo!!!!!! Great work @aliciapaz !!!!!!

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.

Move Travis to Github actions
2 participants