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

Add CI jobs for ESLint and Typescript checks #1439

Merged
merged 13 commits into from
Oct 7, 2022

Conversation

micheal-parks
Copy link
Member

@micheal-parks micheal-parks commented Oct 5, 2022

This PR adds CI jobs for ESLint and Typescript. As an immediate follow-up we should make these checks required to merge.

This PR also syncs our ESLint rules with App and cleans up any issues that arose after syncing.

Note: a lot of types, primarily robot component statuses, are still super broken. I had to place a bunch of band-aids on them for now until we can properly refactor. If people introduce breaking changes to statuses, they will still break the client silently.

@CLAassistant
Copy link

CLAassistant commented Oct 5, 2022

CLA assistant check
All committers have signed the CLA.

@micheal-parks micheal-parks self-assigned this Oct 5, 2022
@Otterverse
Copy link
Member

Is there a reason this needs to be a separate CI job instead of just modifying one or two lines in the lint-web target where we're already running pretty much the same thing? I'd much prefer to keep this sort of stuff as makefile targets so it's easy for people to run things locally when testing.

@micheal-parks
Copy link
Member Author

@Otterverse I've made them separate jobs to both align with APP and to offer a good UX when submitting PRs. If there's an issue with ESLint or Typechecking then the author gets immediate feedback:
Screen Shot 2022-10-06 at 13 52 34

The author is also allowed to immediately go to details about the failure that are isolated from all other jobs:
https://github.com/viamrobotics/rdk/actions/runs/3197572913/jobs/5220968162

This allows us to minimize any red herrings or distractions from real issues. If you have any suggestions for alternate ways to do this, I'm into it since I'm by no means a CI expert 😂

I'm happy to make these commands makefile targets as well. The only reason I didn't is that people working on the frontend usually use npm directly instead of make. For instance:

npm start - to start the development server
npm run lint - to run eslint
npm run check - to typecheck
...etc

But if you think that people will find value in running these from make instead, I'd be happy to add them in this PR and have the CI jobs reference them instead.

@Otterverse
Copy link
Member

@micheal-parks So my first concern is that while "people working on the frontend" might do it differently, everyone that works in this codebase has to be able to pass the tests, and there's been lots of confusion lately how the frontend ends up failing tests when "I didn't touch it in my PR!" but because it auto-generates code during build, it's decided to switch an API version or something when it pulls from upstream. So in order to submit anything in RDK, people have to be able to run everything here, even if they aren't a frontend dev. Makefiles also act as a form of documentation, so that new devs can see what commands are typically used in a codebase, and can make it easier to figure out... this is doubly important now that we're open source and our stuff is going to be used by external devs figuring it out for the first time.

My second concern is that we're already running buf-web and lint-web targets that do most of this in the main "build lint" test step, and duplicating that just slows down the whole CI process. I'd really like to avoid duplicating work as much as possible. PR test runs already take long enough as-is.

Please understand, it's not that your one request here is the whole of the issue... This is only duplicating about 2 minutes worth of steps, but those add up... and I'm just trying to fight the trend of tests getting longer and longer.

Side note: I'm really hoping to talk people into doing this: https://viam.atlassian.net/browse/PRODUCT-265 (separate UI code into it's own repo, so both app and rdk pull from there, instead of just rdk>>app.)

All that said, it sounds like the main reason you want these isolated is so it's easier to see the output for this step alone. Would it be reasonable to make these seperate steps in the main test job? E.g. instead of running "build lint" that does everything, split it up into steps that do "buf-go, lint-go, buf-web, lint-web, typecheck (if that's not part of lint-web?)" Then nothing we be duplicated, and you'd still have separate steps to pick out the output from.

@micheal-parks
Copy link
Member Author

So my first concern...

yep! sounds good. Will add corresponding makefile commands here.

I'd really like to avoid duplicating work...

