|
| 1 | +name: Secure Integration test |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request_target: |
| 5 | + types: [opened, synchronize, labeled, unlabled, reopened] |
| 6 | + |
| 7 | +jobs: |
| 8 | + check-access-and-checkout: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + permissions: |
| 11 | + id-token: write |
| 12 | + pull-requests: read |
| 13 | + contents: read |
| 14 | + steps: |
| 15 | + - name: Check PR labels and author |
| 16 | + id: check |
| 17 | + uses: actions/github-script@v7 |
| 18 | + with: |
| 19 | + script: | |
| 20 | + const pr = context.payload.pull_request; |
| 21 | + |
| 22 | + const labels = pr.labels.map(label => label.name); |
| 23 | + const hasLabel = labels.includes('approved-for-integ-test') |
| 24 | + if (hasLabel) { |
| 25 | + core.info('PR contains label approved-for-integ-test') |
| 26 | + return |
| 27 | + } |
| 28 | + |
| 29 | + const isOwner = pr.author_association === 'OWNER' |
| 30 | + if (isOwner) { |
| 31 | + core.info('PR auther is an OWNER') |
| 32 | + return |
| 33 | + } |
| 34 | +
|
| 35 | + core.setFailed('Pull Request must either have label approved-for-integ-test or be created by an owner') |
| 36 | + - name: Configure Credentials |
| 37 | + uses: aws-actions/configure-aws-credentials@v4 |
| 38 | + with: |
| 39 | + role-to-assume: ${{ secrets.STRANDS_INTEG_TEST_ROLE }} |
| 40 | + aws-region: us-east-1 |
| 41 | + mask-aws-account-id: true |
| 42 | + - name: Checkout base branch |
| 43 | + uses: actions/checkout@v4 |
| 44 | + with: |
| 45 | + ref: ${{ github.event.pull_request.head.ref }} # Pull the commit from the forked repo |
| 46 | + persist-credentials: false # Don't persist credentials for subsequent actions |
| 47 | + - name: Set up Python |
| 48 | + uses: actions/setup-python@v5 |
| 49 | + with: |
| 50 | + python-version: '3.10' |
| 51 | + - name: Install dependencies |
| 52 | + run: | |
| 53 | + pip install --no-cache-dir hatch |
| 54 | + - name: Run integration tests |
| 55 | + env: |
| 56 | + AWS_REGION: us-east-1 |
| 57 | + AWS_REGION_NAME: us-east-1 # Needed for LiteLLM |
| 58 | + id: tests |
| 59 | + run: | |
| 60 | + hatch test tests-integ |
| 61 | + |
| 62 | + |
0 commit comments