Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 72 additions & 92 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ concurrency:
env:
HEAD_COMMIT: ${{ github.event.inputs.commit || github.sha }}

# WARNING: this disables cross os caching as ~ and
# github.workspace evaluate to differents paths
CACHED_DEPENDENCY_PATHS: |
${{ github.workspace }}/node_modules
${{ github.workspace }}/packages/*/node_modules
Expand All @@ -38,25 +36,19 @@ env:

# DEPENDENCY_CACHE_KEY: can't be set here because we don't have access to yarn.lock

# WARNING: this disables cross os caching as ~ and
# github.workspace evaluate to differents paths
# packages/utils/cjs and packages/utils/esm: Symlinks to the folders inside of `build`, needed for tests
CACHED_BUILD_PATHS: |
BUILD_PATHS: |
${{ github.workspace }}/dev-packages/*/build
${{ github.workspace }}/packages/*/build
${{ github.workspace }}/packages/*/lib
${{ github.workspace }}/packages/ember/*.d.ts
${{ github.workspace }}/packages/gatsby/*.d.ts
${{ github.workspace }}/packages/*.d.ts

BUILD_CACHE_TARBALL_KEY: tarball-${{ github.event.inputs.commit || github.sha }}
# upload-artifact globs drop the path through the first `*` (see upload-artifact
# README). Tarballs therefore land in the artifact as <pkg>/*.tgz; download
# tarball-output into packages/ so they resolve to packages/<pkg>/*.tgz.
TARBALL_ARTIFACT_GLOB: packages/*/*.tgz
TARBALL_ARTIFACT_DOWNLOAD_PATH: ${{ github.workspace }}/packages

# GH will use the first restore-key it finds that matches
# So it will start by looking for one from the same branch, else take the newest one it can find elsewhere
# We want to prefer the cache from the current develop branch, if we don't find any on the current branch
NX_CACHE_RESTORE_KEYS: |
nx-Linux-${{ github.ref }}-${{ github.event.inputs.commit || github.sha }}
nx-Linux-${{ github.ref }}
nx-Linux
# We cache NX per-PR for faster CI, other than this we do not want to rely on it
NX_CACHE_KEY: nx-Linux-${{ github.ref }}

# https://bsky.app/profile/joyeecheung.bsky.social/post/3lhy6o54fo22h
# Apparently some of our CI failures are attributable to a corrupt v8 cache, causing v8 failures with: "Check failed: current == end_slot_index.".
Expand All @@ -66,6 +58,7 @@ env:
jobs:
job_get_metadata:
uses: ./.github/workflows/ci-metadata.yml
name: Get CI Metadata
with:
head_commit: ${{ github.event.inputs.commit || github.sha }}
permissions:
Expand Down Expand Up @@ -110,34 +103,40 @@ jobs:
base: ${{ github.event.pull_request.base.sha }}
head: ${{ env.HEAD_COMMIT }}

- name: NX cache
uses: actions/cache@v5
# Disable cache when:
# - on release branches
# - when PR has `ci-skip-cache` label or on nightly builds
if: |
needs.job_get_metadata.outputs.is_release == 'false' &&
needs.job_get_metadata.outputs.force_skip_cache == 'false'
with:
path: .nxcache
key: nx-Linux-${{ github.ref }}-${{ env.HEAD_COMMIT || github.sha }}
# On develop branch, we want to _store_ the cache (so it can be used by other branches), but never _restore_ from it
restore-keys:
${{needs.job_get_metadata.outputs.is_base_branch == 'false' && env.NX_CACHE_RESTORE_KEYS ||
'nx-never-restore'}}

- name: Build packages
run: yarn build

- name: Store NX cache
uses: actions/cache/save@v5
# Only cache this per-PR to speed up CI.
if: github.event_name == 'pull_request'
with:
path: .nx
key: ${{ env.NX_CACHE_KEY }}

- name: Upload build artifacts
uses: actions/upload-artifact@v7
with:
name: build-output
path: ${{ env.CACHED_BUILD_PATHS }}
path: ${{ env.BUILD_PATHS }}
retention-days: 4
compression-level: 6
overwrite: true

- name: Determine which test applications should be run
id: matrix
run:
yarn --silent ci:build-matrix --base=${{ (github.event_name == 'pull_request' &&
github.event.pull_request.base.sha) || '' }} >> $GITHUB_OUTPUT
working-directory: dev-packages/e2e-tests

- name: Determine which optional E2E test applications should be run
id: matrix-optional
run:
yarn --silent ci:build-matrix-optional --base=${{ (github.event_name == 'pull_request' &&
github.event.pull_request.base.sha) || '' }} >> $GITHUB_OUTPUT
working-directory: dev-packages/e2e-tests