Yep. I'm very much against long CI or inefficient tasks. I think that quick CI and deploy times ensures a fast debug loop and therefore a healthy development environment. The two new tasks, eslint and typecheck usually are very fast (taking less than 2-3 minutes) and should remain that way even as the app scales. These tasks also should always be able to be run in parallel. Furthermore, once we entirely build our proto to JS files elsewhere and ship them to NPM these tasks should become even lower energy (the PRIME repo completes them usually in 30s).

main reason you want these isolated is so it's easier to see the output for this step alone...

Absolutely. Two goals: Typechecking and ES Linting should be two distinct checks or x's that are reported here on the main page. This is because they're two absolutely essential steps to ensure continuation of good code health for our UI. If you have any suggestions for doing this more efficiently I'm happy to follow them. Is your suggestion how we currently do it on app? I'm trying to reproduce that exactly here.

@micheal-parks
Copy link
Member Author

@Otterverse Just updated CI jobs to use make commands! Is something like this what you had in mind?

Copy link
Member

@DTCurrie DTCurrie left a comment

Choose a reason for hiding this comment

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

@Otterverse
Copy link
Member

@Otterverse Just updated CI jobs to use make commands! Is something like this what you had in mind?

It is, vis-a-vis the makefile targets. The other part of what I was suggesting was to break up the current step that is "verify no uncommitted changes from "make build lint" into separate steps for build-go, lint-go, build-web (which includes buf) and then lint-web (which should be eslint as you're doing it here, modifying if needed) and finally adding typecheck. This would be instead of having them as separate jobs, thus avoiding duplicated work.

The new jobs you're adding are also duplicating the buf-web stuff of each other. That matters less than the fact that spinning up an instance for a test (with the code checkout and everything, plus cleanup afterwards) is actually the bulk of the work.

All that said... I think this is a bigger issue in overall testing layout, not just something to solve here. For now, I'm gonna review and let this move forward, and have a bigger talk in devops with others about how to lay out and optimize all this, and possibly rearrange in the future.

Copy link
Member

@Otterverse Otterverse left a comment

Choose a reason for hiding this comment

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

One minor thing about a label check that's unneeded, otherwise looking fine for now (per my larger comment in the conversation.)

.github/workflows/pullrequest.yml Outdated Show resolved Hide resolved
.github/workflows/pullrequest.yml Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

github-actions bot commented Oct 7, 2022

Code Coverage

