Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger AWS Lambda tests on label #2538

Merged
merged 14 commits into from
Nov 30, 2023
Merged

Conversation

sentrivana
Copy link
Contributor

@sentrivana sentrivana commented Nov 28, 2023

Our AWS Lambda test suite currently doesn't run properly on external contributor PRs because it needs access to repo secrets, which it currently doesn't have. This PR adds a label to grant access to the secrets, which is invalidated upon any new code changes.

How it works

For the AWS Lambda test suite (and any future test suites that need access to GH secrets):

  • add a new check-permissions job that runs before all test jobs
    • the check-permissions job runs a Python script (taken from here) that finishes with an error code if the PR was not made by someone with write permissions and there is no Trigger: tests using secrets label on the PR
    • additionally, the job removes the Trigger: tests using secrets label on any code changes before any code from the PR is checked out
  • make all test jobs depend on check-permissions finishing successfully
  • run the workflow on pull_request_target (with access to secrets)

Copied and adapted the approach from sentry: https://github.com/getsentry/sentry/blob/master/.github/workflows/getsentry-dispatch.yml

The test AWS account has been stripped down of all unnecessary permissions: #2493 (comment)

Since the workflow is now on pull_request_target it won't run until we've actually merged this PR. I tried the changes out in a test repo.

Supersedes #2493

@sentrivana sentrivana marked this pull request as ready for review November 28, 2023 12:32
@sentrivana sentrivana linked an issue Nov 28, 2023 that may be closed by this pull request
@sentrivana
Copy link
Contributor Author

cc @asottile-sentry @mdtro in case you guys want to/have time to double check

Copy link
Member

@asottile-sentry asottile-sentry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise looks good

from urllib.parse import quote
from urllib.request import Request, urlopen

LABEL = "Trigger: tests"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would maybe make this more explicit that it's sensitive tests requiring secrets

Copy link
Contributor Author

@sentrivana sentrivana Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to "Trigger: tests using secrets" (open to better names)

sentrivana and others added 2 commits November 29, 2023 15:57
Co-authored-by: Anton Pirker <anton.pirker@sentry.io>
@sentrivana sentrivana merged commit cd3f08b into master Nov 30, 2023
466 checks passed
@sentrivana sentrivana deleted the ivana/trigger-tests-on-label-2 branch November 30, 2023 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AWS Lambda test suite doesn't work on contributor PRs
3 participants