outputs:
dependency_cache_key: ${{ steps.install_dependencies.outputs.cache_key }}
changed_node_integration:
Expand All @@ -164,6 +163,8 @@ jobs:
changed_browser_integration:
${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected,
'@sentry-internal/browser-integration-tests') }}
e2e-matrix: ${{ steps.matrix.outputs.matrix }}
e2e-matrix-optional: ${{ steps.matrix-optional.outputs.matrix }}

job_check_branches:
name: Check PR branches
Expand Down Expand Up @@ -298,7 +299,7 @@ jobs:

job_artifacts:
name: Upload Artifacts
needs: [job_get_metadata, job_build]
needs: [job_get_metadata, job_build, job_build_tarballs]
runs-on: ubuntu-24.04
# Build artifacts are only needed for releasing workflow.
if: needs.job_get_metadata.outputs.is_release == 'true'
Expand All @@ -316,8 +317,11 @@ jobs:
with:
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}

- name: Pack tarballs
run: yarn build:tarball
- name: Restore tarball artifacts
uses: actions/download-artifact@v7
with:
name: tarball-output
path: ${{ env.TARBALL_ARTIFACT_DOWNLOAD_PATH }}

- name: Archive artifacts
uses: actions/upload-artifact@v7
Expand Down Expand Up @@ -662,7 +666,7 @@ jobs:
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check for dts files that reference stuff in the temporary build folder
run: |
if grep -r --include "*.d.ts" --exclude-dir ".nxcache" 'import("@sentry(-internal)?/[^/]*/build' .; then
if grep -r --include "*.d.ts" --exclude-dir ".nx" 'import("@sentry(-internal)?/[^/]*/build' .; then
echo "Found illegal TypeScript import statement."
exit 1
fi
Expand Down Expand Up @@ -834,19 +838,16 @@ jobs:
cd packages/remix
yarn test:integration:ci

job_e2e_prepare:
name: Prepare E2E tests
job_build_tarballs:
name: Build tarballs
# We want to run this if:
# - The build job was successful, not skipped
if: |
always() &&
needs.job_build.result == 'success'
needs: [job_get_metadata, job_build]
runs-on: ubuntu-24.04-large-js
runs-on: ubuntu-24.04
timeout-minutes: 15
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
matrix-optional: ${{ steps.matrix-optional.outputs.matrix }}
steps:
- name: Check out base commit (${{ github.event.pull_request.base.sha }})
uses: actions/checkout@v6
Expand All @@ -865,44 +866,33 @@ jobs:
uses: ./.github/actions/restore-cache
with:
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: NX cache

- name: Restore NX cache
uses: actions/cache/restore@v5
with:
path: .nxcache
key: nx-Linux-${{ github.ref }}-${{ env.HEAD_COMMIT }}
# On develop branch, we want to _store_ the cache (so it can be used by other branches), but never _restore_ from it
restore-keys: ${{ env.NX_CACHE_RESTORE_KEYS }}
path: .nx
key: ${{ env.NX_CACHE_KEY }}

- name: Build tarballs
run: yarn build:tarball

- name: Stores tarballs in cache
uses: actions/cache/save@v5
- name: Upload tarball artifacts
uses: actions/upload-artifact@v7
with:
path: ${{ github.workspace }}/packages/*/*.tgz
key: ${{ env.BUILD_CACHE_TARBALL_KEY }}

- name: Determine which E2E test applications should be run
id: matrix
run:
yarn --silent ci:build-matrix --base=${{ (github.event_name == 'pull_request' &&
github.event.pull_request.base.sha) || '' }} >> $GITHUB_OUTPUT
working-directory: dev-packages/e2e-tests

- name: Determine which optional E2E test applications should be run
id: matrix-optional
run:
yarn --silent ci:build-matrix-optional --base=${{ (github.event_name == 'pull_request' &&
github.event.pull_request.base.sha) || '' }} >> $GITHUB_OUTPUT
working-directory: dev-packages/e2e-tests
name: tarball-output
path: ${{ env.TARBALL_ARTIFACT_GLOB }}
if-no-files-found: error
retention-days: 4
compression-level: 6
overwrite: true

job_e2e_tests:
name: E2E ${{ matrix.label || matrix.test-application }} Test
# We need to add the `always()` check here because the previous step has this as well :(
# See: https://github.com/actions/runner/issues/2205
if:
always() && needs.job_e2e_prepare.result == 'success' && needs.job_e2e_prepare.outputs.matrix != '{"include":[]}'
needs: [job_get_metadata, job_build, job_e2e_prepare]
always() && needs.job_build_tarballs.result == 'success' && needs.job_build.outputs.e2e-matrix !='{"include":[]}'
needs: [job_get_metadata, job_build, job_build_tarballs]
runs-on: ubuntu-24.04
timeout-minutes: 15
env:
Expand All @@ -916,7 +906,7 @@ jobs:
E2E_TEST_SENTRY_PROJECT: 'sentry-javascript-e2e-tests'
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.job_e2e_prepare.outputs.matrix) }}
matrix: ${{ fromJson(needs.job_build.outputs.e2e-matrix) }}
steps:
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
uses: actions/checkout@v6
Expand Down Expand Up @@ -948,16 +938,11 @@ jobs:
with:
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}

- name: Restore tarball cache
uses: actions/cache/restore@v5
id: restore-tarball-cache
- name: Restore tarball artifacts
uses: actions/download-artifact@v7
with:
path: ${{ github.workspace }}/packages/*/*.tgz
key: ${{ env.BUILD_CACHE_TARBALL_KEY }}

