[RAPTOR-15429] Skip Functional Tests for Fork PRs and Guide Contributors#373
Conversation
There was a problem hiding this comment.
Pull request overview
This PR modifies the GitHub Actions workflow to skip functional tests for pull requests originating from forked repositories. The change aims to prevent functional tests from running on fork PRs where repository secrets (like DATAROBOT_API_TOKEN and DATAROBOT_WEBSERVER) would not be available.
Key Changes
- Added a condition to the
run-functional-testjob that prevents execution when the PR comes from a fork - Restructured the existing conditional logic with proper parentheses grouping for clarity
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
.github/workflows/workflow.yml
Outdated
| github.event.comment.body == null || | ||
| (github.event.issue.pull_request && contains(github.event.comment.body, '$FUNCTIONAL_TESTS=')) | ||
| ) && | ||
| (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork != true) |
There was a problem hiding this comment.
The condition uses != true to check if a PR is not from a fork. In GitHub Actions, when the event is not a pull_request (e.g., push events, issue_comment events), the property github.event.pull_request.head.repo.fork may be null or undefined. While null != true evaluates to true in JavaScript, this implicit behavior can be unclear and error-prone.
Consider using a more explicit check such as github.event.pull_request.head.repo.fork == false or restructure the condition to be more clear about handling non-PR events first.
| (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork != true) | |
| (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false) |
There was a problem hiding this comment.
I do not agree with you. because if event is not a pull request, it will be caught in the first block 'github.event_name != 'pull_request' and the condition is met.
However I apply your suggestion as I want my code be clean and explicit.
Description
Functional test need secrets and for security reasons secrets can not be shared between fork and the main repository.
In addition, we can not use the secrets of the main repository for testing the fork as it has security issues.
The logic of CI is changed as the following:
If the PR is in the main repo, main repo secrets would be used for running the functional test.
If PR is in the fork, function test would run on fork using user secrets and will be skipped in the main repo.
https://datarobot.atlassian.net/browse/RAPTOR-15429