Skip to content

Check tests exist before running#56

Merged
iMattPro merged 1 commit intophpbb-extensions:3.3.xfrom
iMattPro:checktests
Jun 12, 2025
Merged

Check tests exist before running#56
iMattPro merged 1 commit intophpbb-extensions:3.3.xfrom
iMattPro:checktests

Conversation

@iMattPro
Copy link
Copy Markdown
Contributor

No description provided.

@iMattPro iMattPro force-pushed the checktests branch 2 times, most recently from 4382fb3 to 8697663 Compare June 11, 2025 20:03
@iMattPro
Copy link
Copy Markdown
Contributor Author

Co-Pilot says:

This diff introduces a set of improvements to the .github/workflows/tests.yml GitHub Actions workflow for the phpbb-extensions/test-framework repository. Here’s a summary and review of the changes:


Summary of Changes

  1. Basic Check for Unit Tests

    • New Step Added: A new step named Check for unit tests is added under the basic-checks job. It checks whether a tests directory exists inside the extension’s directory.
    • Output Set: The step sets an output has-tests to true if the directory exists, false otherwise.
    • Job Outputs: The basic-checks job is updated to output has-tests based on the above check.
  2. Conditional Job Execution

    • Several jobs (mysql-tests, postgres-tests, other-tests, windows-tests) now:
      • Depend on the basic-checks job via needs: basic-checks.
      • Add a new if condition: The job only runs if both its original input condition (e.g., RUN_MYSQL_JOBS == '1') is met and the has-tests output from basic-checks is true.

    For example:

    needs: basic-checks
    if: ${{ inputs.RUN_MYSQL_JOBS == '1' && needs.basic-checks.outputs.has-tests == 'true' }}

Review

Pros

  • Efficiency: If the extension does not have a tests directory, the database test jobs (MySQL, PostgreSQL, MSSQL, Windows) are skipped, saving CI resources and reducing execution time.
  • Clarity: The logic for whether to run tests is now explicit and centralized in the basic-checks job.
  • Modular: This approach makes it easy to add similar conditional jobs in the future.

Cons / Considerations

  • Specificity: The logic only checks for the existence of a tests directory; it does not check if any actual tests are present or if they are valid. (This is usually sufficient for most setups, but could be enhanced if needed.)
  • Job Dependency: All test jobs now depend on basic-checks, so if basic-checks fails or is slow, downstream jobs will be delayed or skipped.
  • Backward Compatibility: If there are extensions with non-standard test layouts, they may not be detected.

Conclusion

This is a practical and well-implemented improvement to the workflow. It will help conserve CI resources by avoiding unnecessary test runs when no tests are present. The implementation is clean and leverages GitHub Actions features effectively.

Recommendation:
Approve the change. If future enhancements are needed, consider checking for actual test files or supporting custom test directory locations.

@iMattPro iMattPro merged commit d442188 into phpbb-extensions:3.3.x Jun 12, 2025
1 check passed
@iMattPro iMattPro deleted the checktests branch June 12, 2025 03:34
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.

1 participant