diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml new file mode 100644 index 00000000..cc814a69 --- /dev/null +++ b/.github/workflows/integration-test.yml @@ -0,0 +1,63 @@ +name: Secure Integration test + +on: + pull_request_target: + types: [opened, synchronize, labeled, unlabled, reopened] + +env: + AWS_REGION: us-east-1 + +jobs: + check-access-and-checkout: + runs-on: ubuntu-latest + permissions: + id-token: write + pull-requests: read + contents: read + steps: + - name: Check PR labels and author + id: check + uses: actions/github-script@v7 + with: + script: | + const pr = context.payload.pull_request; + + const labels = pr.labels.map(label => label.name); + const hasLabel = labels.includes('approved-for-integ-test') + if (hasLabel) { + core.info('PR contains label approved-for-integ-test') + return + } + + const isOwner = pr.user.type === 'User' && pr.user.login === context.repo.owner; + if (isOwner) { + core.info('PR auther is an OWNER') + return + } + + core.setFailed('Pull Request must either have label approved-for-integ-test or be created by an owner') + + - name: Configure Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.STRANDS_INTEG_TEST_ROLE }} + aws-region: us-east-1 + mask-aws-account-id: true + - name: Checkout base branch + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.base.ref }} + persist-credentials: false # Don't persist credentials for subsequent actions + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Install dependencies + run: | + pip install --no-cache-dir hatch + - name: Run integration tests + id: tests + run: | + hatch test tests-integ + + diff --git a/.github/workflows/pr-and-push.yml b/.github/workflows/pr-and-push.yml index 2b2d026f..97945428 100644 --- a/.github/workflows/pr-and-push.yml +++ b/.github/workflows/pr-and-push.yml @@ -5,7 +5,7 @@ on: branches: [ main ] types: [opened, synchronize, reopened, ready_for_review, review_requested, review_request_removed] push: - branches: [ main ] # Also run on direct pushes to main + branches: [ main, dea/integ-test ] # Also run on direct pushes to main concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true @@ -15,5 +15,6 @@ jobs: uses: ./.github/workflows/test-lint.yml permissions: contents: read + id-token: write with: ref: ${{ github.event.pull_request.head.sha }} diff --git a/.github/workflows/pypi-publish-on-release.yml b/.github/workflows/pypi-publish-on-release.yml index 0e26a1db..5854e77c 100644 --- a/.github/workflows/pypi-publish-on-release.yml +++ b/.github/workflows/pypi-publish-on-release.yml @@ -15,6 +15,7 @@ jobs: name: Build distribution 📦 permissions: contents: read + id-token: write needs: - call-test-lint runs-on: ubuntu-latest diff --git a/.github/workflows/test-lint.yml b/.github/workflows/test-lint.yml deleted file mode 100644 index 35e0f584..00000000 --- a/.github/workflows/test-lint.yml +++ /dev/null @@ -1,94 +0,0 @@ -name: Test and Lint - -on: - workflow_call: - inputs: - ref: - required: true - type: string - -jobs: - unit-test: - name: Unit Tests - Python ${{ matrix.python-version }} - ${{ matrix.os-name }} - permissions: - contents: read - strategy: - matrix: - include: - # Linux - - os: ubuntu-latest - os-name: 'linux' - python-version: "3.10" - - os: ubuntu-latest - os-name: 'linux' - python-version: "3.11" - - os: ubuntu-latest - os-name: 'linux' - python-version: "3.12" - - os: ubuntu-latest - os-name: 'linux' - python-version: "3.13" - # Windows - - os: windows-latest - os-name: 'windows' - python-version: "3.10" - - os: windows-latest - os-name: 'windows' - python-version: "3.11" - - os: windows-latest - os-name: 'windows' - python-version: "3.12" - - os: windows-latest - os-name: 'windows' - python-version: "3.13" - # MacOS - latest only; not enough runners for macOS - - os: macos-latest - os-name: 'macOS' - python-version: "3.13" - fail-fast: true - runs-on: ${{ matrix.os }} - env: - LOG_LEVEL: DEBUG - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - ref: ${{ inputs.ref }} # Explicitly define which commit to check out - persist-credentials: false # Don't persist credentials for subsequent actions - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install --no-cache-dir hatch - - name: Run Unit tests - id: tests - run: hatch test tests --cover - continue-on-error: false - lint: - name: Lint - runs-on: ubuntu-latest - permissions: - contents: read - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - ref: ${{ inputs.ref }} - persist-credentials: false - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.10' - cache: 'pip' - - - name: Install dependencies - run: | - pip install --no-cache-dir hatch - - - name: Run lint - id: lint - run: hatch run test-lint - continue-on-error: false diff --git a/README.md b/README.md index ed98d001..17997913 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@