Skip to content

Commit

Permalink
Merge pull request #958 from input-output-hk/fix/ci-build
Browse files Browse the repository at this point in the history
fix: ci build + upload
  • Loading branch information
mchappell authored Oct 21, 2024
2 parents fd87c68 + 6ead300 commit 249db02
Show file tree
Hide file tree
Showing 8 changed files with 2,362 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: npm test
- name: Generates Secrets File
run: |
echo "export default { PROJECT_ID_MAINNET: '${{ secrets.PROJECT_ID_MAINNET }}', PROJECT_ID_PREVIEW: '${{ secrets.PROJECT_ID_PREVIEW }}', PROJECT_ID_PREPROD: '${{ secrets.PROJECT_ID_PREPROD }}', POSTHOG_API_KEY:'${{ secrets.POSTHOG_API_KEY_PRODUCTION }}', POSTHOG_PROJECT_ID: '${{ secrets.POSTHOG_PROJECT_ID_PRODUCTION }}'};" > secrets.production.js
echo "export default { PROJECT_ID_MAINNET: '${{ secrets.PROJECT_ID_MAINNET }}', PROJECT_ID_PREVIEW: '${{ secrets.PROJECT_ID_PREVIEW }}', PROJECT_ID_PREPROD: '${{ secrets.PROJECT_ID_PREPROD }}', POSTHOG_API_KEY:'${{ secrets.POSTHOG_API_KEY }}', POSTHOG_PROJECT_ID: '${{ secrets.POSTHOG_PROJECT_ID }}', LACE_EXTENSION_ID: '${{ secrets.LACE_EXTENSION_ID }}'};" > secrets.production.js
- name: Build
run: npm run build
env:
Expand Down
2,300 changes: 2,278 additions & 22 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"@blaze-cardano/sdk": "^0.1.32",
"@cardano-foundation/ledgerjs-hw-app-cardano": "^7.1.3",
"@cardano-sdk/core": "^0.39.2",
"@chakra-ui/button": "^2.1.0",
"@chakra-ui/checkbox": "^2.3.2",
"@chakra-ui/css-reset": "^2.3.0",
"@chakra-ui/icons": "^2.1.1",
"@chakra-ui/react": "^2.8.2",
Expand Down Expand Up @@ -94,6 +96,7 @@
"clean-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.8.1",
"dotenv": "^16.4.5",
"dotenv-defaults": "^5.0.2",
"eslint": "^8.54.0",
"eslint-config-react-app": "^7.0.1",
Expand All @@ -110,6 +113,7 @@
"html-webpack-plugin": "^5.2.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-webextension-mock": "^3.9.0",
"prettier": "^3.1.0",
"react-refresh": "^0.14.0",
"sass": "1.69.5",
Expand All @@ -124,9 +128,7 @@
"typescript": "^5.3.2",
"webpack": "^5.88.1",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1",
"dotenv": "^16.4.5",
"jest-webextension-mock": "^3.9.0"
"webpack-dev-server": "^4.15.1"
},
"resolutions": {
"nan": "2.17.0"
Expand Down
1 change: 1 addition & 0 deletions secrets.testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export default {
PROJECT_ID_PREPROD: 'DUMMY_PREPROD',
POSTHOG_API_KEY: 'DUMMY_POSTHOG_API_KEY',
POSTHOG_PROJECT_ID: 'DUMMY_POSTHOG_PROJECT_ID',
LACE_EXTENSION_ID: 'DUMMY_EXT_ID',
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
if (process.env.LACE_EXTENSION_ID === undefined) {
import secrets from '../../../../config/provider';

if (secrets.LACE_EXTENSION_ID === undefined) {
throw new Error('process.env.LACE_EXTENSION_ID must be defined');
}
export const LACE_EXTENSION_ID = process.env.LACE_EXTENSION_ID;
export const LACE_EXTENSION_ID = secrets.LACE_EXTENSION_ID;
1 change: 1 addition & 0 deletions src/config/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ export default {
},
posthog_api_token: secrets.POSTHOG_API_KEY,
posthog_project_id: secrets.POSTHOG_PROJECT_ID,
LACE_EXTENSION_ID: secrets.LACE_EXTENSION_ID,
};
43 changes: 23 additions & 20 deletions src/features/sentry.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
import * as Sentry from '@sentry/react';

Sentry.init({
environment: process.env.NODE_ENV,
dsn: process.env.SENTRY_DSN,
integrations: [
Sentry.browserTracingIntegration(),
Sentry.browserProfilingIntegration(),
Sentry.replayIntegration(),
],
// Set `tracePropagationTargets` to control for which URLs trace propagation should be enabled
tracePropagationTargets: ["localhost", "chrome-extension://bpmphiofbkjfgclgimheipflhladbngo"],
// .5%
tracesSampleRate: 0.05,
profilesSampleRate: 0.05,
// Since profilesSampleRate is relative to tracesSampleRate,
// the final profiling rate can be computed as tracesSampleRate * profilesSampleRate
// A tracesSampleRate of 0.05 and profilesSampleRate of 0.05 results in 2.5% of
// transactions being profiled (0.05*0.05=0.0025)
environment: process.env.NODE_ENV,
dsn: process.env.SENTRY_DSN,
integrations: [
Sentry.browserTracingIntegration(),
Sentry.browserProfilingIntegration(),
Sentry.replayIntegration(),
],
// Set `tracePropagationTargets` to control for which URLs trace propagation should be enabled
tracePropagationTargets: [
'localhost',
'chrome-extension://lpfcbjknijpeeillifnkikgncikgfhdo',
],
// .5%
tracesSampleRate: 0.05,
profilesSampleRate: 0.05,
// Since profilesSampleRate is relative to tracesSampleRate,
// the final profiling rate can be computed as tracesSampleRate * profilesSampleRate
// A tracesSampleRate of 0.05 and profilesSampleRate of 0.05 results in 2.5% of
// transactions being profiled (0.05*0.05=0.0025)

// Capture Replay for 0.5% of all sessions,
replaysSessionSampleRate: 0.005,
// ...plus for 100% of sessions with an error
replaysOnErrorSampleRate: 1.0,
// Capture Replay for 0.5% of all sessions,
replaysSessionSampleRate: 0.005,
// ...plus for 100% of sessions with an error
replaysOnErrorSampleRate: 1.0,
});
86 changes: 49 additions & 37 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var webpack = require('webpack'),
TerserPlugin = require('terser-webpack-plugin'),
NodePolyfillPlugin = require('node-polyfill-webpack-plugin'),
ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const { sentryWebpackPlugin } = require("@sentry/webpack-plugin");
const { sentryWebpackPlugin } = require('@sentry/webpack-plugin');

require('dotenv').config();

Expand All @@ -21,7 +21,7 @@ var secretsPath = path.join(__dirname, 'secrets.' + env.NODE_ENV + '.js');

require('dotenv-defaults').config({
path: './.env',
encoding: 'utf8'
encoding: 'utf8',
});

var fileExtensions = [
Expand All @@ -44,14 +44,17 @@ if (fileSystem.existsSync(secretsPath)) {
const isDevelopment = process.env.NODE_ENV === 'development';

const hasSentryConfig =
!!process.env.SENTRY_AUTH_TOKEN &&
!!process.env.SENTRY_ORG &&
!!process.env.SENTRY_PROJECT &&
!!process.env.SENTRY_DSN
!!process.env.SENTRY_AUTH_TOKEN &&
!!process.env.SENTRY_ORG &&
!!process.env.SENTRY_PROJECT &&
!!process.env.SENTRY_DSN;

const withMaybeSentry = (p) => hasSentryConfig ? [ path.join(__dirname, 'src', 'features', 'sentry.js'), p ] : p;
const withMaybeSentry = (p) =>
hasSentryConfig
? [path.join(__dirname, 'src', 'features', 'sentry.js'), p]
: p;

const envsToExpose = ['NODE_ENV', 'LACE_EXTENSION_ID', 'NAMI_EXTENSION_ID'];
const envsToExpose = ['NODE_ENV'];
if (hasSentryConfig) envsToExpose.push('SENTRY_DSN');

var options = {
Expand All @@ -61,28 +64,31 @@ var options = {
},
mode: process.env.NODE_ENV || 'development',
entry: {
mainPopup: withMaybeSentry(path.join(__dirname, 'src', 'ui', 'indexMain.jsx')),
internalPopup: withMaybeSentry(path.join(__dirname, 'src', 'ui', 'indexInternal.jsx')),
hwTab: withMaybeSentry(path.join(__dirname, 'src', 'ui', 'app', 'tabs', 'hw.jsx')),
createWalletTab: withMaybeSentry(path.join(
__dirname,
'src',
'ui',
'app',
'tabs',
'createWallet.jsx'
)),
trezorTx: withMaybeSentry(path.join(__dirname, 'src', 'ui', 'app', 'tabs', 'trezorTx.jsx')),
background: withMaybeSentry(path.join(__dirname, 'src', 'pages', 'Background', 'index.js')),
contentScript: withMaybeSentry(path.join(__dirname, 'src', 'pages', 'Content', 'index.js')),
injected: withMaybeSentry(path.join(__dirname, 'src', 'pages', 'Content', 'injected.js')),
trezorContentScript: withMaybeSentry(path.join(
__dirname,
'src',
'pages',
'Content',
'trezorContentScript.js'
))
mainPopup: withMaybeSentry(
path.join(__dirname, 'src', 'ui', 'indexMain.jsx')
),
internalPopup: withMaybeSentry(
path.join(__dirname, 'src', 'ui', 'indexInternal.jsx')
),
hwTab: withMaybeSentry(
path.join(__dirname, 'src', 'ui', 'app', 'tabs', 'hw.jsx')
),
createWalletTab: withMaybeSentry(
path.join(__dirname, 'src', 'ui', 'app', 'tabs', 'createWallet.jsx')
),
trezorTx: withMaybeSentry(
path.join(__dirname, 'src', 'ui', 'app', 'tabs', 'trezorTx.jsx')
),
background: path.join(__dirname, 'src', 'pages', 'Background', 'index.js'),
contentScript: withMaybeSentry(
path.join(__dirname, 'src', 'pages', 'Content', 'index.js')
),
injected: withMaybeSentry(
path.join(__dirname, 'src', 'pages', 'Content', 'injected.js')
),
trezorContentScript: withMaybeSentry(
path.join(__dirname, 'src', 'pages', 'Content', 'trezorContentScript.js')
),
},
chromeExtensionBoilerplate: {
notHotReload: ['contentScript', 'devtools', 'injected'],
Expand Down Expand Up @@ -193,13 +199,19 @@ var options = {
},
plugins: [
...(isDevelopment ? [new ReactRefreshWebpackPlugin()] : []),
...(hasSentryConfig ? [sentryWebpackPlugin({
authToken: process.env.SENTRY_AUTH_TOKEN,
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
telemetry: false,
url: 'https://sentry.io/'
})] : []),
...(hasSentryConfig
? [
sentryWebpackPlugin({
authToken: process.env.SENTRY_AUTH_TOKEN,
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
telemetry: false,
include: './build',
url: 'https://sentry.io/',
ignore: ['node_modules', 'webpack.config.js'],
}),
]
: []),
new webpack.BannerPlugin({
banner: () => {
return 'globalThis.document={getElementsByTagName:()=>[],createElement:()=>({ setAttribute:()=>{}}),head:{appendChild:()=>{}}};';
Expand Down

0 comments on commit 249db02

Please sign in to comment.