Skip to content

Commit

Permalink
Merge branch 'develop' into lforst-xhr-function-names
Browse files Browse the repository at this point in the history
  • Loading branch information
lforst authored Aug 28, 2024
2 parents e6404b7 + 4ccf251 commit ea1d470
Show file tree
Hide file tree
Showing 28 changed files with 511 additions and 120 deletions.
4 changes: 1 addition & 3 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ outputs:
runs:
using: "composite"
steps:
# we use a hash of yarn.lock as our cache key, because if it hasn't changed, our dependencies haven't changed,
# so no need to reinstall them
- name: Compute dependency cache key
id: compute_lockfile_hash
run: echo "hash=dependencies-${{ hashFiles('yarn.lock', 'packages/*/package.json', 'dev-packages/*/package.json') }}" >> "$GITHUB_OUTPUT"
run: node ./scripts/dependency-hash-key.js >> "$GITHUB_OUTPUT"
shell: bash

- name: Check dependency cache
Expand Down
12 changes: 5 additions & 7 deletions .github/actions/restore-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ runs:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ env.DEPENDENCY_CACHE_KEY }}

- name: Check build cache
uses: actions/cache/restore@v4
id: build-cache
- name: Restore build artifacts
uses: actions/download-artifact@v4
with:
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
name: build-output

- name: Check if caches are restored
uses: actions/github-script@v6
if: steps.dep-cache.outputs.cache-hit != 'true' || steps.build-cache.outputs.cache-hit != 'true'
if: steps.dep-cache.outputs.cache-hit != 'true'
with:
script: core.setFailed('Dependency or build cache could not be restored - please re-run ALL jobs.')
script: core.setFailed('Dependency cache could not be restored - please re-run ALL jobs.')
57 changes: 25 additions & 32 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ env:
${{ github.workspace }}/packages/utils/cjs
${{ github.workspace }}/packages/utils/esm
BUILD_CACHE_KEY: build-cache-${{ github.event.inputs.commit || github.sha }}
BUILD_CACHE_TARBALL_KEY: tarball-${{ github.event.inputs.commit || github.sha }}

# GH will use the first restore-key it finds that matches
Expand Down Expand Up @@ -127,7 +126,9 @@ jobs:
runs-on: ubuntu-20.04
timeout-minutes: 15
if: |
needs.job_get_metadata.outputs.changed_any_code == 'true' &&
needs.job_get_metadata.outputs.changed_any_code == 'true' ||
needs.job_get_metadata.outputs.is_develop == 'true' ||
needs.job_get_metadata.outputs.is_release == 'true' ||
(needs.job_get_metadata.outputs.is_gitflow_sync == 'false' && needs.job_get_metadata.outputs.has_gitflow_label == 'false')
steps:
- name: Check out base commit (${{ github.event.pull_request.base.sha }})
Expand Down Expand Up @@ -158,13 +159,6 @@ jobs:
base: ${{ github.event.pull_request.base.sha }}
head: ${{ env.HEAD_COMMIT }}

- name: Check build cache
uses: actions/cache@v4
id: cache_built_packages
with:
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}

- name: NX cache
uses: actions/cache@v4
# Disable cache when:
Expand All @@ -186,6 +180,15 @@ jobs:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: yarn build

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

outputs:
dependency_cache_key: ${{ steps.install_dependencies.outputs.cache_key }}
changed_node_integration: ${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected, '@sentry-internal/node-integration-tests') }}
Expand Down Expand Up @@ -344,7 +347,7 @@ jobs:
name: ${{ github.sha }}
path: |
${{ github.workspace }}/packages/browser/build/bundles/**
${{ github.workspace }}/packages/replay/build/bundles/**
${{ github.workspace }}/packages/replay-internal/build/bundles/**
${{ github.workspace }}/packages/replay-canvas/build/bundles/**
${{ github.workspace }}/packages/feedback/build/bundles/**
${{ github.workspace }}/packages/**/*.tgz
Expand Down Expand Up @@ -454,7 +457,8 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [14, 16, 18, 20, 22]
#TODO: unpin 22 once Node bug is fixed
node: [14, 16, 18, 20, '22.6.0']
steps:
- name: Check out base commit (${{ github.event.pull_request.base.sha }})
uses: actions/checkout@v4
Expand Down Expand Up @@ -1416,31 +1420,29 @@ jobs:
with:
ref: ${{ env.HEAD_COMMIT }}

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}

- name: Restore dependency cache
uses: actions/cache/restore@v4
id: restore-dependencies
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ needs.job_build.outputs.dependency_cache_key }}
enableCrossOsArchive: true
fail-on-cache-miss: true

- name: Restore build cache
uses: actions/cache/restore@v4
id: restore-build
with:
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ needs.job_build.outputs.dependency_cache_key }}
enableCrossOsArchive: true
fail-on-cache-miss: true
- name: Install dependencies
env:
SKIP_PLAYWRIGHT_BROWSER_INSTALL: "1"
if: steps.restore-dependencies.outputs.cache-hit != 'true'
run: yarn install --ignore-engines --frozen-lockfile

