Skip to content

Commit

Permalink
Skip GitHub E2E Tests for Forked Repositories (#1887)
Browse files Browse the repository at this point in the history
* Add contributor check for GitHub Action tests

* Fowrk owner always has a valud, so we can remove the check for it.
  • Loading branch information
pastuxso authored Dec 31, 2024
1 parent 18f7e9c commit 9991193
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:
RUNME_PROJECT: ${{ github.workspace }}
SHELL: bash
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
FORK_OWNER: ${{ github.event.pull_request.head.repo.owner.login }}
BASE_OWNER: ${{ github.repository_owner }}
- name: 🔼 Upload Artifacts
uses: actions/upload-artifact@v4
if: failure()
Expand Down
14 changes: 12 additions & 2 deletions tests/e2e/specs/githubAction.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,29 @@ const UI_LATENCY_TIMEOUT_SECS = 2 * 60 * 1000

describe('Runme GitHub Workflow Integration', async () => {
const notebook = new RunmeNotebook()
const token = process.env.RUNME_TEST_TOKEN
const token = process.env.RUNME_TEST_TOKEN || ''
const actor = process.env.GITHUB_ACTOR
const eventName = process.env.GITHUB_EVENT_NAME
const baseOwner = process.env.BASE_OWNER || ''
const forkOwner = process.env.FORK_OWNER || ''

/**
* Skip GitHub Action tests for local testing due to missing token
*/
if (
(!token && !process.env.CI) ||
process.env.NODE_ENV === 'production' ||
process.env.GITHUB_ACTOR === 'dependabot[bot]'
actor === 'dependabot[bot]'
) {
return
}

// Skip tests only if PR is from external fork
if (eventName === 'pull_request' && forkOwner !== baseOwner) {
console.log('Skipping GitHub Workflow Integration tests for pull request from external fork.')
return
}

it('has GitHub test token defined in the environment', async () => {
expect(token).toBeDefined()
})
Expand Down

0 comments on commit 9991193

Please sign in to comment.