Skip to content

Commit

Permalink
Convert into monorepo (#367)
Browse files Browse the repository at this point in the history
* Convert into monorepo
* Using lerna for managing packages
* Add incremental and composite options in tsconfig to improve build optimization and project referencing
* Isolate tests into a separate package
  • Loading branch information
w1am authored May 10, 2024
1 parent 343954e commit d2b2874
Show file tree
Hide file tree
Showing 263 changed files with 6,061 additions and 2,633 deletions.
48 changes: 23 additions & 25 deletions .github/workflows/build_and_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,29 +57,27 @@ jobs:
run: yarn
- name: Build
run: yarn build
- name: Create package
id: package
- name: Create and Test All Packages
run: |
echo "package=$(echo $PWD)$(echo "/")$(npm pack)" >> $GITHUB_OUTPUT
echo "file=$(echo $PWD)$(echo "/.github/files/package_check.txt")" >> $GITHUB_OUTPUT
- name: Create test project
run: |
cd ../
mkdir ./temp
cd ./temp
yarn init -y
yarn add ${{ steps.package.outputs.package }}
yarn add --dev typescript
cp ${{ steps.package.outputs.file }} ./main.ts
- name: Test project compiles
working-directory: ../temp
run: yarn tsc main.ts
--alwaysStrict
--noImplicitAny
--noImplicitReturns
--strictNullChecks
--module system
--moduleResolution node
--target es2018
--lib es2020
--types node
for DIR in packages/*; do
if [ -d "$DIR" ]; then
cd $DIR
if [ -f "package.json" ]; then
PACKAGE_NAME=$(node -p "require('./package.json').name")
SHOULD_PUBLISH=$(node -p "require('./package.json').publishConfig && require('./package.json').publishConfig.public ? 'true' : 'false'")
if [[ $PACKAGE_NAME == @eventstore/* ]] && [[ $SHOULD_PUBLISH == 'true' ]]; then
npm pack
PACKAGE_PATH=$(pwd)/$(ls *.tgz)
mkdir -p ../../../temp/$PACKAGE_NAME
cd ../../../temp/$PACKAGE_NAME
yarn init -y
yarn add $PACKAGE_PATH
yarn add --dev typescript
cp ../../..$DIR/.github/files/package_check.txt ./main.ts
yarn tsc main.ts --alwaysStrict --noImplicitAny --noImplicitReturns --strictNullChecks --module system --moduleResolution node --target es2018 --lib es2020 --types node
cd ../../..
fi
fi
cd ..
fi
done
112 changes: 57 additions & 55 deletions .github/workflows/test_ee.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,58 @@
name: "EE"

on:
pull_request:
push:
branches:
- master
schedule:
- cron: "0 * * * 0" # Every day at 3am UTC.

jobs:
tests:
name: "${{ matrix.group.name }}"
strategy:
fail-fast: false
matrix:
group:
- name: plugins
path: ./src/__test__/plugins
tailscale: true
env:
# Github only passes secrets to the main repo, so we need to skip some things if they are unavailable
SECRETS_AVAILABLE: ${{ secrets.EVENTSTORE_CLOUD_ID != null }}
EVENTSTORE_VERSION: "24.2.0-jammy"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Connect to tailscale
if: ${{ matrix.group.tailscale && env.SECRETS_AVAILABLE == 'true' }}
run: |
curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/eoan.gpg | sudo apt-key add -
curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/eoan.list | sudo tee /etc/apt/sources.list.d/tailscale.list
sudo apt-get update
sudo apt-get install tailscale
sudo tailscale up --authkey ${{ secrets.TAILSCALE_AUTH }} --hostname "node-client-ci-${{ env.EVENTSTORE_VERSION }}-$(date +'%Y-%m-%d-%H-%M-%S')" --advertise-tags=tag:ci --accept-routes
- uses: actions/setup-node@v4
with:
node-version-file: .github/files/.nvmrc
- name: NodeJS version
run: node -v
- name: Login to Cloudsmith
uses: docker/login-action@v3
with:
registry: docker.eventstore.com
username: ${{ secrets.CLOUDSMITH_CICD_USER }}
password: ${{ secrets.CLOUDSMITH_CICD_TOKEN }}
- name: Install
run: yarn
- name: Run Tests
run: yarn test ${{ matrix.group.path }} --ci --run-in-band --forceExit
env:
EVENTSTORE_IMAGE: eventstore-ee:${{ env.EVENTSTORE_VERSION }}
EVENTSTORE_CLOUD_ID: ${{ secrets.EVENTSTORE_CLOUD_ID }}
- name: Disconnect from tailscale
if: ${{ always() && matrix.group.tailscale && env.SECRETS_AVAILABLE == 'true' }}
name: "EE"

on:
pull_request:
push:
branches:
- master
schedule:
- cron: "0 3 * * *" # Every day at 3am UTC.

jobs:
tests:
name: "${{ matrix.group.name }}"
strategy:
fail-fast: false
matrix:
group:
- name: plugins
path: ./src/plugins
tailscale: true
env:
# Github only passes secrets to the main repo, so we need to skip some things if they are unavailable
SECRETS_AVAILABLE: ${{ secrets.EVENTSTORE_CLOUD_ID != null }}
EVENTSTORE_VERSION: "24.2.0-jammy"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Connect to tailscale
if: ${{ matrix.group.tailscale && env.SECRETS_AVAILABLE == 'true' }}
run: |
curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/eoan.gpg | sudo apt-key add -
curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/eoan.list | sudo tee /etc/apt/sources.list.d/tailscale.list
sudo apt-get update
sudo apt-get install tailscale
sudo tailscale up --authkey ${{ secrets.TAILSCALE_AUTH }} --hostname "node-client-ci-${{ env.EVENTSTORE_VERSION }}-$(date +'%Y-%m-%d-%H-%M-%S')" --advertise-tags=tag:ci --accept-routes
- uses: actions/setup-node@v4
with:
node-version-file: .github/files/.nvmrc
- name: NodeJS version
run: node -v
- name: Login to Cloudsmith
uses: docker/login-action@v3
with:
registry: docker.eventstore.com
username: ${{ secrets.CLOUDSMITH_CICD_USER }}
password: ${{ secrets.CLOUDSMITH_CICD_TOKEN }}
- name: Install
run: yarn
- name: Build
run: yarn build
- name: Run Tests
run: yarn test ${{ matrix.group.path }} --ci --run-in-band --forceExit
env:
EVENTSTORE_IMAGE: eventstore-ee:${{ env.EVENTSTORE_VERSION }}
EVENTSTORE_CLOUD_ID: ${{ secrets.EVENTSTORE_CLOUD_ID }}
- name: Disconnect from tailscale
if: ${{ always() && matrix.group.tailscale && env.SECRETS_AVAILABLE == 'true' }}
run: sudo tailscale down
2 changes: 1 addition & 1 deletion .github/workflows/test_next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
branches:
- master
schedule:
- cron: "0 * * * 0" # Every day at 3am UTC.
- cron: "0 3 * * *" # Every day at 3am UTC.

jobs:
test:
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@ on:
required: false

jobs:
tests:
build-and-test:
name: "${{ matrix.group.name }}"
strategy:
fail-fast: false
matrix:
group:
- name: samples
path: ./samples
path: ./src/samples
tailscale: true

- name: connection
path: ./src/__test__/connection
path: ./src/connection
tailscale: true

- name: extra
path: ./src/__test__/extra
path: ./src/extra

- name: persistentSubscription
path: ./src/__test__/persistentSubscription
path: ./src/persistentSubscription

- name: projections
path: ./src/__test__/projections
path: ./src/projections

- name: streams
path: ./src/__test__/streams
path: ./src/streams
env:
# Github only passes secrets to the main repo, so we need to skip some things if they are unavailable
SECRETS_AVAILABLE: ${{ secrets.eventstore_cloud_id != null }}
Expand All @@ -59,6 +59,8 @@ jobs:
run: node -v
- name: Install
run: yarn
- name: Build
run: yarn build
- name: Run Tests
run: yarn test ${{ matrix.group.path }} --ci --run-in-band --forceExit
env:
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,4 @@ dist
.npmrc
package-lock.json

src/__test__/utils/instances

.vscode
Loading

0 comments on commit d2b2874

Please sign in to comment.