Skip to content
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
7 changes: 7 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@
"prefer": "type-imports",
"disallowTypeAnnotations": false
}
],
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
]
},
"env": {
Expand Down
94 changes: 55 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,77 +1,79 @@
name: Continuous Integration
on: [pull_request]
on: pull_request

permissions:
id-token: write
contents: read
actions: read
checks: write
pull-requests: write

jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
node-version: [20.x, 22.x, 24.x]
steps:
- 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') }}

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

- name: Build
run: pnpm run build
run: pnpm 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

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

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

- name: Lint
run: pnpm run lint

- name: Validate Packages
run: pnpm manypkg check
run: pnpm lint

test:
name: Test
name: Unit Tests
runs-on: ubuntu-latest
strategy:
matrix:
project: ['doubles.jest', 'doubles.sinon', 'core.unit', 'doubles.vitest', 'di.nestjs', 'di.inversify', 'unit']
project: ['cli', 'governance', 'changesets', 'json-schema-differ', 'types']
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -80,47 +82,61 @@ jobs:
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
- uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/pnpm-lock.yaml') }}

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

- name: Build
run: pnpm build

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

- name: Test
run: pnpm --filter @contractual/${{ matrix.project }} run test
run: pnpm lerna run test --scope @contractual/${{ matrix.project }} --stream
continue-on-error: true
env:
JEST_JUNIT_OUTPUT_NAME: ${{ matrix.project }}.xml
JEST_JUNIT_OUTPUT_DIR: ${{ github.workspace }}/test-reports
JUNIT_OUTPUT_NAME: ${{ matrix.project }}
JUNIT_OUTPUT_DIR: ${{ github.workspace }}/test-reports
COVERAGE_DIR: ${{ github.workspace }}/coverage
COVERAGE_FILE: coverage-${{ matrix.project }}.xml

- name: Tests Results
uses: dorny/test-reporter@v1
if: always()
e2e:
name: E2E Tests
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
reporter: 'jest-junit'
name: Tests Results (${{ matrix.project }})
path: ${{ github.workspace }}/test-reports/${{ matrix.project }}.xml
fail-on-error: false

# - name: Upload Report to Codecov
# uses: codecov/codecov-action@v3
# with:
# name: codecov-umbrella
# flags: ${{ matrix.project }}
# token: ${{ secrets.CODECOV_TOKEN }}
# fail_ci_if_error: true
# files: ${{ github.workspace }}/coverage/coverage-${{ matrix.project }}.xml
# verbose: true
node-version: '22.x'

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9.15.4

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

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm build

- name: Run E2E Tests
run: pnpm test:e2e
162 changes: 162 additions & 0 deletions .github/workflows/e2e-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
name: E2E Release Simulation
env:
CI: true

on:
workflow_call:
inputs:
target_branch:
description: 'Branch to test release from'
required: true
type: string
workflow_dispatch:
inputs:
target_branch:
description: 'Branch to test release from'
required: true
type: string
default: 'next'

permissions:
contents: write
id-token: write

jobs:
e2e:
name: E2E (${{ matrix.e2e-project }}, Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
e2e-project: ['cli-basic', 'cli-lifecycle', 'packages-import']
node-version: [20.x, 22.x, 24.x]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.target_branch }}
fetch-depth: 0

- 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: Install dependencies
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: Wait for Verdaccio
run: |
for i in {1..30}; do
if curl -s http://localhost:4873 > /dev/null; then
echo "Verdaccio is ready"
break
fi
echo "Waiting for Verdaccio..."
sleep 1
done

- 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: '@contractual'
always-auth: false

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

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

- name: Config Git
run: |
git config --global user.email "e2e@contractual.dev"
git config --global user.name "Contractual e2e"

- name: Commit Provenance Change
run: |
git add .
git commit -am "remove provenance"

- name: Version Packages
run: |
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
npx lerna version --yes \
--conventional-commits \
--conventional-prerelease \
--preid e2e \
--no-changelog \
--allow-branch "$BRANCH_NAME" \
--no-git-tag-version \
--no-push \
--force-publish \
--no-commit-hooks

- name: Commit Packages Versions
run: |
git add .
git commit -am "bump versions"

- name: Capture Versions for Report
run: |
echo "## E2E Test Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Project:** \`${{ matrix.e2e-project }}\`" >> $GITHUB_STEP_SUMMARY
echo "**Node:** \`${{ matrix.node-version }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Versions:" >> $GITHUB_STEP_SUMMARY
lerna ls --json | jq -r '.[] | "- **\(.name)** -> `v\(.version)`"' >> $GITHUB_STEP_SUMMARY

- name: Publish Packages to Verdaccio
run: |
npx lerna publish from-package --yes \
--no-git-tag-version \
--no-push \
--no-git-reset \
--exact \
--dist-tag e2e

- name: Clean Source (simulate fresh install)
run: |
rm -rf packages
rm -rf node_modules
rm pnpm-lock.yaml
rm package.json
rm -f .npmrc

- name: Install E2E Dependencies from Verdaccio
run: |
cd "${{ github.workspace }}/e2e/${{ matrix.e2e-project }}"
npm install --registry http://localhost:4873 --no-package-lock

- name: Execute Tests
run: |
cd "${{ github.workspace }}/e2e/${{ matrix.e2e-project }}"
npm test

- name: Test Success Summary
if: success()
run: |
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Test Passed" >> $GITHUB_STEP_SUMMARY
echo "Packages work correctly when published" >> $GITHUB_STEP_SUMMARY
Loading
Loading