Skip to content

refactor: rearrange monorepo and packages + ci [WIP] #13

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 4 additions & 7 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@
},
"import/resolver": {
"node": {
"paths": [
"packages/"
],
"extensions": [
".ts"
]
"paths": ["packages/"],
"extensions": [".ts"]
},
"typescript": {
"project": ["packages/**/*/tsconfig.json"],
"alwaysTryTypes": true
}
}
Expand Down Expand Up @@ -63,7 +60,7 @@
"devDependencies": true,
"optionalDependencies": false,
"peerDependencies": false,
"packageDir": "./"
"packageDir": ["./", "packages/*"]
}
],
"@typescript-eslint/consistent-type-imports": [
Expand Down
55 changes: 22 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,87 +17,76 @@ jobs:
- name: Checkout
uses: actions/checkout@v4


- name: Use Node ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9.15.4
- uses: actions/cache@v2

- uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/pnpm-lock.yaml') }}
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}

- name: PNPM
run: pnpm install --frozen-lockfile
- name: Install
run: npm ci

- name: Build
run: pnpm run build
run: npm run build

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '22.x'
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9.15.4

- uses: actions/cache@v2
node-version: '18.x'

- uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/pnpm-lock.yaml') }}
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}

- name: PNPM
run: pnpm install --frozen-lockfile
- name: Install
run: npm ci

- name: Lint
run: pnpm run lint
run: npm run lint

- name: Validate Packages
run: pnpm manypkg check
run: npx @manypkg/cli check

test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
project: ['doubles.jest', 'doubles.sinon', 'core.unit', 'doubles.vitest', 'di.nestjs', 'di.inversify', 'unit']
project: ['cli', 'differs.openapi', 'compilers.openapi', 'generators.openapi', 'openapi']
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '22.x'
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9.15.4
node-version: '18.x'

- uses: actions/cache@v2
- uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/pnpm-lock.yaml') }}
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}

- name: PNPM
run: pnpm install --frozen-lockfile
- name: Yarn
run: yarn --frozen-lockfile

- name: Create Coverage Directory
run: mkdir -p ${{ github.workspace }}/coverage

- name: Test
run: pnpm --filter @contractual/${{ matrix.project }} run test
run: npm run test --workspace=@contractual/${{ matrix.project }}
env:
JEST_JUNIT_OUTPUT_NAME: ${{ matrix.project }}.xml
JEST_JUNIT_OUTPUT_DIR: ${{ github.workspace }}/test-reports
Expand Down
136 changes: 23 additions & 113 deletions .github/workflows/publish-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ on:
- 'beta'
required: true
default: 'dev'
release_branch:
description: 'Release Branch'
type: choice
options:
- 'next'
- 'master'
required: true
default: 'next'
strategy:
description: 'Release Strategy'
type: choice
Expand All @@ -29,136 +37,38 @@ on:
- 'from-package'
required: true
default: 'from-package'

target_branch:
description: 'Target branch to release from'
type: choice
options:
- 'next'
- 'master'
required: true
default: 'next'
jobs:
e2e:
name: Build and Test
runs-on: ubuntu-latest
strategy:
matrix:
e2e-project: ['jest/nestjs', 'sinon/nestjs', 'vitest/nestjs', 'jest/inversify', 'sinon/inversify', 'vitest/inversify']
node-version: [16.x, 18.x, 20.x]
exclude:
- e2e-project: 'vitest/inversify'
node-version: '16.x'
- e2e-project: 'vitest/nestjs'
node-version: '16.x'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.target_branch }}

- name: Remove Vitest If Needed
if: ${{ matrix.node-version == '16.x' }}
run: |
rm -rf packages/doubles/vitest
git config --global user.email "ci@suites.dev"
git config --global user.name "Suites CI"
git add .
git commit -am "remove vitest temp"

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

- name: PNPM
run: pnpm install --frozen-lockfile

- name: Run Verdaccio Docker
run: |
docker run -d --name verdaccio \
-p 4873:4873 \
-v ${{ github.workspace }}/e2e/config.yaml:/verdaccio/conf/config.yaml \
verdaccio/verdaccio

- name: Build
run: pnpm build

- name: Setup Registry
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
registry-url: http://localhost:4873
scope: '@suites'
always-auth: false

- name: Install jq
run: sudo apt-get install jq

- name: Remove provenance from publishConfig
run: |
find packages -name 'package.json' | while read filename; do
jq 'del(.publishConfig.provenance)' "$filename" > temp.json && mv temp.json "$filename"
done

- name: Commit Change
run: |
git config --global user.email "e2e@suites.dev"
git config --global user.name "Suites e2e"
git add .
git commit -am "remove provenance"

- name: Publish Packages
run: |
pnpm publish -r \
--no-git-checks \
--access public \
--tag ci \
--force
- name: Setup and Test
run: |
IFS='/' read -r library framework <<< "${{ matrix.e2e-project }}"
echo "FRAMEWORK=$framework" >> $GITHUB_ENV
echo "LIBRARY=$library" >> $GITHUB_ENV

- name: Clean Source
run: |
rm -rf packages
rm -rf node_modules

- name: Install Dependencies
run: |
cd "$PWD/e2e/$LIBRARY/$FRAMEWORK"
npm install --no-cache --no-package-lock
npm install --dev --no-package-lock @types/node@${{ matrix.node-version }}

- name: Execute Test
run: |
cd "$PWD/e2e/$LIBRARY/$FRAMEWORK"
npm test

publish:
name: Publish Packages
needs: [e2e]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.target_branch }}

- name: Setup Registry
uses: actions/setup-node@v4
with:
registry-url: https://registry.npmjs.org/
scope: '@suites'
scope: '@contractual'
always-auth: true
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9.15.4

- name: pnpm
run: pnpm install --frozen-lockfile
- name: NPM
run: npm ci

- name: Build
run: pnpm build
run: npm run build

- name: Publish Packages
run: pnpm publish -r ${{ github.event.inputs.strategy }} --access public --tag ${{ github.event.inputs.dist_tag }}
run: npx lerna publish ${{ github.event.inputs.strategy }} --yes --dist-tag ${{ github.event.inputs.dist_tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
13 changes: 4 additions & 9 deletions .github/workflows/release-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,22 @@ jobs:
- name: Prerelease Version (Exact Version)
if: ${{ github.event.inputs.release_type == 'prerelease' && github.event.inputs.exact_version }}
run: |
pnpm version ${{ github.event.inputs.exact_version }} \
--workspaces-update \
--no-git-tag-version \
--no-commit-hooks
npx lerna version ${{ github.event.inputs.exact_version }} --yes --no-changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Prerelease Version
if: ${{ github.event.inputs.release_type == 'prerelease' && !github.event.inputs.exact_version }}
run: |
pnpm version prerelease \
npx lerna version prerelease --yes \
--preid ${{ github.event.inputs.preid }} \
--workspaces-update \
--no-git-tag-version \
--no-commit-hooks
--no-changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Graduate Version
if: ${{ github.event.inputs.release_type == 'graduate' }}
run: pnpm version --workspaces-update from-git
run: npx lerna version --conventional-graduate --yes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
Loading
Loading