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

How to end the rails started process to generate simplecov coverage report #508

Open
wagnerpereira opened this issue Feb 18, 2022 · 2 comments
Labels
type: enhancement New feature or request

Comments

@wagnerpereira
Copy link

I'm using Cypress to do system on our Rails application and simplecov to generate the coverage report, but simplecov only generate the reports when the rails server process is terminated with sucess exit(0).

https://github.com/cypress-io/github-action#start-server

...

- name: Cypress Run
  uses: cypress-io/github-action@v2
  env:
    CYPRESS_RAILS_PORT: 9999
    CYPRESS_BASE_URL: "http://localhost:9999/"
    COVERAGE: true
  with:
    start: bundle exec rails server -b 0.0.0.0 -p 9999
    wait-on: "http://localhost:9999"

...

Cypress suite test runs perfectly but in the end I didn't get the simplecov reports to be uploaded to codecov. I'm guessing this is because the "started" rails process was note terminated by the cypress github action.

e.g

^C- Gracefully stopping, waiting for requests to finish
=== puma shutdown: 2022-02-18 11:48:09 -0300 ===
- Goodbye!
Exiting
Coverage report generated to /Users/wagner/src/tia/coverage/coverage.xml. 1469 / 3460 LOC (42.46%) covered
Coverage report generated to /Users/wagner/src/tia/coverage. 1469 / 3460 LOC (42.46%) covered.

Any idea how to achieve this ? Get the simplecov report in the end of the cypress github action execution?

Thanks a lot in advance.

@wagnerpereira
Copy link
Author

Any way to stop/kill the with: start process after tests ends?

- name: Cypress Run
  uses: cypress-io/github-action@v2
  env:
    CYPRESS_RAILS_PORT: 9999
    CYPRESS_BASE_URL: "http://localhost:9999/"
    COVERAGE: true
  with:
    start: bundle exec rails server -b 0.0.0.0 -p 9999
    wait-on: "http://localhost:9999"

@wagnerpereira
Copy link
Author

Issue hacked with this "external" kill of the started process by cypress.io/github-actions. It should nice to have this inside the github action.

Check what I have to do to solve my issue.

      - name: Cypress Run
        uses: cypress-io/github-action@v3
        id: cypress
        env:
          DATABASE_URL: postgres://postgres:@localhost:5432/test
          REDIS_URL: redis://localhost:6379/0
          RAILS_ENV: test
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
          CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
          CYPRESS_BASE_URL: "http://localhost:9999/"
          COVERAGE: true
        with:
          project: ./spec
          record: true
          start: bundle exec rails server -b 0.0.0.0 -p 9999
          wait-on: "http://localhost:9999"

      - name: Stop Rails to generate coverage report
        run: |
          kill -2 `cat tmp/pids/server.pid`

      - name: Rename coverage report
        run: |
          while [ ! -f coverage/coverage.xml ]
          do
            sleep 2
          done
          mv coverage/coverage.xml coverage/coverage-e2e-tests.xml

      - name: Upload PR Coverage Report
        uses: codecov/codecov-action@v2
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          files: ./coverage/coverage-e2e-tests.xml
          flags: testes-integracao
          name: ${{ needs.setup.outputs.repo_name }}-${{ needs.setup.outputs.image_tag }}
          fail_ci_if_error: true
          verbose: true

It should be great if we have some thing like this. A way to customize and send the stop command.

      - name: Cypress Run
        uses: cypress-io/github-action@v3
        id: cypress
        env:
          DATABASE_URL: postgres://postgres:@localhost:5432/test
          REDIS_URL: redis://localhost:6379/0
          RAILS_ENV: test
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
          CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
          CYPRESS_BASE_URL: "http://localhost:9999/"
          COVERAGE: true
        with:
          project: ./spec
          record: true
          start: bundle exec rails server -b 0.0.0.0 -p 9999
          stop-command:  kill -2 `cat tmp/pids/server.pid`
          wait-on: "http://localhost:9999"

Thank you very much.

@emilyrohrbough emilyrohrbough added the type: enhancement New feature or request label Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants