-
Notifications
You must be signed in to change notification settings - Fork 32
70 lines (62 loc) · 2.39 KB
/
e2e-external-phase-2.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: Run end-to-end tests on external PR approval
on:
workflow_run:
workflows: ["Trigger end-to-end tests on external PR approval"]
types:
- completed
jobs:
e2e:
name: End-to-end tests
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
permissions:
actions: read
pull-requests: write
contents: write
steps:
- name: Extract the approved commit
id: extract
run: |
PR_NUMBER=$(gh api "repos/py-cov-action/python-coverage-comment-action/actions/runs/${RUN_ID}" --jq '.pull_requests | first | .number')
if [ -z "${PR_NUMBER}" ]; then
echo "No PR number found"
exit 1
fi
COMMIT_ID=$(gh pr --repo py-cov-action/python-coverage-comment-action view "${PR_NUMBER}" --json reviews --jq '[.reviews[] | select(.state == "APPROVED" and .authorAssociation == "MEMBER") | .commit.oid] | last')
if [ -z "${COMMIT_ID}" ]; then
echo "No approved commit found"
exit 1
fi
echo "PR_NUMBER=${PR_NUMBER}" >> "${GITHUB_OUTPUT}"
echo "COMMIT_ID=${COMMIT_ID}" > "${GITHUB_OUTPUT}"
env:
RUN_ID: ${{ github.event.workflow_run.id }}
GH_TOKEN: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v4
with:
# Important: use the commit that was reviewed. GitHub is making sure
# that this is race-condition-proof
ref: ${{ steps.extract.outputs.COMMIT_ID }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install Poetry
run: |
pipx install poetry --python=python3.11
- name: Poetry caches
uses: actions/cache@v3
with:
path: |
~/.cache/
key: ${{ hashFiles('poetry.lock') }}
- name: Install deps
run: poetry install
- name: Run end-to-end tests
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: ${{ steps.extract.outputs.COMMIT_ID }}
COVERAGE_COMMENT_E2E_REPO_SUFFIX: ${{ steps.extract.outputs.PR_NUMBER }}