Shopify / shipit-engine

Deployment coordination
https://shopify.engineering/introducing-shipit
MIT License
1.41k stars 145 forks source link

Overriding all tasks #527

Open teu opened 8 years ago

teu commented 8 years ago

Hi,

out deployment cycle relies fully on capistrano, I basically only need shipit to fetch the specific repository. Is there a way to override all shipit events and just run one shell command?

Thanks

byroot commented 8 years ago

Actually wait. It's blowing up in the controller, which mean it was inserted fine in the DB but now it can't encode it in JSON.

byroot commented 8 years ago

What database are you using?

teu commented 8 years ago

RDS mysql 5.6 character set utf8 collate utf8_general_ci

byroot commented 8 years ago

Ok, by googling a but I found people with similar issues: https://github.com/JoshCheek/seeing_is_believing/issues/46#issuecomment-69007428

I think that might be an actual bug that we are not experiencing because we have LANG=en_US.UTF-8. I'll try to reproduce this.

teu commented 8 years ago

Will try to set locale tomorrow. Midnight here.

teu commented 8 years ago

Set the locale system wide and restarted apache (passenger). No change.

byroot commented 8 years ago

yeah sorry, I was about to update to say I can reproduce without changing LANG.

byroot commented 8 years ago

Reproducing is basically as simple as:

>> JSON.dump(Shipit::Command.new("echo test √ test", chdir: '.').run)
Encoding::UndefinedConversionError: "\xE2" from ASCII-8BIT to UTF-8

What I don't understand though it that we do handle this already here: https://github.com/Shopify/shipit-engine/blob/fd3ce935a20163cf7dd39b3dfa5d0731a848e632/app/models/shipit/output_chunk.rb#L8

>> JSON.dump(Shipit::Command.new("echo test √ test", chdir: '.').run.force_encoding(Encoding::UTF_8).scrub)
=> "\"test √ test\\r\\n\""

So there is something fishy here :/

byroot commented 8 years ago

Ok, so one possibility would be the usual utf8 vs utf8mb4 MySQL shenanigans.

If you have say, and emoji in your output, it's very possible it got truncated by MySQL.

teu commented 8 years ago

Perhaps I should create a database with a different encoding then?

byroot commented 8 years ago

Well, I haven't tested yet to confirm it's indeed this. But it's recommended to use utf8mb4 with Shipit. People have a tendency to put emojis in commit messages or build outputs.