Repository navigation
perf(api): Use lightweight contexts across control permissions #367347
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Also note that this name *MUST* match the filename because GHA | |
| # only provides the workflow name (https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables#default-environment-variables) | |
| # and GH APIs only support querying by workflow *FILENAME* (https://developer.github.com/v3/actions/workflows/#get-a-workflow) | |
| name: acceptance | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - releases/** | |
| pull_request: | |
| # Cancel in progress workflows on pull_requests. | |
| # https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| # hack for https://github.com/actions/cache/issues/810#issuecomment-1222550359 | |
| env: | |
| SEGMENT_DOWNLOAD_TIMEOUT_MINS: 3 | |
| NODE_OPTIONS: '--max-old-space-size=4096' | |
| CHARTCUTERIE_CONFIG_PATH: ${{ github.workspace }}/config/chartcuterie | |
| SNUBA_NO_WORKERS: 1 | |
| jobs: | |
| files-changed: | |
| name: detect what files changed | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 3 | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| # Map a step output to a job output | |
| outputs: | |
| acceptance: ${{ steps.changes.outputs.acceptance }} | |
| backend_all: ${{ steps.changes.outputs.backend_all }} | |
| frontend_all: ${{ steps.changes.outputs.frontend_all }} | |
| steps: | |
| - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
| - name: Check for backend file changes | |
| uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 # v4.0.2 | |
| id: changes | |
| with: | |
| token: ${{ github.token }} | |
| filters: .github/file-filters.yml | |
| acceptance: | |
| if: needs.files-changed.outputs.acceptance == 'true' | |
| needs: files-changed | |
| name: acceptance | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 30 | |
| permissions: | |
| contents: read | |
| id-token: write | |
| actions: read # used for DIM metadata | |
| strategy: | |
| # This helps not having to run multiple jobs because one fails, thus, reducing resource usage | |
| # and reducing the risk that one of many runs would turn red again (read: intermittent tests) | |
| fail-fast: false | |
| matrix: | |
| # XXX: Use 5 runners when backend changes are present, 10 runners for frontend-only changes | |
| instance: ${{ needs.files-changed.outputs.backend_all == 'true' && fromJSON('[0, 1, 2, 3, 4]') || fromJSON('[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]') }} | |
| env: | |
| # XXX: MATRIX_INSTANCE_TOTAL must match the matrix size (5 for backend changes, 10 for frontend-only) | |
| MATRIX_INSTANCE_TOTAL: ${{ needs.files-changed.outputs.backend_all == 'true' && '5' || '10' }} | |
| TEST_GROUP_STRATEGY: roundrobin | |
| PYTHONHASHSEED: '0' | |
| XDIST_PER_WORKER_SNUBA: '1' | |
| XDIST_WORKERS: '2' | |
| steps: | |
| - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
| name: Checkout sentry | |
| # devservices bind mounts this into chartcuterie. Create it up front so | |
| # docker doesn't create it as root before the config module is built. | |
| # chartcuterie polls for the config file until it shows up. | |
| - name: Create chartcuterie config directory | |
| run: mkdir -p "$CHARTCUTERIE_CONFIG_PATH" | |
| # Must run before "Setup sentry env" starts in the background: it parses | |
| # $GITHUB_EVENT_PATH, which the runner truncates whenever a step starts, | |
| # including the background step's inner steps (getsentry/sentry#127566). | |
| - uses: ./.github/actions/setup-node-toolchain | |
| # Starts per-worker ClickHouse bootstrap as soon as its dependencies are | |
| # healthy, instead of after snuba-snuba-1's own bootstrap. | |
| - name: Start per-worker Snuba bootstrap in the background | |
| if: env.XDIST_PER_WORKER_SNUBA == '1' | |
| env: | |
| DEVSERVICES_STATUS_FILE: ${{ runner.temp }}/devservices-ci/up.exit | |
| run: python3 .github/workflows/scripts/bootstrap-snuba.py --start | |
| # The python env and devservices don't depend on the frontend build, so | |
| # bring them up in the background while webpack runs. | |
| - name: Setup sentry env | |
| uses: ./.github/actions/setup-sentry | |
| id: setup | |
| background: true | |
| with: | |
| mode: acceptance-ci | |
| early-devservices: 'true' | |
| - name: Step configurations | |
| id: config | |
| run: | | |
| echo "webpack-path=.webpack_cache" >> "$GITHUB_OUTPUT" | |
| echo "WEBPACK_CACHE_PATH=.webpack_cache" >> "$GITHUB_ENV" | |
| - name: webpack cache | |
| uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 | |
| with: | |
| path: ${{ steps.config.outputs.webpack-path }} | |
| key: ${{ runner.os }}-v2-webpack-cache-${{ hashFiles('rsbuild.config.ts', 'pnpm-lock.yaml', 'package.json') }} | |
| - uses: ./.github/actions/setup-node-pnpm | |
| with: | |
| setup-toolchain: 'false' | |
| # Chrome's first launch on a fresh runner takes several seconds longer | |
| # than later ones, which is consistent with a cold disk and font cache. | |
| # Launch it once here, while webpack builds, so the test workers don't | |
| # pay that. | |
| - name: Warm up Chrome in the background | |
| run: | | |
| if command -v google-chrome && command -v chromedriver; then | |
| setsid nohup timeout 60 google-chrome --headless --no-sandbox --disable-gpu \ | |
| --disable-dev-shm-usage --user-data-dir="$(mktemp -d)" --window-size=1680,1050 \ | |
| --screenshot="$RUNNER_TEMP/chrome-warmup.png" 'data:text/html,<p>warm</p>' \ | |
| >"$RUNNER_TEMP/chrome-warmup.log" 2>&1 & | |
| setsid nohup chromedriver --version >/dev/null 2>&1 & | |
| fi | |
| - name: webpack | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| GH_COMMIT_SHA: ${{ github.event.pull_request.head.sha }} | |
| run: | | |
| pnpm run build-acceptance | |
| - name: Build chartcuterie configuration module | |
| run: | | |
| make build-chartcuterie-config | |
| - name: Wait for sentry env | |
| wait: setup | |
| - name: Bootstrap per-worker Snuba instances | |
| if: env.XDIST_PER_WORKER_SNUBA == '1' | |
| run: python3 .github/workflows/scripts/bootstrap-snuba.py --wait | |
| - name: Run acceptance tests (#${{ steps.setup.outputs.matrix-instance-number }} of ${{ steps.setup.outputs.matrix-instance-total }}) | |
| run: | | |
| export PYTEST_ADDOPTS="$PYTEST_ADDOPTS -n ${XDIST_WORKERS} --dist=loadfile" | |
| # Skips the Selenium Manager lookup Selenium would run on every launch. | |
| if chromedriver=$(command -v chromedriver); then | |
| PYTEST_ADDOPTS="$PYTEST_ADDOPTS --chromedriver-path=$chromedriver" | |
| fi | |
| timeout -k 30 1200 make run-acceptance || rc=$? | |
| [ "${rc:-0}" -ne 124 ] || echo "::error::Test run timed out after 20 minutes (possible xdist hang)" | |
| exit "${rc:-0}" | |
| - name: Inspect failure | |
| if: failure() | |
| run: | | |
| if command -v devservices; then | |
| devservices logs | |
| fi | |
| if [ "${XDIST_PER_WORKER_SNUBA}" = "1" ]; then | |
| for i in $(seq 0 $(( ${XDIST_WORKERS} - 1 ))); do | |
| echo "--- snuba-gw${i} logs ---" | |
| docker logs "snuba-gw${i}" 2>&1 | tail -30 || true | |
| done | |
| fi | |
| acceptance-required-checks: | |
| # this is a required check so we need this job to always run and report a status. | |
| if: always() | |
| name: Acceptance | |
| needs: [acceptance, files-changed] | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 3 | |
| steps: | |
| - name: Check for failures | |
| if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') | |
| run: | | |
| echo "One of the dependent jobs have failed. You may need to re-run it." && exit 1 |