- name: Build tarballs if not cached
if: steps.restore-tarball-cache.outputs.cache-hit != 'true'
run: yarn build:tarball
name: tarball-output
path: ${{ env.TARBALL_ARTIFACT_DOWNLOAD_PATH }}

- name: Validate Verdaccio
run: yarn test:validate
Expand Down Expand Up @@ -1022,10 +1007,10 @@ jobs:
# We need to add the `always()` check here because the previous step has this as well :(
# See: https://github.com/actions/runner/issues/2205
if:
always() && needs.job_get_metadata.outputs.is_release != 'true' && needs.job_e2e_prepare.result == 'success' &&
needs.job_e2e_prepare.outputs.matrix-optional != '{"include":[]}' && (github.event_name != 'pull_request' ||
always() && needs.job_get_metadata.outputs.is_release != 'true' && needs.job_build_tarballs.result == 'success' &&
needs.job_build.outputs.e2e-matrix-optional != '{"include":[]}' && (github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository) && github.actor != 'dependabot[bot]'
needs: [job_get_metadata, job_build, job_e2e_prepare]
needs: [job_get_metadata, job_build, job_build_tarballs]
runs-on: ubuntu-24.04
timeout-minutes: 15
env:
Expand All @@ -1039,7 +1024,7 @@ jobs:
E2E_TEST_SENTRY_PROJECT: 'sentry-javascript-e2e-tests'
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.job_e2e_prepare.outputs.matrix-optional) }}
matrix: ${{ fromJson(needs.job_build.outputs.e2e-matrix-optional) }}

steps:
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
Expand All @@ -1058,16 +1043,11 @@ jobs:
with:
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}

- name: Restore tarball cache
uses: actions/cache/restore@v5
id: restore-tarball-cache
- name: Restore tarball artifacts
uses: actions/download-artifact@v7
with:
path: ${{ github.workspace }}/packages/*/*.tgz
key: ${{ env.BUILD_CACHE_TARBALL_KEY }}

- name: Build tarballs if not cached
if: steps.restore-tarball-cache.outputs.cache-hit != 'true'
run: yarn build:tarball
name: tarball-output
path: ${{ env.TARBALL_ARTIFACT_DOWNLOAD_PATH }}

- name: Validate Verdaccio
run: yarn test:validate
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/flaky-test-detector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ on:
env:
HEAD_COMMIT: ${{ github.event.inputs.commit || github.sha }}

NX_CACHE_RESTORE_KEYS: |
nx-Linux-${{ github.ref }}-${{ github.event.inputs.commit || github.sha }}
nx-Linux-${{ github.ref }}
nx-Linux
NX_CACHE_KEY: nx-Linux-${{ github.ref }}

# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
Expand All @@ -39,12 +36,11 @@ jobs:
- name: Install dependencies
run: yarn install --ignore-engines --frozen-lockfile

- name: NX cache
- name: Restore NX cache
uses: actions/cache/restore@v5
with:
path: .nxcache
key: nx-Linux-${{ github.ref }}-${{ env.HEAD_COMMIT }}
restore-keys: ${{ env.NX_CACHE_RESTORE_KEYS }}
path: .nx
key: ${{ env.NX_CACHE_KEY }}

- name: Build packages
run: yarn build
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/e2e-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ try {
```

Test apps in the folder `test-applications` will be automatically picked up by CI in the job `job_e2e_tests` (in `.github/workflows/build.yml`).
The test matrix for CI is generated in `dev-packages/e2e-tests/lib/getTestMatrix.ts`.
The test matrix for CI is generated in `dev-packages/e2e-tests/lib/getTestMatrix.mjs`.

For each test app, CI checks its dependencies (and devDependencies) to see if any of them have changed in the current PR (based on nx affected projects).
For example, if something is changed in the browser package, only E2E test apps that depend on browser will run, while others will be skipped.
Expand Down
Loading
Loading