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

added run dev server action to pull request workflow #1371

Merged
merged 3 commits into from
Aug 22, 2023
Merged

added run dev server action to pull request workflow #1371

merged 3 commits into from
Aug 22, 2023

Conversation

ishtails
Copy link
Contributor

@ishtails ishtails commented Aug 4, 2023

What kind of change does this PR introduce?
PR CI/CD workflow feature

Issue Number:
Fixes #1343

Did you add tests for your changes?
No.

Snapshots/Videos:
N/A

If relevant, did you update the documentation?
No

Summary

Added a final github action to run the dev server using "npm run dev" before finishing checks as suggested by issue #1343

Does this PR introduce a breaking change?
No

Other information
NA

Have you read the contributing guide?
Yes

@github-actions
Copy link

github-actions bot commented Aug 4, 2023

Our Pull Request Approval Process

We have these basic policies to make the approval process smoother for our volunteer team.

Testing Your Code

Please make sure your code passes all tests. Our test code coverage system will fail if these conditions occur:

  1. The overall code coverage drops below the target threshold of the repository
  2. Any file in the pull request has code coverage levels below the repository threshold
  3. Merge conflicts

The process helps maintain the overall reliability of the code base and is a prerequisite for getting your PR approved. Assigned reviewers regularly review the PR queue and tend to focus on PRs that are passing.

Reviewers

When your PR has been assigned reviewers contact them to get your code reviewed and approved via:

  1. comments in this PR or
  2. our slack channel

Reviewing Your Code

Your reviewer(s) will have the following roles:

  1. arbitrators of future discussions with other contributors about the validity of your changes
  2. point of contact for evaluating the validity of your work
  3. person who verifies matching issues by others that should be closed.
  4. person who gives general guidance in fixing your tests

CONTRIBUTING.md

Read our CONTRIBUTING.md file. Most importantly:

  1. PRs with issues not assigned to you will be closed by the reviewer
  2. Fix the first comment in the PR so that each issue listed automatically closes

Other

  1. 🎯 Please be considerate of our volunteers' time. Contacting the person who assigned the reviewers is not advised unless they ask for your input. Do not @ the person who did the assignment otherwise.
  2. Read the CONTRIBUTING.md file make

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Congratulations on making your first PR! 🎊 If you haven't already, check out our Contributing Guidelines and PR Reporting Guidelines to ensure that you are following our guidelines for contributing and creating PR.

@ishtails
Copy link
Contributor Author

ishtails commented Aug 4, 2023

I have added a job that runs the dev server after testing is finished. Is there anything that I am missing? if so, let me know and i will make the required changes

@codecov
Copy link

codecov bot commented Aug 4, 2023

Codecov Report

Merging #1371 (4f8f83a) into develop (c0468a4) will not change coverage.
Report is 3 commits behind head on develop.
The diff coverage is n/a.

❗ Current head 4f8f83a differs from pull request most recent head 3228b3b. Consider uploading reports for the commit 3228b3b to get more accurate results

@@           Coverage Diff            @@
##           develop    #1371   +/-   ##
========================================
  Coverage    98.17%   98.17%           
========================================
  Files          184      184           
  Lines        10767    10767           
  Branches       835      835           
========================================
  Hits         10571    10571           
  Misses         186      186           
  Partials        10       10           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ishtails
Copy link
Contributor Author

ishtails commented Aug 5, 2023

Can i get some help with the checks not passing? @palisadoes

  • first check seems to say that i am not authorized to make changes to workflow files. is that so?
  • dev server run workflow fails due to some kind of env issue i am guessing. do i need to configure env beforehand?

@palisadoes
Copy link
Contributor

  1. Yes, we flag changes to workflow and other key files so that the approvers can be extra vigilant.
  2. Yes, you'll need to setup a .env file environment variable. Try setting up the API on your local machine to understand all the steps required. This is specifically why we created this issue to make sure the API would run correctly after each PR.

@ishtails
Copy link
Contributor Author

ishtails commented Aug 6, 2023

I have setup up a separate job for running dev server with dummy variables that worked on local setup, so i am assuming it should work on the workflow as well. let me know if i need to change anything

Comment on lines 171 to 176
- name: Sleep for 10s
uses: juliangruber/sleep-action@v1
with:
time: 10s

Copy link
Member

Choose a reason for hiding this comment

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

why we need to wait for 10 seconds, is there anything that will break without it ? @ishtails

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 don't believe we need to wait, but this sleep command was there in the test job as well before running tests, so I put it here to be on the safe side, as I felt it might be there for some specific reason...

Copy link
Contributor

Choose a reason for hiding this comment

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

@ishtails github actions steps are run in series are they not? So idk what we're waiting 10 seconds for.

Anyway a clean way to test whether server successfully starts or stops is listening for node.js events. The useful events would be the listening, close and error events. You would listen to these events to determine if server successfully starts, stops or errors out in between the process.

This can be done by importing the server instance in a test file created for this test case and checking for those events. When and where you choose to run this particular test case is upto you to decide.

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 will remove the sleep command from the job then, I also believe it is not required.

That is a good idea, to write a test for it. However I don't have any experience writing tests as of now. Can we have it as a separate issue maybe? So that either someone else could write the test for it, or I could just do it in the future.

Copy link
Contributor

@xoldd xoldd Aug 18, 2023

Choose a reason for hiding this comment

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

@ishtails It seems there are some oddities about github actions that I wasn't aware about. The 10 second wait seems to be done for the server to successfully start because the workflow doesn't wait for the server to successfully start I guess? Or the the npm run dev gives the successful status code without it actually being successful, for example doing things asynchronously. Something like that.

Also an action just to check if the server successfully starts seems wasteful, it'd be better to have this as a part of some end to end test workflow. For example this action https://github.com/PalisadoesFoundation/talawa-api/blob/develop/.github/workflows/push-documentation.yml already makes use of npm run dev. Starting the server itself doesn't tell us anything about whether all the services of the server are working perfectly.

Copy link
Contributor Author

@ishtails ishtails Aug 19, 2023

Choose a reason for hiding this comment

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

I am unaware of any such issues. Let me know if I should put the sleep command there or not...
If someone could explain the need for it, it would be really nice.

The issue originally just stated that there should be a job to check if the dev server starts or not, shouldn't the check passing or failing mean that the server started successfully or failed to start anyway? If not, How can I modify it to verify the status of services running in here?

Copy link
Contributor

@xoldd xoldd left a comment

Choose a reason for hiding this comment

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

Whether this job provides any value I'm not too sure. Anyway the configuration seems to be correct so it's okay to merge.

Copy link
Member

@noman2002 noman2002 left a comment

Choose a reason for hiding this comment

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

I also agree with @xoldyckk that if this add any value or not, but the changes looks good to me.

@palisadoes
Copy link
Contributor

@xoldyckk @noman2002 We created the issue because there were times when the PR tests passed, but the application would not start. Some contributors would make modifications to the code to to satisfy the code coverage requirements, but ignored the usability. This is to help prevent such short sighted work.

@palisadoes palisadoes merged commit 31f7a3a into PalisadoesFoundation:develop Aug 22, 2023
3 of 4 checks passed
palisadoes added a commit that referenced this pull request Aug 22, 2023
@palisadoes
Copy link
Contributor

This has to be reverted. There is a syntax error.

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.

CI/CD : Check for Starting a Server.
4 participants