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

Convert CircleCI to GitHub Actions #23608

Merged
merged 45 commits into from Mar 7, 2023

Conversation

nschonni
Copy link
Contributor

I tried out https://docs.github.com/en/actions/migrating-to-github-actions/automating-migration-with-github-actions-importer but mostly had to redo it anyway.
There is still an issue with the Ruby 2.7 build I'm not sure how to fix, so opening this up to see if someone else has an idea.

- run: yarn install --frozen-lockfile
- name: Precompile assets
# Previously had set this, but it's not supported
# export NODE_OPTIONS=--openssl-legacy-provider
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what this one was used for, as current Node throws a warning/error using this flag in the variable

Copy link
Contributor

Choose a reason for hiding this comment

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

This was used because OpenSSL 3 doesn't support some of the algorithms used by webpack. Without it, on some node versions, this would result in the build failing with loads of errors like this:

ERROR in chunk public [initial]
js/public-73f580d0c8328bbd755f.chunk.js
/home/claire/Sources/GIT/mastodon/node_modules/babel-loader/lib/index.js??ref--8-0!/home/claire/Sources/GIT/mastodon/app/javascript/mastodon/load_keyboard_extensions.js
error:0308010C:digital envelope routines::unsupported

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing that out. Looks like it's not an issue/supported, because the version in .nvmrc is still on the v16 release line, and the OpenSSL 3.0 was a 17+ thing https://stackoverflow.com/questions/69962209/what-is-openssl-legacy-provider-in-node-js-v17

.github/workflows/build-and-test.yml Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@ykzts
Copy link
Sponsor Member

ykzts commented Feb 15, 2023

Thank you for the very good Pull Request! But I would like to see how much the Queue is used by moving the whole thing to GitHub Actions, so I would like to see the Pull Request split into several separate Pull Requests for each task.

@nschonni
Copy link
Contributor Author

so I would like to see the Pull Request split into several separate Pull Requests for each task.

Definitely! I think separate from this, because it might not land, I'll split off the Jest testing, since it doesn't seem to rely on the other steps.

