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

ref: Transition to binaries over npm #1836

Merged
merged 17 commits into from
Nov 27, 2023
Merged
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
16 changes: 9 additions & 7 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
"node": true
},
"parserOptions": {
"ecmaVersion": "latest"
"ecmaVersion": 9
},
"overrides": [{
"env": {
"jest": true
},
"files": ["*.test.js"]
}]
"overrides": [
{
"env": {
"jest": true
},
"files": ["*.test.js"]
}
]
}
45 changes: 1 addition & 44 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [10.x, 12.x, 14.x, 16.x, 18.x]
node-version: [10.x, 12.x, 14.x, 16.x, 18.x, 20.x]

name: Test Node ${{ matrix.node-version }}
runs-on: ubuntu-latest
Expand All @@ -88,52 +88,9 @@ jobs:
node-version: ${{ matrix.node-version }}

- run: npm install
env:
SENTRYCLI_LOCAL_CDNURL: 'http://localhost:8999/'

# older node versions need an older nft
- run: npm install @vercel/[email protected]
if: matrix.node-version == '10.x' || matrix.node-version == '12.x'

- run: npm test

test_install:
# Don't run install test on release branches, as at this point binaries were not published to CDN yet.
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}

strategy:
fail-fast: false
matrix:
node-version: [10.x, 12.x, 14.x, 16.x, 18.x]

name: Test install script on Node ${{ matrix.node-version }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
path: sentry-cli-dep

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Setup empty test app
run: mkdir test-app && cd test-app && npm init --yes

- name: Install @sentry/cli
run: npm install ../sentry-cli-dep --install-links
working-directory: ./test-app

- name: Ensure binary can be called from paths
run: |
node_modules/.bin/sentry-cli help
node_modules/@sentry/cli/sentry-cli help
working-directory: ./test-app

- name: Install @sentry/cli globally
run: npm install ./sentry-cli-dep --install-links -g

- name: Ensure binary is installed globally
run: sentry-cli help
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ coverage
dist
dump
checksums.txt
yarn-error.log

/sentry-cli
/sentry-cli.exe
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

"You know what they say. Fool me once, strike one, but fool me twice... strike three." — Michael Scott

## 2.22.3

ref: Transition to binaries over npm (#1836)

## 2.22.2

This release contains no changes and was done for technical purposes.
Expand Down
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
setupFiles: ['<rootDir>/setupTests.js'],
testPathIgnorePatterns: ['<rootDir>/src/'],
};
5 changes: 0 additions & 5 deletions js/__tests__/helper.test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
const os = require('os');
const path = require('path');

const helper = require('../helper');

const SOURCEMAPS_OPTIONS = require('../releases/options/uploadSourcemaps');

describe('SentryCli helper', () => {
beforeEach(() => {
helper.mockBinaryPath(path.resolve(__dirname, '../__mocks__/sentry-cli'));
});

test('call sentry-cli --version', () => {
expect.assertions(1);
return helper
Expand Down
11 changes: 2 additions & 9 deletions js/helper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const os = require('os');
const path = require('path');
const childProcess = require('child_process');

const BINARY_DISTRIBUTIONS = [
Expand Down Expand Up @@ -80,14 +79,6 @@ function getBinaryPath() {
return process.env.SENTRY_BINARY_PATH;
}

if (!process.env.USE_SENTRY_BINARY_NPM_DISTRIBUTION) {
const parts = [];
parts.push(__dirname);
parts.push('..');
parts.push(`sentry-cli${process.platform === 'win32' ? '.exe' : ''}`);
return path.resolve(...parts);
}

const { packageName, subpath } = getDistributionForThisPlatform();

if (packageName === undefined) {
Expand Down Expand Up @@ -141,7 +132,9 @@ let binaryPath = getBinaryPath();
* Overrides the default binary path with a mock value, useful for testing.
*
* @param {string} mockPath The new path to the mock sentry-cli binary
* @deprecated This was used in tests internally and will be removed in the next major version.
*/
// TODO(v3): Remove this function
function mockBinaryPath(mockPath) {
binaryPath = mockPath;
}
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"eslint-config-prettier": "^8.5.0",
"jest": "^27.5.1",
"npm-run-all": "^4.1.5",
"prettier": "^2.6.2"
"prettier": "2.8.8"
Copy link
Member Author

Choose a reason for hiding this comment

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

I pinned this because CI and local were drifting apart for some reason. :/

},
"optionalDependencies": {
"@sentry/cli-darwin": "2.22.2",
Expand All @@ -39,7 +39,6 @@
"@sentry/cli-win32-x64": "2.22.2"
},
"scripts": {
"install": "node ./scripts/install.js",
"fix": "npm-run-all fix:eslint fix:prettier",
"fix:eslint": "eslint --fix bin/* scripts/**/*.js js/**/*.js",
"fix:prettier": "prettier --write bin/* scripts/**/*.js js/**/*.js",
Expand All @@ -58,7 +57,7 @@
]
},
"volta": {
"node": "10.24.1",
"node": "20.10.0",
"yarn": "1.22.19"
}
}
24 changes: 7 additions & 17 deletions scripts/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

'use strict';

// TODO(v3): Remove this file

console.log(
'DEPRECATION NOTICE: The Sentry CLI install script has been deprecated. The package now uses "optionalDependencies" instead to install architecture-compatible binaries distributed over npm.'
);

const fs = require('fs');
const http = require('http');
const os = require('os');
const path = require('path');
const crypto = require('crypto');
Expand Down Expand Up @@ -303,27 +308,12 @@ async function downloadBinary() {
async function checkVersion() {
const output = await helper.execute(['--version']);
const version = output.replace('sentry-cli ', '').trim();
const expected = process.env.SENTRYCLI_LOCAL_CDNURL ? 'DEV' : pkgInfo.version;
const expected = pkgInfo.version;
if (version !== expected) {
throw new Error(`Unexpected sentry-cli version "${version}", expected "${expected}"`);
}
}

if (process.env.SENTRYCLI_LOCAL_CDNURL) {
// For testing, mock the CDN by spawning a local server
const server = http.createServer((request, response) => {
const contents = fs.readFileSync(path.join(__dirname, '../js/__mocks__/sentry-cli'));
response.writeHead(200, {
'Content-Type': 'application/octet-stream',
'Content-Length': String(contents.byteLength),
});
response.end(contents);
});

server.listen(8999);
process.on('exit', () => server.close());
}

if (process.env.SENTRYCLI_SKIP_DOWNLOAD === '1') {
logger.log(`Skipping download because SENTRYCLI_SKIP_DOWNLOAD=1 detected.`);
process.exit(0);
Expand Down
3 changes: 3 additions & 0 deletions setupTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const path = require('path');

process.env.SENTRY_BINARY_PATH = path.join(__dirname, 'js', '__mocks__', 'sentry-cli');
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3069,10 +3069,10 @@ prelude-ls@~1.1.2:
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
integrity sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==

prettier@^2.6.2:
version "2.8.3"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.3.tgz#ab697b1d3dd46fb4626fbe2f543afe0cc98d8632"
integrity sha512-tJ/oJ4amDihPoufT5sM0Z1SKEuKay8LfVAMlbbhnnkvt6BUserZylqo2PN+p9KeljLr0OHa2rXHU1T8reeoTrw==
prettier@2.8.8:
version "2.8.8"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==

pretty-format@^27.5.1:
version "27.5.1"
Expand Down
Loading