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

feat: add codecov to the project #3168

Merged
merged 35 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ec09642
add codecov to the project
vishvamsinh28 Aug 28, 2024
566c37b
wf
vishvamsinh28 Aug 28, 2024
a8814ec
wfef
vishvamsinh28 Aug 28, 2024
0a997a3
updated workflow
vishvamsinh28 Aug 28, 2024
cef181b
Merge branch 'master' into addCodecov
vishvamsinh28 Aug 30, 2024
6d4d293
add explicit commit id
vishvamsinh28 Aug 30, 2024
fd92de6
Merge branch 'addCodecov' of https://github.com/vishvamsinh28/website…
vishvamsinh28 Aug 30, 2024
7e2c409
Merge branch 'master' into addCodecov
vishvamsinh28 Aug 31, 2024
2791cfd
update workflow
vishvamsinh28 Aug 31, 2024
6a1f40f
update id
vishvamsinh28 Aug 31, 2024
451acf3
Merge branch 'master' into addCodecov
vishvamsinh28 Sep 5, 2024
347d752
remove flag
vishvamsinh28 Sep 7, 2024
859e9dc
Merge branch 'master' into addCodecov
vishvamsinh28 Sep 7, 2024
4ce435f
Merge branch 'addCodecov' of https://github.com/vishvamsinh28/website…
vishvamsinh28 Sep 7, 2024
f29052d
Merge branch 'master' into addCodecov
vishvamsinh28 Sep 11, 2024
af14485
Merge branch 'master' into addCodecov
anshgoyalevil Sep 13, 2024
354871b
updated test
vishvamsinh28 Sep 13, 2024
ca47e34
Merge branch 'master' into addCodecov
asyncapi-bot Sep 13, 2024
75d4483
Merge branch 'master' into addCodecov
asyncapi-bot Sep 13, 2024
9cc0dc1
remove flag
anshgoyalevil Sep 13, 2024
af99e29
fef
vishvamsinh28 Sep 13, 2024
e20d236
Merge branch 'master' into addCodecov
vishvamsinh28 Sep 14, 2024
fd57791
Update jest.config.js
vishvamsinh28 Sep 14, 2024
829c653
jest config update
vishvamsinh28 Sep 14, 2024
0bde97f
Merge branch 'master' into addCodecov
vishvamsinh28 Sep 16, 2024
d3541cb
fewf
vishvamsinh28 Sep 16, 2024
efe6ab9
Merge branch 'addCodecov' of https://github.com/vishvamsinh28/website…
vishvamsinh28 Sep 16, 2024
16f4651
Merge branch 'master' into addCodecov
asyncapi-bot Sep 18, 2024
37bea64
Merge branch 'master' into addCodecov
anshgoyalevil Sep 20, 2024
4a15cee
upated config for jest
vishvamsinh28 Sep 20, 2024
1643499
Merge branch 'addCodecov' of https://github.com/vishvamsinh28/website…
vishvamsinh28 Sep 20, 2024
8f79d8a
Merge branch 'master' into addCodecov
vishvamsinh28 Sep 23, 2024
3fe50cd
Merge branch 'master' into addCodecov
vishvamsinh28 Sep 28, 2024
6dab16d
Merge branch 'master' into addCodecov
vishvamsinh28 Sep 30, 2024
d745bb1
Merge branch 'master' into addCodecov
akshatnema Oct 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/if-nodejs-pr-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: "${{ steps.nodeversion.outputs.version }}"

- name: Install dependencies
run: npm ci
- if: steps.packagejson.outputs.exists == 'true'
Expand All @@ -72,3 +73,12 @@ jobs:
name: Run release assets generation to make sure PR does not break it
shell: bash
run: npm run generate:assets --if-present

