External PRs #7
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: End-to-end tests for external PRs | |
on: | |
pull_request_review: | |
types: [submitted] | |
concurrency: | |
group: ${{ github.event_name }}-${{ github.ref }} | |
jobs: | |
test: | |
name: Run end to end tests | |
# If reviewed by a repo(/org) owner | |
if: | | |
github.event.pull_request.author_association != 'MEMBER' | |
&& github.event.review.author_association == 'MEMBER' | |
&& github.event.review.state == 'approved' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check cache if the tests have already run | |
id: cache | |
uses: actions/cache/restore@v3 | |
with: | |
key: ${{ github.ref }}-${{ github.event.review.commit_id }} | |
path: dummy.txt | |
- name: Checkout | |
if: steps.cache.outputs.cache-hit != 'true' | |
uses: actions/checkout@v3 | |
with: | |
# Important: use the commit that was reviewed. GitHub is making sure | |
# that this is race-condition-proof | |
ref: ${{ github.event.review.commit_id }} | |
- name: Set up Python | |
if: steps.cache.outputs.cache-hit != 'true' | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install Poetry | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
pipx install poetry --python=python3.10 | |
- name: Poetry caches | |
if: steps.cache.outputs.cache-hit != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/ | |
key: ${{ hashFiles('poetry.lock') }} | |
- name: Install deps | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: poetry install | |
- name: Run end-to-end tests | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: poetry run pytest tests/end_to_end | |
env: | |
COVERAGE_COMMENT_E2E_GITHUB_TOKEN_USER_1: ${{ secrets.COVERAGE_COMMENT_E2E_GITHUB_TOKEN_USER_1 }} | |
COVERAGE_COMMENT_E2E_GITHUB_TOKEN_USER_2: ${{ secrets.COVERAGE_COMMENT_E2E_GITHUB_TOKEN_USER_2 }} | |
COVERAGE_COMMENT_E2E_ACTION_REF: ${{ github.event.review.commit_id }} | |
COVERAGE_COMMENT_E2E_REPO_SUFFIX: ${{ github.event.pull_request.number }} | |
COVERAGE_COMMENT_E2E_PR_AUTHOR: ${{ github.event.pull_request.user.login }} | |
- name: Create dummy file | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: touch dummy.txt | |
shell: bash | |
- name: Create cache to indicate that the tests have run | |
if: steps.cache.outputs.cache-hit != 'true' | |
uses: actions/cache/save@v3 | |
with: | |
key: ${{ github.ref }}-${{ github.event.review.commit_id }} | |
path: dummy.txt |