I think the migration tests could also have some sort of filter on them. Would it just be for any changes to db/* or would them be impacted by any other file changes? Gemfile* probably to catch any rails update dependencies.

@nschonni
Copy link
Contributor Author

@ClearlyClaire I had to revert #23571 to make Ruby 2.7 happy. That doesn't seem like the right fix though, would you have any ideas?

@github-actions
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@ClearlyClaire
Copy link
Contributor

@ClearlyClaire I had to revert #23571 to make Ruby 2.7 happy. That doesn't seem like the right fix though, would you have any ideas?

What made it unhappy?

@nschonni
Copy link
Contributor Author

@ClearlyClaire I had to revert #23571 to make Ruby 2.7 happy. That doesn't seem like the right fix though, would you have any ideas?

What made it unhappy?

Ah, sorry, the rebase meant the previous builds with the message got cleared, but you can see the same message from my fork's build:

bundler: failed to load command: rspec (/home/runner/work/mastodon/mastodon/vendor/bundle/ruby/2.7.0/bin/rspec)
/opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/lib/bundler/runtime.rb:304:in `check_for_activated_spec!': You have already activated uri 0.10.0, but your Gemfile requires uri 0.12.0. Since uri is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports uri as a default gem. (Gem::LoadError)
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/lib/bundler/runtime.rb:25:in `block in setup'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/lib/bundler/spec_set.rb:155:in `each'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/lib/bundler/spec_set.rb:155:in `each'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/lib/bundler/runtime.rb:24:in `map'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/lib/bundler/runtime.rb:24:in `setup'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/lib/bundler.rb:170:in `setup'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/lib/bundler/setup.rb:20:in `block in <top (required)>'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/lib/bundler/ui/shell.rb:159:in `with_level'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/lib/bundler/ui/shell.rb:111:in `silence'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/lib/bundler/setup.rb:20:in `<top (required)>'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/lib/bundler/cli/exec.rb:56:in `require_relative'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/lib/bundler/cli/exec.rb:56:in `kernel_load'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/lib/bundler/cli/exec.rb:23:in `run'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/lib/bundler/cli.rb:492:in `exec'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/lib/bundler/cli.rb:34:in `dispatch'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/lib/bundler/cli.rb:28:in `start'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/exe/bundle:45:in `block in <top (required)>'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.7/exe/bundle:33:in `<top (required)>'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/bin/bundle:23:in `load'
	from /opt/hostedtoolcache/Ruby/2.7.7/x64/bin/bundle:23:in `<main

https://github.com/nschonni/mastodon/actions/runs/4186815456/jobs/7255893357#step:11:21

@ClearlyClaire
Copy link
Contributor

ClearlyClaire commented Feb 17, 2023

https://gorails.com/blog/bundler-default-gem-dependency-error suggests updating installed gems, but I wonder if that's the correct solution

@nschonni
Copy link
Contributor Author

I'll give that a try. Looks like 2.7 only has a little over a month till EOL https://endoflife.date/ruby so maybe something that will go away with that

@nschonni
Copy link
Contributor Author

@ClearlyClaire looks like adding a conditional gem update --system for 2.7 seemed to have made it happy.
Seems like the matrix is slower than CircleCI, but I haven't dug into why yet.

@nschonni
Copy link
Contributor Author

nschonni commented Feb 18, 2023

Hmm, weird one about the performance between the two providers.
CircleCI:

Finished in 2 minutes 30 seconds (files took 6.06 seconds to load)
751 examples, 0 failures

GitHub Actions:

 Finished in 10 minutes 22 seconds (files took 7.31 seconds to load)
3744 examples, 0 failures, 26 pending

Actions seems 4 times slower, but is also executing that many more tests???

@nschonni nschonni marked this pull request as draft February 18, 2023 20:15
@github-actions
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@nschonni nschonni marked this pull request as ready for review March 6, 2023 18:30
@nschonni
Copy link
Contributor Author

nschonni commented Mar 6, 2023

OK, I think with the rspec_chunked that does a very simple fan out based on file size, the timings are at least close to CircleCI, so I'm going to unmark this as draft.

Let me know if you want me to cleanup the commits


services:
postgres:
image: postgres:14.5
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unlike CircleCI, this could be changed to the floating 14

run: gem update --system

- name: Load database schema
run: './bin/rails db:create db:schema:load db:seed'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if this should actually be

Suggested change
run: './bin/rails db:create db:schema:load db:seed'
run: bundle exec rails db:create db:schema:load db:seed

- name: Load database schema
run: './bin/rails db:create db:schema:load db:seed'

- run: bundle exec rake rspec_chunked
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The coverage setup can still be used https://github.com/owen2345/rspec_chunked#coverage-merge-reports-when-using-simplecov but I backed out the CodeCov parts of this branch

pull_request:

env:
BUNDLE_CLEAN: true
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'm not sure if these are all still needed, but I left them from the migration

DISABLE_SIMPLECOV: true
RAILS_ENV: test
ALLOW_NOPAM: true
PAM_ENABLED: true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if the PAM stuff should go into a separate matrix job

PAM_DEFAULT_SERVICE: pam_test
PAM_CONTROLLED_SERVICE: pam_test_controlled
BUNDLE_WITH: 'pam_authentication'
CI_JOBS: ${{ matrix.ci_job }}/4
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This could fan out further, but I think the 4 like CircleCI uses seems to give enough speedup

- '2.7'
- '3.0'
- '3.1'
- '.ruby-version'
Copy link
Contributor Author

@nschonni nschonni Mar 6, 2023

Choose a reason for hiding this comment

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

Could also update the title to spell this out by overriding the name for the job

Suggested change
- '.ruby-version'
- '.ruby-version' # Currently set to 3.2

@nschonni
Copy link
Contributor Author

nschonni commented Mar 6, 2023

I've removed the CircleCI config completely, so the branch protection rules would need to be updated to merge this

@Gargron Gargron merged commit e594bb7 into mastodon:main Mar 7, 2023
29 checks passed
@nschonni nschonni deleted the github-action-importer branch March 7, 2023 03:52
@shleeable
Copy link
Contributor

image

What's the deal with this?

@nschonni
Copy link
Contributor Author

nschonni commented Mar 7, 2023

CircleCI was fanning out the jobs to 4 workers at once to speed up the completion. This is now happening on the GitHub Actions too, but it's more visible in the UI

@shleeable
Copy link
Contributor

I felt like this is just running the same job 4 times... but if it's on purpose that's fine.

@nschonni
Copy link
Contributor Author

nschonni commented Mar 7, 2023

Right, the name could probably be converted so something friendlier like "Ruby 3.0 Part 1 of 4"

@ClearlyClaire
Copy link
Contributor

The tests do not seem to be marked as required for merge anymore. Can that be changed?

@mjankowski
Copy link
Contributor

This is nice overall (circle ci to GH actions) even if visually kinda loud now. Well done.

I'm not at all a GH actions expert -- but I'm curious about the interaction of the build and test sections ... is it more or less the case that everything done in build will be done once and then (if successful) we advance to the matrix'd out test steps, where every command within test will be done once per matrix run and run "on" the env previously created in build?

If so -- is it possible to move anything else out of test and into build? Specifically:

  • Looks like the line of sudo apt-get install -y libicu-dev libidn11-dev appears in both setup and test. Is it necessary to run again in test if it's already run in build?
  • Could this line - sudo apt-get install -y ffmpeg imagemagick libpam-dev - be moved up into build? Seems like just installing linux packages not contingent on the ruby version matrix?

@nschonni
Copy link
Contributor Author

nschonni commented Mar 9, 2023

They're not reliant on the ruby version, but the runners for each of the matrix builds are new environments, so they need to be installed for each (if they're required).
There may be some optimizations around moving the PAM stuff to a single test run instead of running it for the whole matrix, but I wasn't confident enough on the testing to just a single version.

@nschonni
Copy link
Contributor Author

nschonni commented Mar 9, 2023

The tests do not seem to be marked as required for merge anymore. Can that be changed?

@ClearlyClaire if you have admin settings on the repo, I think the updated branch policy would look something like this
image
I think it can match against the generatl test instead of listing out all the jobs

rutvijmehta-harness pushed a commit to rutvijmehta-harness/mastodon that referenced this pull request Mar 19, 2023
rutvijmehta-harness added a commit to rutvijmehta-harness/mastodon that referenced this pull request Mar 19, 2023
Co-authored-by: Nick Schonning <nschonni@gmail.com>
arachnist pushed a commit to arachnist/mastodon that referenced this pull request Apr 4, 2023
skerit pushed a commit to 11ways/mastodon that referenced this pull request Jul 7, 2023
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.

None yet

6 participants