Skip to content

feat: ignore test paths #8

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

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Changes from 1 commit
Commits
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
5 changes: 5 additions & 0 deletions codeql-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ query-filters:
id: js/missing-rate-limiting
- exclude:
id: js/missing-token-validation
paths-ignore:
- '**/test*'
- '**/__test__/**'
- '**/__tests__/**'
- '**/*test.*'
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, looking at https://github.com/search?q=org%3Aopengovsg+path%3A*test*&type=code I see a couple of matches like:

The rest that are in this search would be matched by the folder rules or maybe an additional folder:

- '**/test/*'
- '**/tests/*'

Would this make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to clarify is this what youre proposing?

- '**/*test*'
- '**/test/*'
- '**/tests/*'

I think that makes sense

Copy link
Contributor

@spaceraccoon spaceraccoon Dec 12, 2024

Choose a reason for hiding this comment

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

Yep! Actually just the foldernames

Copy link
Contributor Author

@zhongliang02 zhongliang02 Dec 16, 2024

Choose a reason for hiding this comment

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

Ok I figured out a way to test across all repos and I tested with

- '**/test/*'
- '**/tests/*'
- '**/__test__/*'
- '**/__tests__/*'

There are still some paths that are considered tests by AI and not covered

Test File Type Frequency Pattern Examples
Unit Tests High *.test.ts, *.test.tsx, *.test.js FormSG/frontend/src/features/admin-form/responses/FeedbackPage/utils/FeedbackCsvGenerator.test.ts
bright/src/pages/api/external/dev/sftp-aic360-test.ts
End-to-End Tests Medium *.e2e.test.ts, playwright/*.test.ts bright/playwright/auth.e2e.test.ts
isomer/apps/studio/playwright/smoke.test.ts
Configuration Files Medium vitest.config.ts, jest-testcontainers-config.js FormSG/frontend/vitest.config.ts
hms/packages/backend/jest-testcontainers-config.js
CI/CD Test Workflows Medium .github/workflows/*test*.yml hms/.github/workflows/coverage_tests.yml
bright/.github/workflows/build_and_test.yml
Test Utilities Low test-utils.tsx, testing.utils.ts FormSG/frontend/src/test-utils.tsx
hms/packages/backend/src/modules/database/testing.utils.ts
Database Migrations for Tests Low *-test-*.ts (in migrations folders) hms/packages/backend/src/modules/database/migrations/1719079410866-test-result-updatedat.ts
Load Tests Low load-tests/*.test.ts phas/load-tests/src/get-public-appointments.test.ts
refer/load-test/src/pb.test.ts
Test Data/Fixtures Very Low testing.fixtures.ts hms/packages/backend/src/modules/database/testing.fixtures.ts
Mock Data Very Low *.mock.ts (inferred, not explicitly seen) (No explicit examples found in the provided list)
Visual Regression Tests Very Low visual-regression-tests.cy.js askgov/cypress/e2e/visual-regression-tests.cy.js
Smoke Tests Very Low smoke.test.ts, smoke.e2e.test.ts bright/playwright/smoke.e2e.test.ts
pixie/playwright/smoke.test.ts

Of the above, I think we should add the unit tests and the playwright tests to the exclusion list with *.test.*

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense!

Loading