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

Automatic Running of Tests On Pull Request #1123

Open
wants to merge 15 commits into
base: dev
Choose a base branch
from

Conversation

saifrk
Copy link
Collaborator

@saifrk saifrk commented Dec 5, 2024

**Fixes #1111 **

Your Name and others added 2 commits December 4, 2024 18:15
@saifrk
Copy link
Collaborator Author

saifrk commented Dec 10, 2024

A centralized logic has been implemented to streamline test execution across all workflows.
Continuous Execution:
Even if a test fails, the check doesn’t fail immediately.
It continues running other tests and, at the end, reports the total number of failed tests while marking the check as failed.
Naming Convention:
All tests beginning with tests_* are executed.
To add new tests, simply adhere to this naming convention.
Workflow Trigger

Workflow: Django Test Suite on PR
Trigger: Automatically triggered whenever a pull request (PR) is created or updated for the dev branch.
Workflow Steps

Checkout Merged Code:
The workflow checks out the merged code which combines:
The branch being merged .
The target branch (dev).
Purpose: Tests are executed on the post-merge state to ensure stability.
Set Up Environment:
Installs docker-compose.
Builds the Docker environment defined in local.yml.
Run Tests:
Executes the Django test suite which runs all test cases defined in the merged code.
Cleanup:
Cleans up Docker containers and volumes to free resources after tests finish.
Test Execution

1.Test Scope:

Executes all pytest tests defined in the repository.
Includes all files matching the naming convention tests_*.
2.Fail-Safe Mechanism:
Even if a test fails, all tests are executed.
At the end, it reports the number of failed tests and marks the workflow as failed if any test fails.
3.Feedback:
Results appear directly in the pull request as:
✅ All tests pass.
❌ Test failures are displayed with logs for debugging.
Key Change:

Previously, tests were executed on the branch being pushed, Integration issues with the target branch (e.g., dev) were not accounted for.
Now, Tests are executed on the merged code, this ensures the merged state is stable and prevents surprises post-merge.

@CarsonDavis
Copy link
Collaborator

Take a look at whether you can use https://github.com/NASA-IMPACT/COSMOS/blob/dev/pytest.ini as a way to handle what is being done in init.sh.

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.

Add Automatic Running of Tests On Pull Request
2 participants