- name: Configure safe directory
run: |
git config --global --add safe.directory "*"
- name: Install yarn
run: npm i -g [email protected] --force

- name: Increase yarn network timeout on Windows
if: contains(matrix.os, 'windows')
run: yarn config set network-timeout 600000 -g
Expand All @@ -1452,15 +1454,6 @@ jobs:
with:
python-version: '3.8.10'

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}

- name: Install Dependencies
if: steps.restore-dependencies.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile --ignore-engines --ignore-scripts

- name: Setup (arm64| ${{ contains(matrix.container, 'alpine') && 'musl' || 'glibc' }})
if: matrix.arch == 'arm64' && !contains(matrix.container, 'alpine') && matrix.target_platform != 'darwin'
run: |
Expand Down
36 changes: 34 additions & 2 deletions .github/workflows/clear-cache.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,43 @@
name: "Action: Clear all GHA caches"
on:
workflow_dispatch:
inputs:
clear_pending_prs:
description: Delete caches of pending PR workflows
type: boolean
default: false
clear_develop:
description: Delete caches on develop branch
type: boolean
default: false
clear_branches:
description: Delete caches on non-develop branches
type: boolean
default: true
schedule:
# Run every day at midnight
- cron: '0 0 * * *'

jobs:
clear-caches:
name: Delete all caches
runs-on: ubuntu-20.04
steps:
- name: Clear caches
uses: easimon/wipe-cache@v2
- uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'

# TODO: Use cached version if possible (but never store cache)
- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Delete GHA caches
uses: ./dev-packages/clear-cache-gh-action
with:
clear_pending_prs: ${{ inputs.clear_pending_prs }}
clear_develop: ${{ inputs.clear_develop }}
clear_branches: ${{ inputs.clear_branches }}
github_token: ${{ secrets.GITHUB_TOKEN }}
1 change: 0 additions & 1 deletion .github/workflows/external-contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ jobs:
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
cache: 'yarn'

- name: Install dependencies
run: yarn install --frozen-lockfile
Expand Down
2 changes: 1 addition & 1 deletion .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = [
path: 'packages/browser/build/npm/esm/index.js',
import: createImport('init', 'browserTracingIntegration', 'replayIntegration'),
gzip: true,
limit: '66.01 KB',
limit: '68 KB',
modifyWebpackConfig: function (config) {
const webpack = require('webpack');
config.plugins.push(
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/browser-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"private": true,
"scripts": {
"clean": "rimraf -g suites/**/dist loader-suites/**/dist tmp",
"install-browsers": "npx playwright install --with-deps",
"install-browsers": "[[ -z \"$SKIP_PLAYWRIGHT_BROWSER_INSTALL\" ]] && yarn npx playwright install --with-deps || echo 'Skipping browser installation'",
"lint": "eslint . --format stylish",
"fix": "eslint . --format stylish --fix",
"type-check": "tsc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,3 @@ Sentry.init({
feedbackIntegration({ tags: { from: 'integration init' }, styleNonce: 'foo1234', scriptNonce: 'foo1234' }),
],
});

document.addEventListener('securitypolicyviolation', () => {
const container = document.querySelector('#csp-violation');
if (container) {
container.innerText = 'CSP Violation';
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
window.__CSPVIOLATION__ = false;
document.addEventListener('securitypolicyviolation', () => {
window.__CSPVIOLATION__ = true;
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@
content="style-src 'nonce-foo1234'; script-src sentry-test.io 'nonce-foo1234';"
/>
</head>
<body>
<div id="csp-violation" />
</body>
<body></body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ sentryTest('should capture feedback', async ({ getLocalTestUrl, page }) => {
},
platform: 'javascript',
});
const cspContainer = await page.locator('#csp-violation');
expect(cspContainer).not.toContainText('CSP Violation');
const cspViolation = await page.evaluate<boolean>('window.__CSPVIOLATION__');
expect(cspViolation).toBe(false);
});
14 changes: 14 additions & 0 deletions dev-packages/clear-cache-gh-action/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
extends: ['../../.eslintrc.js'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 'latest',
},

overrides: [
{
files: ['*.mjs'],
extends: ['@sentry-internal/sdk/src/base'],
},
],
};
25 changes: 25 additions & 0 deletions dev-packages/clear-cache-gh-action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'clear-cache-gh-action'
description: 'Clear caches of the GitHub repository.'
inputs:
github_token:
required: true
description: 'a github access token'
clear_develop:
required: false
default: ""
description: "If set, also clear caches from develop branch."
clear_branches:
required: false
default: ""
description: "If set, also clear caches from non-develop branches."
clear_pending_prs:
required: false
default: ""
description: "If set, also clear caches from pending PR workflow runs."
workflow_name:
required: false
default: "CI: Build & Test"
description: The workflow to clear caches for.
runs:
using: 'node20'
main: 'index.mjs'
Loading

0 comments on commit ea1d470

Please sign in to comment.