COVID-19-electronic-health-system / Corona-tracker

An easy-to-use PWA to monitor the user's wellness and learn about COVID-19.
https://coronatracker.me/
MIT License
235 stars 101 forks source link

Update travis.yml to run separate commands #693

Closed whoabuddy closed 4 years ago

whoabuddy commented 4 years ago

⚠️ IMPORTANT: Please do not create a Pull Request without creating an Issue first.

All changes need to be discussed before proceeding. Failure to do so may result in the pull request being rejected.

Before submitting a pull request, please be sure to review:


Please include the issue number the pull request fixes by replacing YOUR-ISSUE-HERE in the text below.

Fixes #692

Summary

This pull request updates the formatting of the travis.yml file to ensure each command is run individually.

Details

I am not a Travis CI pro so a thorough review is appreciated, but from the way I understand it, the changes to this file should fix the build process.

Test Plan (required)

Creating the PR to see if it affects the Travis CI build, otherwise I will need help for the best way to test/deploy this.

Final Checklist

whoabuddy commented 4 years ago

This appears to have solved the problem of the commands running separately, however I am still getting some build errors that I saw when trying to build locally as well.

Yarn has some trouble with the dependency canvas:

error /home/travis/build/COVID-19-electronic-health-system/Corona-tracker/client/node_modules/canvas: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build
Arguments: 
Directory: /home/travis/build/COVID-19-electronic-health-system/Corona-tracker/client/node_modules/canvas

and

node-pre-gyp http GET https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.6.1/canvas-v2.6.1-node-v83-linux-glibc-x64.tar.gz
node-pre-gyp http 404 https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.6.1/canvas-v2.6.1-node-v83-linux-glibc-x64.tar.gz
node-pre-gyp WARN Tried to download(404): https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.6.1/canvas-v2.6.1-node-v83-linux-glibc-x64.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for canvas@2.6.1 and node@14.2.0 (node-v83 ABI, glibc) (falling back to source compile with node-gyp) 
node-pre-gyp http 404 status code downloading tarball https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.6.1/canvas-v2.6.1-node-v83-linux-glibc-x64.tar.gz 

Yarn also had trouble with pangocairo via pkg-config:

Package pangocairo was not found in the pkg-config search path.
Perhaps you should add the directory containing `pangocairo.pc'
to the PKG_CONFIG_PATH environment variable

I'm not sure how to fix this on Travis CI, but on my local machine (Linux Mint / Ubuntu-based), I ran the following, and afterward the errors above were gone:

sudo apt-get install libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev

Hopefully that helps!

SomeMoosery commented 4 years ago

I'm just a bit confused - is this fixing any tests / pipeline stuff? Or is this more of a cosmetic change. Either way it looks good, but I want to be sure

whoabuddy commented 4 years ago

Yes, this fixes how Travis CI runs the commands, which currently are getting bunched together based on syntax.

Regarding the dependency issues in Ubuntu, there is an article here that outlines how to fix it, and I'm testing that out now as part of this PR.

This is more of an overall change versus something specific to what caused the build to fail, but I think it will lead to a more consistent experience with the testing. If you look at the output in my initial issue you can see how things weren't running 100% correctly based on the commands provided versus the console output.

whoabuddy commented 4 years ago

Ok, so not sure what happened on the last Travis CI check as the logs are null, but I got it back to passing status. Here's a more detailed version of what I fixed now that I know the fix worked!

  1. The Travis CI setup relies on Ubuntu, which requires a few extra dependencies before it can successfully build the project. Those are listed in the first post above and in the final config file.
  2. The Travis CI YAML file was not recognizing commands as separate commands, and rather stringing them together. For example:
before_install:
  npm -g install yarn
  npm install -g jest-dom
  npm install -g react-scripts

Was actually being run as:

npm -g install yarn npm install -g jest-dom npm install -g react-scripts

There are two ways to fix this, one is to use && at the end of each line, so the result is:

npm -g install yarn && npm install -g jest-dom && npm install -g react-scripts

But that gets hard to debug in the long run, so instead we can use a hyphen - to separate the commands, like this:

before_install:
  - npm -g install yarn
  - npm install -g jest-dom
  - npm install -g react-scripts

So when they run in Travis CI, the result is:

npm -g install yarn
npm install -g jest-dom
npm install -g react-scripts

In addition to that, several packages are required in order to build the app on Ubuntu, which is now taken care of as part of the before_install procedure using the two lines below:

before_install:
  - sudo apt-get update
  - sudo apt-get -y install build-essential cmake libcairo2-dev libpango1.0-dev libssl-dev    - sudo apt-get -y install build-essential cmake libcairo2-dev libpango1.0-dev libssl-dev libjpeg-dev libgif-dev librsvg2-dev

I also added npm install -g canvas since that was required on my system, and part of what requires the additional packages above in order to build.

Everything passed this time around, so this should help others efficiently test everything and make sure the errors we see are real errors! :upside_down_face: :heavy_check_mark:

SomeMoosery commented 4 years ago

Sounds good! Just needs 1 more approval