Skip to content

Commit 2c2f955

Browse files
committed
Add trusted and fork integration tests
1 parent 5ee4cfb commit 2c2f955

File tree

1 file changed

+34
-11
lines changed

1 file changed

+34
-11
lines changed

.github/workflows/validate.yml

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
name: Validate
33

44
on:
5-
push:
6-
paths-ignore:
7-
- '**.md'
5+
pull_request:
6+
repository_dispatch:
7+
types: [ ok-to-test-command ]
88

99
jobs:
1010

11-
validate:
11+
integration-test-trusted:
12+
# actions that are trusted by default must only be opened from within the repo, and skipped for forks because they'll fail there
13+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
1214
strategy:
1315
matrix:
1416
os: [ubuntu-latest, windows-latest, macos-latest]
@@ -47,12 +49,18 @@ jobs:
4749
ruff --output-format=github --exclude=src/onepassword/lib/ .
4850
continue-on-error: true
4951

50-
# Repo owner has commented /ok-to-test on a (fork-based) pull request
51-
integration-fork:
52-
runs-on: ubuntu-latest
52+
# This action is called by the /ok-to-test command, once the forked PR's code has been security reviewed.
53+
# It will checkout the forked (and now trusted) code and it will run the integration tests on it.
54+
# If the tests are successful this action will proceed to update the status of the forked PR integration check.
55+
integration-test-fork:
56+
# must have these permissions to
5357
permissions:
5458
pull-requests: write
5559
checks: write
60+
strategy:
61+
matrix:
62+
os: [ubuntu-latest, windows-latest, macos-latest]
63+
runs-on: ${{ matrix.os }}
5664
if: |
5765
github.event_name == 'repository_dispatch' &&
5866
github.event.client_payload.slash_command.args.named.sha != '' &&
@@ -64,16 +72,31 @@ jobs:
6472

6573
# Check out merge commit
6674
- name: Fork based /ok-to-test checkout
67-
uses: actions/checkout@v3
75+
uses: actions/checkout@v4
6876
with:
6977
ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge'
7078

71-
# <insert integration tests needing secrets>
79+
80+
- uses: actions/checkout@v4
81+
82+
- name: Set up Python
83+
uses: actions/setup-python@v4
84+
with:
85+
python-version: '3.x'
86+
87+
- name: Integration Test
88+
env:
89+
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.TEST_SERVICE_ACCOUNT_TOKEN }}
90+
run: |
91+
pip install pytest &&
92+
pip install pytest-asyncio &&
93+
pip install pydantic &&
94+
python -m pytest src/onepassword/test_client.py
7295
7396
- run: |
74-
echo "Integration tests... success! ;-)"
97+
echo "Integration tests completed successfully!"
7598
76-
# Update check run called "integration-fork"
99+
# Update check run called "integration-fork" on the forked PR
77100
- uses: actions/github-script@v6
78101
id: update-check-run
79102
if: ${{ always() }}

0 commit comments

Comments
 (0)