Package Line Rate Health
go.viam.com/rdk/components/arm 59%
go.viam.com/rdk/components/arm/universalrobots 12%
go.viam.com/rdk/components/arm/xarm 2%
go.viam.com/rdk/components/arm/yahboom 7%
go.viam.com/rdk/components/audioinput 55%
go.viam.com/rdk/components/base 68%
go.viam.com/rdk/components/base/agilex 62%
go.viam.com/rdk/components/base/boat 41%
go.viam.com/rdk/components/base/wheeled 76%
go.viam.com/rdk/components/board 69%
go.viam.com/rdk/components/board/arduino 10%
go.viam.com/rdk/components/board/commonsysfs 47%
go.viam.com/rdk/components/board/fake 39%
go.viam.com/rdk/components/board/numato 19%
go.viam.com/rdk/components/board/pi 50%
go.viam.com/rdk/components/camera 66%
go.viam.com/rdk/components/camera/fake 67%
go.viam.com/rdk/components/camera/ffmpeg 71%
go.viam.com/rdk/components/camera/transformpipeline 74%
go.viam.com/rdk/components/camera/videosource 57%
go.viam.com/rdk/components/encoder/fake 77%
go.viam.com/rdk/components/gantry 68%
go.viam.com/rdk/components/gantry/multiaxis 84%
go.viam.com/rdk/components/gantry/oneaxis 86%
go.viam.com/rdk/components/generic 85%
go.viam.com/rdk/components/gripper 82%
go.viam.com/rdk/components/input 86%
go.viam.com/rdk/components/input/gpio 87%
go.viam.com/rdk/components/motor 82%
go.viam.com/rdk/components/motor/dmc4000 69%
go.viam.com/rdk/components/motor/fake 59%
go.viam.com/rdk/components/motor/gpio 62%
go.viam.com/rdk/components/motor/gpiostepper 53%
go.viam.com/rdk/components/motor/tmcstepper 65%
go.viam.com/rdk/components/movementsensor 67%
go.viam.com/rdk/components/movementsensor/cameramono 39%
go.viam.com/rdk/components/movementsensor/gpsnmea 37%
go.viam.com/rdk/components/movementsensor/gpsrtk 28%
go.viam.com/rdk/components/posetracker 88%
go.viam.com/rdk/components/sensor 88%
go.viam.com/rdk/components/sensor/ultrasonic 31%
go.viam.com/rdk/components/servo 77%
go.viam.com/rdk/config 77%
go.viam.com/rdk/control 57%
go.viam.com/rdk/data 78%
go.viam.com/rdk/grpc 25%
go.viam.com/rdk/ml 67%
go.viam.com/rdk/ml/inference 70%
go.viam.com/rdk/motionplan 71%
go.viam.com/rdk/operation 93%
go.viam.com/rdk/pointcloud 70%
go.viam.com/rdk/protoutils 74%
go.viam.com/rdk/referenceframe 78%
go.viam.com/rdk/registry 88%
go.viam.com/rdk/resource 85%
go.viam.com/rdk/rimage 78%
go.viam.com/rdk/rimage/depthadapter 94%
go.viam.com/rdk/rimage/transform 73%
go.viam.com/rdk/rimage/transform/cmd/extrinsic_calibration 67%
go.viam.com/rdk/robot 93%
go.viam.com/rdk/robot/client 79%
go.viam.com/rdk/robot/framesystem 68%
go.viam.com/rdk/robot/impl 80%
go.viam.com/rdk/robot/server 59%
go.viam.com/rdk/robot/web 61%
go.viam.com/rdk/robot/web/stream 87%
go.viam.com/rdk/services/armremotecontrol 75%
go.viam.com/rdk/services/armremotecontrol/builtin 25%
go.viam.com/rdk/services/baseremotecontrol 75%
go.viam.com/rdk/services/baseremotecontrol/builtin 71%
go.viam.com/rdk/services/datamanager 62%
go.viam.com/rdk/services/datamanager/builtin 80%
go.viam.com/rdk/services/datamanager/datacapture 34%
go.viam.com/rdk/services/datamanager/datasync 70%
go.viam.com/rdk/services/motion 68%
go.viam.com/rdk/services/motion/builtin 89%
go.viam.com/rdk/services/navigation 54%
go.viam.com/rdk/services/sensors 78%
go.viam.com/rdk/services/sensors/builtin 97%
go.viam.com/rdk/services/shell 15%
go.viam.com/rdk/services/slam 86%
go.viam.com/rdk/services/slam/builtin 75%
go.viam.com/rdk/services/vision 82%
go.viam.com/rdk/services/vision/builtin 74%
go.viam.com/rdk/spatialmath 85%
go.viam.com/rdk/subtype 96%
go.viam.com/rdk/utils 71%
go.viam.com/rdk/vision 25%
go.viam.com/rdk/vision/chess 80%
go.viam.com/rdk/vision/delaunay 87%
go.viam.com/rdk/vision/keypoints 92%
go.viam.com/rdk/vision/objectdetection 83%
go.viam.com/rdk/vision/odometry 60%
go.viam.com/rdk/vision/odometry/cmd 0%
go.viam.com/rdk/vision/segmentation 48%
go.viam.com/rdk/web/server 26%
Summary 66% (18980 / 28660)

Copy link
Member

@Otterverse Otterverse left a comment

Choose a reason for hiding this comment

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

LGTM!

@micheal-parks micheal-parks merged commit 91d9d0c into viamrobotics:main Oct 7, 2022
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.

4 participants