- if: steps.packagejson.outputs.exists == 'true'
name: Upload Coverage to Codecov
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673
with:
fail_ci_if_error: true
files: ./coverage/lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
anshgoyalevil marked this conversation as resolved.
Show resolved Hide resolved
verbose: true
4 changes: 3 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
module.exports = {
verbose: true,
collectCoverage: true,
coverageReporters: ['text', 'lcov', 'json-summary'],
coverageDirectory: 'coverage',
collectCoverageFrom: ['scripts/**/*.js'],
Copy link
Member

Choose a reason for hiding this comment

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

Why did you remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't need that jest will only include files that are directly imported in our test files for coverage.

Copy link
Member

Choose a reason for hiding this comment

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

That's the case. Jest is now taking fixture files also into coverage, and that's wrong.

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 update it for excluding fixture files

Copy link

@coderabbitai coderabbitai bot Oct 15, 2024

Choose a reason for hiding this comment

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

💡 Codebase verification

Coverage reports are not being generated.

Despite collectCoverage being enabled in jest.config.js, the coverage directory does not exist. This indicates that coverage reports are not being generated as expected.

Please ensure that:

  • Tests are executed with coverage collection enabled.
  • The test scripts are correctly configured to generate coverage reports.
  • There are no errors during test execution that prevent coverage generation.
🔗 Analysis chain

Verify coverage collection configuration.

The current collectCoverageFrom configuration includes only 'scripts/**/*.js'. Based on the previous discussion in the comments, there was a concern about including 'fixture' files in the coverage reports.

Please verify if the current configuration sufficiently excludes 'fixture' files from coverage reports. If not, consider updating it to explicitly exclude these files.

To check if 'fixture' files are being included in coverage reports, you can run the following command after running your tests:

If 'fixture' files are found in the coverage report and you want to exclude them, you might want to update the collectCoverageFrom configuration to something like:

collectCoverageFrom: ['scripts/**/*.js', '!**/fixtures/**']

This will include all .js files in the 'scripts' directory and its subdirectories, but exclude any files in 'fixtures' directories.



</details>

<details>
<summary>🏁 Scripts executed</summary>

The following scripts were executed for the analysis:

Script:

```shell
#!/bin/bash
# Description: Check if 'fixture' files are included in coverage reports

# Look for 'fixture' files in the coverage report
grep -r "fixture" coverage/lcov-report

# If any 'fixture' files are found, they will be listed. 
# If no output is produced, it means no 'fixture' files are included in the coverage report.

Length of output: 92


Script:

#!/bin/bash
# Description: Check if coverage directory exists and list its contents

if [ -d "coverage" ]; then
  echo "Coverage directory exists. Listing contents:"
  ls -la coverage
else
  echo "Coverage directory does not exist."
fi

Length of output: 100


Script:

#!/bin/bash
# Description: Verify if coverage collection is enabled in jest.config.js

if grep -q "collectCoverage: true" jest.config.js; then
  echo "Coverage collection is enabled in jest.config.js."
else
  echo "Coverage collection is NOT enabled in jest.config.js."
fi

Length of output: 157


Script:

#!/bin/bash
# Description: Display the current collectCoverageFrom configuration in jest.config.js

grep "collectCoverageFrom" jest.config.js || echo "collectCoverageFrom is not defined in jest.config.js."

Length of output: 85


Script:

#!/bin/bash
# Description: Check if coverageDirectory is specified in jest.config.js

grep "coverageDirectory" jest.config.js || echo "coverageDirectory is not defined in jest.config.js. Default coverage directory is 'coverage'."

Length of output: 72


Script:

#!/bin/bash
# Description: Search for any coverage report directories other than the default 'coverage'

# Common coverage report directories
coverage_dirs=("coverage" "coverage-report" "lcov-report" "reports/coverage")

for dir in "${coverage_dirs[@]}"; do
  if [ -d "$dir" ]; then
    echo "Found coverage directory: $dir"
    ls -la "$dir"
  fi
done

# Additionally, search for any directories containing 'lcov' or 'coverage' in their names
fd --type d --glob '*coverage*' --glob '*lcov*' . 

Length of output: 430


Script:

#!/bin/bash
# Description: Verify if tests have been executed to generate coverage reports

# Check if jest has been run by looking for recent test-related scripts in package.json
grep '"test"' package.json || echo "No test scripts found in package.json."

# Alternatively, check Git history for recent test executions
git log -n 1 --pretty=format:"%H" -- "**/*.test.js" || echo "No recent test commits found."

# Check for recent modifications in jest.config.js
git log -n 1 --pretty=format:"%H" jest.config.js || echo "No recent changes to jest.config.js found."

Length of output: 248

Copy link
Member

Choose a reason for hiding this comment

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

coverage directory has been added in the .gitignore, hence it won't be part of repo. The coverage is generated everytime during github action run.

Copy link

Choose a reason for hiding this comment

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

@akshatnema, thank you for the clarification. I understand that the coverage directory is gitignored and coverage reports are generated during the GitHub Actions run. That makes sense.

(_/)
(o.O)


✏️ Learnings added
Learnt from: akshatnema
PR: asyncapi/website#3168
File: jest.config.js:6-6
Timestamp: 2024-10-15T17:44:59.028Z
Learning: In this repository, the `coverage` directory is added to `.gitignore`, and coverage reports are generated during GitHub Actions runs.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

// To disallow netlify edge function tests from running
testMatch: ['**/tests/**/*.test.*', '!**/netlify/**/*.test.*'],
};
};
anshgoyalevil marked this conversation as resolved.
Show resolved Hide resolved
Loading