Skip to content

Commit

Permalink
Turn monorepo into regular repo
Browse files Browse the repository at this point in the history
Change repo structure not to be a monorepo anymore. Now that we are only
relying on the "nodejs" package, there's no need to use workspaces as it
adds friction to the development process, and the idea is to not add
more packages to the same repo in the future.

@tombruijn: I've also updated the build matrix generator to work with
the single package.

Written by: (I'm just reapplying it)

Co-authored-by: Noemi <[email protected]>
Co-authored-by: Luismi Ramirez <[email protected]>
  • Loading branch information
3 people committed Jun 14, 2022
1 parent 79817aa commit d452b46
Show file tree
Hide file tree
Showing 104 changed files with 4,984 additions and 5,898 deletions.
File renamed without changes.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ build/
/ext/libappsignal.a
/ext/libappsignal.dylib
/ext/libappsignal.so
/ext/*.report

# Agent archives
packages/nodejs/ext/*.tar.gz
ext/*.tar.gz

packages/*/test/spec/examples.txt
packages/*/test/example/package-lock.json
test/spec/examples.txt
test/example/package-lock.json
tmp
File renamed without changes.
File renamed without changes.
96 changes: 48 additions & 48 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ global_job_config:
value: 'true'
- name: NODE_ENV
value: test
- name: _PACKAGES_CACHE
value: v1
- name: _PACKAGE_CACHE
value: v3
- name: _BUNDLER_CACHE
value: v1
value: v2
prologue:
commands:
- checkout
Expand Down Expand Up @@ -74,18 +74,17 @@ blocks:
- cache restore
- mono bootstrap --ci
- cache store
epilogue: &1
always:
commands:
- ''
jobs:
- name: Build
commands:
- mono build
- cache delete $_PACKAGES_CACHE-packages-$SEMAPHORE_GIT_SHA-v$NODE_VERSION
- cache store $_PACKAGES_CACHE-packages-$SEMAPHORE_GIT_SHA-v$NODE_VERSION packages
- 'cat packages/nodejs/ext/install.report; cat packages/nodejs/ext/install.report
| grep ''"status": "success"'''
- cache delete $_PACKAGE_CACHE-dist-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID
- cache store $_PACKAGE_CACHE-dist-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID dist
- cache delete $_PACKAGE_CACHE-ext-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID
- cache store $_PACKAGE_CACHE-ext-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID ext
- cache delete $_PACKAGE_CACHE-build-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID
- cache store $_PACKAGE_CACHE-build-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID build
- 'cat ext/install.report; cat ext/install.report | grep ''"status": "success"'''
- name: Node.js 18 - Tests
dependencies:
- Node.js 18 - Build
Expand All @@ -98,16 +97,17 @@ blocks:
prologue:
commands:
- cache restore
- cache restore $_PACKAGES_CACHE-packages-$SEMAPHORE_GIT_SHA-v$NODE_VERSION
- cache restore $_PACKAGE_CACHE-dist-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID
- cache restore $_PACKAGE_CACHE-ext-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID
- cache restore $_PACKAGE_CACHE-build-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID
- mono bootstrap --ci
epilogue: *1
jobs:
- name: "@appsignal/nodejs - nodejs"
commands:
- mono test --package=@appsignal/nodejs
- mono run --package @appsignal/nodejs -- npm run test:failure
- name: "@appsignal/nodejs - nodejs - diagnose"
- name: Test package
commands:
- mono test
- npm run test:failure
- name: Extra test - diagnose
commands: &1
- git submodule init
- git submodule update
- LANGUAGE=nodejs test/integration/diagnose/bin/test
Expand All @@ -123,15 +123,17 @@ blocks:
- cache restore
- mono bootstrap --ci
- cache store
epilogue: *1
jobs:
- name: Build
commands:
- mono build
- cache delete $_PACKAGES_CACHE-packages-$SEMAPHORE_GIT_SHA-v$NODE_VERSION
- cache store $_PACKAGES_CACHE-packages-$SEMAPHORE_GIT_SHA-v$NODE_VERSION packages
- 'cat packages/nodejs/ext/install.report; cat packages/nodejs/ext/install.report
| grep ''"status": "success"'''
- cache delete $_PACKAGE_CACHE-dist-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID
- cache store $_PACKAGE_CACHE-dist-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID dist
- cache delete $_PACKAGE_CACHE-ext-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID
- cache store $_PACKAGE_CACHE-ext-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID ext
- cache delete $_PACKAGE_CACHE-build-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID
- cache store $_PACKAGE_CACHE-build-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID build
- 'cat ext/install.report; cat ext/install.report | grep ''"status": "success"'''
- name: Node.js 16 - Tests
dependencies:
- Node.js 16 - Build
Expand All @@ -144,19 +146,17 @@ blocks:
prologue:
commands:
- cache restore
- cache restore $_PACKAGES_CACHE-packages-$SEMAPHORE_GIT_SHA-v$NODE_VERSION
- cache restore $_PACKAGE_CACHE-dist-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID
- cache restore $_PACKAGE_CACHE-ext-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID
- cache restore $_PACKAGE_CACHE-build-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID
- mono bootstrap --ci
epilogue: *1
jobs:
- name: "@appsignal/nodejs - nodejs"
commands:
- mono test --package=@appsignal/nodejs
- mono run --package @appsignal/nodejs -- npm run test:failure
- name: "@appsignal/nodejs - nodejs - diagnose"
- name: Test package
commands:
- git submodule init
- git submodule update
- LANGUAGE=nodejs test/integration/diagnose/bin/test
- mono test
- npm run test:failure
- name: Extra test - diagnose
commands: *1
- name: Node.js 14 - Build
dependencies:
- Validation
Expand All @@ -169,15 +169,17 @@ blocks:
- cache restore
- mono bootstrap --ci
- cache store
epilogue: *1
jobs:
- name: Build
commands:
- mono build
- cache delete $_PACKAGES_CACHE-packages-$SEMAPHORE_GIT_SHA-v$NODE_VERSION
- cache store $_PACKAGES_CACHE-packages-$SEMAPHORE_GIT_SHA-v$NODE_VERSION packages
- 'cat packages/nodejs/ext/install.report; cat packages/nodejs/ext/install.report
| grep ''"status": "success"'''
- cache delete $_PACKAGE_CACHE-dist-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID
- cache store $_PACKAGE_CACHE-dist-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID dist
- cache delete $_PACKAGE_CACHE-ext-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID
- cache store $_PACKAGE_CACHE-ext-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID ext
- cache delete $_PACKAGE_CACHE-build-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID
- cache store $_PACKAGE_CACHE-build-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID build
- 'cat ext/install.report; cat ext/install.report | grep ''"status": "success"'''
- name: Node.js 14 - Tests
dependencies:
- Node.js 14 - Build
Expand All @@ -190,16 +192,14 @@ blocks:
prologue:
commands:
- cache restore
- cache restore $_PACKAGES_CACHE-packages-$SEMAPHORE_GIT_SHA-v$NODE_VERSION
- cache restore $_PACKAGE_CACHE-dist-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID
- cache restore $_PACKAGE_CACHE-ext-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID
- cache restore $_PACKAGE_CACHE-build-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID
- mono bootstrap --ci
epilogue: *1
jobs:
- name: "@appsignal/nodejs - nodejs"
- name: Test package
commands:
- mono test --package=@appsignal/nodejs
- mono run --package @appsignal/nodejs -- npm run test:failure
- name: "@appsignal/nodejs - nodejs - diagnose"
commands:
- git submodule init
- git submodule update
- LANGUAGE=nodejs test/integration/diagnose/bin/test
- mono test
- npm run test:failure
- name: Extra test - diagnose
commands: *1
File renamed without changes.
52 changes: 42 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,56 @@
- [Documentation][docs]
- [Support][contact]

[![Build Status](https://appsignal.semaphoreci.com/badges/appsignal-nodejs/branches/main.svg?style=shields&key=7dd9fe64-f1d5-437b-a5b7-8ac337a26c5b)](https://travis-ci.org/appsignal/appsignal-nodejs) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
![npm (scoped)](https://img.shields.io/npm/v/@appsignal/nodejs) [![Build Status](https://appsignal.semaphoreci.com/badges/appsignal-nodejs/branches/main.svg?style=shields&key=7dd9fe64-f1d5-437b-a5b7-8ac337a26c5b)](https://appsignal.semaphoreci.com/projects/appsignal-nodejs) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

The core AppSignal for Node.js library.

## Installation

Please follow our [installation guide](https://docs.appsignal.com/guides/new-application.html) in our documentation.

First, [sign up][appsignal-sign-up] for an AppSignal account and run our automated install tool, which will install `@appsignal/nodejs` and any relevant integrations to your project:

```bash
npx @appsignal/cli install
```

You can also skip the automated tool and add `@appsignal/nodejs` to your `package.json` on the command line with `npm`/`yarn`:

```bash
yarn add @appsignal/nodejs
npm install --save @appsignal/nodejs
```

Alternatively, you can manually add the `@appsignal/nodejs` package to your `package.json`. Then, run `yarn install`/`npm install`.

> Installing the AppSignal for Node.js integration builds a native extension. In order to compile it, macOS users will need to install the [Xcode Developer Tools](https://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/). Linux users will need the dependencies outlined here. Windows is not supported.
You can then import and use the package in your bundle:

```js
const { Appsignal } = require("@appsignal/nodejs");

const appsignal = new Appsignal({
active: true,
name: "<YOUR APPLICATION NAME>"
pushApiKey: "<YOUR API KEY>"
});

// ...all the rest of your code goes here!
```

> In order to auto-instrument modules, the Appsignal module must be both **required** and **initialized** before any other package.
## Extension

This package also contains the C++ extension, and the install script for the agent. The native extension is a bridge between the Node.js runtime and [our agent](https://docs.appsignal.com/appsignal/how-appsignal-operates.html#agent).

## Development

### Installation

This repository is a [mono-managed monorepo](https://github.com/appsignal/mono/), containing packages (located in the `/packages` directory) that map to separate `npm` modules.

First install mono on your local machine by [following the mono installation steps](https://github.com/appsignal/mono/#installation).
This repository is a [mono-managed repository](https://github.com/appsignal/mono/). First install mono on your local machine by [following the mono installation steps](https://github.com/appsignal/mono/#installation).

Then install the dependencies and prepare the project for development use using mono:

Expand All @@ -27,7 +64,7 @@ mono bootstrap
You can then run the following to start the compiler in _watch_ mode.

```bash
mono run npm run build:watch --parallel
npm run build:watch --parallel
```

You can also build the library without watching the directory:
Expand All @@ -46,10 +83,6 @@ The tests for this library use [Jest](https://jestjs.io) as the test runner. Onc
mono test
```

### Versioning

This repo uses [Semantic Versioning][semver] (often referred to as _semver_). Each package in the repository is versioned independently from one another.

## Contributing

Thinking of contributing to this repo? Awesome! 🚀
Expand All @@ -69,4 +102,3 @@ Also, we would be very happy to send you Stroopwafels. Have look at everyone we
[waffles-page]: https://www.appsignal.com/waffles
[docs]: https://docs.appsignal.com/nodejs/
[contributing-guide]: http://docs.appsignal.com/appsignal/contributing.html
[semver]: http://semver.org/
81 changes: 24 additions & 57 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace :build_matrix do
matrix = yaml["matrix"]
semaphore = yaml["semaphore"]
builds = []
skipped_packages = Set.new
matrix["nodejs"].each do |nodejs|
nodejs_version = nodejs["nodejs"]
setup = nodejs.fetch("setup", [])
Expand All @@ -34,17 +33,18 @@ namespace :build_matrix do
"cache store"
]
},
"epilogue" => matrix["epilogue"],
"jobs" => [
build_semaphore_job(
"name" => "Build",
"commands" => [
"mono build",
"cache delete $_PACKAGES_CACHE-packages-$SEMAPHORE_GIT_SHA-v$NODE_VERSION",
"cache store $_PACKAGES_CACHE-packages-$SEMAPHORE_GIT_SHA-v$NODE_VERSION " \
"packages",
"cat packages/nodejs/ext/install.report; " \
"cat packages/nodejs/ext/install.report | grep '\"status\": \"success\"'"
"cache delete $_PACKAGE_CACHE-dist-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID",
"cache store $_PACKAGE_CACHE-dist-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID dist",
"cache delete $_PACKAGE_CACHE-ext-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID",
"cache store $_PACKAGE_CACHE-ext-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID ext",
"cache delete $_PACKAGE_CACHE-build-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID",
"cache store $_PACKAGE_CACHE-build-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID build",
"cat ext/install.report; cat ext/install.report | grep '\"status\": \"success\"'"
]
)
]
Expand All @@ -54,55 +54,21 @@ namespace :build_matrix do

primary_block_name = "Node.js #{nodejs_version} - Tests"
primary_jobs = []
matrix["packages"].each do |package|
has_package_tests = package_has_tests? package["path"]
if !has_package_tests && skipped_packages.add?(package["package"])
puts "DEBUG: Skipping Node.js tests for #{package["package"]}: No test files found"
end

package["variations"].each do |variation|
excluded_nodejs_versions = variation.dig("exclude", "nodejs") || []
next if excluded_nodejs_versions.include?(nodejs_version)

variation_name = variation.fetch("name")
dependency_specification = variation["packages"]
update_package_version_command, update_test_app_version_command =
if dependency_specification
packages = dependency_specification.map do |name, version|
"#{name}@#{version}"
end.join(" ")
[
"script/install_packages #{packages}",
"script/install_test_example_packages " \
"#{File.basename package["path"]} #{packages}"
]
end

# Run Node.js / Jest tests against specific package versions
if has_package_tests
# Only add a job to run Node.js / Jest tests if there are any. So
# we don't waste a lot of time on job setup that don't do
# anything. If a package suddenly does get tests the validation
# step will fail, and will require this task to be re-run, so
# that we don't forget to run those new tests.
primary_jobs << build_semaphore_job(
"name" => "#{package["package"]} - #{variation_name}",
"commands" => ([
update_package_version_command,
"mono test --package=#{package["package"]}"
] + package.fetch("extra_commands", [])).compact
)
end
package = matrix["package"]
primary_jobs << build_semaphore_job(
"name" => "Test package",
"commands" => ([
"mono test"
] + package.fetch("extra_commands", [])).compact
)

# Run extra tests against specific package versions. If configured,
# run the extra tests configured for the package.
package.fetch("extra_tests", []).each do |test_name, extra_tests|
primary_jobs << build_semaphore_job(
"name" => "#{package["package"]} - #{variation_name} - #{test_name}",
"commands" => ([update_test_app_version_command] + extra_tests).compact
)
end
end
# Run extra tests against specific package versions. If configured,
# run the extra tests configured for the package.
package.fetch("extra_tests", []).each do |test_name, extra_tests|
primary_jobs << build_semaphore_job(
"name" => "Extra test - #{test_name}",
"commands" => extra_tests
)
end
primary_block =
build_semaphore_task(
Expand All @@ -122,11 +88,12 @@ namespace :build_matrix do
"prologue" => {
"commands" => setup + [
"cache restore",
"cache restore $_PACKAGES_CACHE-packages-$SEMAPHORE_GIT_SHA-v$NODE_VERSION",
"cache restore $_PACKAGE_CACHE-dist-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID",
"cache restore $_PACKAGE_CACHE-ext-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID",
"cache restore $_PACKAGE_CACHE-build-v$NODE_VERSION-$SEMAPHORE_WORKFLOW_ID",
"mono bootstrap --ci"
]
},
"epilogue" => matrix["epilogue"],
"jobs" => primary_jobs
}
)
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit d452b46

Please sign in to comment.