Skip to content

Commit 9991193

Browse files
authored
Skip GitHub E2E Tests for Forked Repositories (#1887)
* Add contributor check for GitHub Action tests * Fowrk owner always has a valud, so we can remove the check for it.
1 parent 18f7e9c commit 9991193

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ jobs:
3737
RUNME_PROJECT: ${{ github.workspace }}
3838
SHELL: bash
3939
GITHUB_ACTOR: ${{ github.actor }}
40+
GITHUB_EVENT_NAME: ${{ github.event_name }}
41+
FORK_OWNER: ${{ github.event.pull_request.head.repo.owner.login }}
42+
BASE_OWNER: ${{ github.repository_owner }}
4043
- name: 🔼 Upload Artifacts
4144
uses: actions/upload-artifact@v4
4245
if: failure()

tests/e2e/specs/githubAction.e2e.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,29 @@ const UI_LATENCY_TIMEOUT_SECS = 2 * 60 * 1000
77

88
describe('Runme GitHub Workflow Integration', async () => {
99
const notebook = new RunmeNotebook()
10-
const token = process.env.RUNME_TEST_TOKEN
10+
const token = process.env.RUNME_TEST_TOKEN || ''
11+
const actor = process.env.GITHUB_ACTOR
12+
const eventName = process.env.GITHUB_EVENT_NAME
13+
const baseOwner = process.env.BASE_OWNER || ''
14+
const forkOwner = process.env.FORK_OWNER || ''
1115

1216
/**
1317
* Skip GitHub Action tests for local testing due to missing token
1418
*/
1519
if (
1620
(!token && !process.env.CI) ||
1721
process.env.NODE_ENV === 'production' ||
18-
process.env.GITHUB_ACTOR === 'dependabot[bot]'
22+
actor === 'dependabot[bot]'
1923
) {
2024
return
2125
}
2226

27+
// Skip tests only if PR is from external fork
28+
if (eventName === 'pull_request' && forkOwner !== baseOwner) {
29+
console.log('Skipping GitHub Workflow Integration tests for pull request from external fork.')
30+
return
31+
}
32+
2333
it('has GitHub test token defined in the environment', async () => {
2434
expect(token).toBeDefined()
2535
})

0 commit comments

Comments
 (0)