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
182 changes: 84 additions & 98 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,122 +12,108 @@ concurrency:
cancel-in-progress: true

jobs:
setup:
name: Setup
lint:
name: ⬣ ESLint
runs-on: ubuntu-latest
outputs:
cache-hit: ${{ steps.cache-node-modules.outputs.cache-hit }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
- name: 📦 Install pnpm
uses: pnpm/action-setup@v4

- uses: actions/setup-node@v4
- name: ⎔ Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- id: cache-node-modules
uses: actions/cache@v4
with:
path: |
node_modules
packages/*/node_modules
docs/node_modules
key: ${{ runner.os }}-modules-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-modules-

- id: cache-turbo
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-

# Always run install to ensure all dependencies are available
# This ensures workspace packages like docs have their dependencies
- run: pnpm install --frozen-lockfile

validate:
name: Validate
needs: setup
- name: 📦 Install dependencies
run: pnpm install --frozen-lockfile

- name: 🔬 Lint
run: pnpm turbo run lint --affected

typecheck:
name: ʦ TypeScript
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
- name: 📦 Install pnpm
uses: pnpm/action-setup@v4

- uses: actions/setup-node@v4
- name: ⎔ Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

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

- uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-

- run: pnpm turbo run lint --affected
- run: pnpm turbo run type-check --affected
- run: pnpm turbo run build --affected
- run: pnpm turbo run test --affected

# Debug: Check what was built
- name: Check build output
run: |
echo "Checking packages directory structure:"
find packages -name "dist" -type d || echo "No dist directories found"
ls -la packages/*/dist 2>/dev/null || echo "No dist directories to list"

- uses: actions/upload-artifact@v4
if: success()
with:
name: build-artifacts
path: packages/*/dist
if-no-files-found: warn
- name: 📦 Install dependencies
run: pnpm install --frozen-lockfile

- name: 🔎 Type check
run: pnpm turbo run type-check --affected

cache-build:
name: Cache Artifacts
needs: validate
test:
name: 🧪 Test
runs-on: ubuntu-latest
if: success()
steps:
- uses: actions/download-artifact@v4
id: download-artifacts
continue-on-error: true
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 📦 Install pnpm
uses: pnpm/action-setup@v4

- name: ⎔ Setup Node.js
uses: actions/setup-node@v4
with:
name: build-artifacts
path: packages

- name: Check artifact download
run: |
if [[ "${{ steps.download-artifacts.outcome }}" == "success" ]]; then
echo "Artifacts downloaded successfully"
ls -la packages/
else
echo "No artifacts to download - this may be expected if no packages were built"
fi

- uses: actions/cache@v4
if: steps.download-artifacts.outcome == 'success'
node-version: 20
cache: 'pnpm'

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

- name: 🧪 Run tests
run: pnpm turbo run test --affected

build:
name: 🏗 Build
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 📦 Install pnpm
uses: pnpm/action-setup@v4

- name: ⎔ Setup Node.js
uses: actions/setup-node@v4
with:
path: packages/*/dist
key: build-artifacts-${{ github.sha }}
node-version: 20
cache: 'pnpm'

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

- name: 🏗 Build packages
run: pnpm turbo run build --affected

- name: 📄 Generate docs (validate examples)
run: pnpm turbo run docgen --affected || echo "No docgen script found, skipping"

# All jobs must pass
ci:
name: ✅ CI
runs-on: ubuntu-latest
if: always()
needs: [lint, typecheck, test, build]
steps:
- name: ✅ All jobs passed
if: ${{ !(contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) }}
run: exit 0

- name: ❌ Some jobs failed
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
run: exit 1
93 changes: 33 additions & 60 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,81 +22,53 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2

- uses: pnpm/action-setup@v4
- name: ⬇️ Checkout
uses: actions/checkout@v4

- uses: actions/setup-node@v4
- name: ⎔ Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- id: cached-build-artifacts
uses: actions/cache@v4
- name: 📦 Install pnpm
uses: pnpm/action-setup@v4
with:
path: packages/*/dist
key: build-artifacts-${{ github.sha }}
restore-keys: |
build-artifacts-
run_install: false

- id: cache-node-modules
uses: actions/cache@v4
with:
path: |
node_modules
packages/*/node_modules
docs/node_modules
key: ${{ runner.os }}-modules-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-modules-
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- id: cache-turbo
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-turbo-
${{ runner.os }}-pnpm-store-

# Always run install to ensure all dependencies are available
# This ensures workspace packages like docs have their dependencies
- run: pnpm install --frozen-lockfile
- name: 📦 Install dependencies
run: pnpm install

# Always build packages to ensure we have the latest changes
# Don't rely solely on cache as it might be stale or missing
- run: pnpm turbo run build
- name: 🏗 Build packages (required for docs)
run: pnpm turbo run build

- run: pnpm turbo run docgen --filter=@evolution-sdk/evolution
- name: 📄 Generate Evolution SDK docs
run: pnpm turbo run docgen
working-directory: packages/evolution

# Build the docs with Next.js static export (output: export in next.config.js)
- run: pnpm --filter=@evolution-sdk/docs run build
- name: 📚 Copy Evolution docs to website
run: node scripts/copy-evolution-docs.mjs
working-directory: docs

- id: cache-docs-output
uses: actions/cache@v4
with:
path: docs/out
key: docs-output-${{ github.sha }}
restore-keys: |
docs-output-

# Add debug step to check if the output directory exists
- name: Debug output directory
- name: 🏗 Build documentation
run: |
echo "Checking docs build output:"
ls -la docs/
if [ -d "docs/out" ]; then
echo "docs/out directory exists:"
ls -la docs/out/
echo "Total files in docs/out:"
find docs/out -type f | wc -l
else
echo "ERROR: docs/out directory does not exist!"
exit 1
fi

- uses: actions/upload-pages-artifact@v3
cd docs
pnpm build

- name: 📤 Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/out

Expand All @@ -108,5 +80,6 @@ jobs:
runs-on: ubuntu-latest
needs: build
steps:
- id: deployment
- name: 🚀 Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4