Skip to content

feat: re-organization of repo structure #15

feat: re-organization of repo structure

feat: re-organization of repo structure #15

name: Build, Deploy, and Test All Examples
on:
workflow_dispatch:
inputs:
environment:
description: "Deployment environment (dev, staging, prod)"
required: true
default: "prod"
type: choice
options:
- dev
- staging
- prod
skip_cache:
description: "Skip build cache and force rebuild all packages"
required: false
default: true
type: boolean
plugin_version:
description: "Zephyr plugin version to upgrade to (default: next)"
required: false
default: "next"
type: string
repository_dispatch:
types: [build-deploy-test]
pull_request:
branches:
- main
paths:
- "nx/**"
- "vanilla/**"
- "turborepo/**"
- "scripts/**"
- ".github/workflows/**"
- ".github/actions/**"
push:
branches:
- main
paths:
- "nx/**"
- "vanilla/**"
- "turborepo/**"
- "scripts/**"
- ".github/workflows/**"
- ".github/actions/**"
env:
NODE_VERSION: "24"
ZE_SECRET_TOKEN: |
${{
github.event.inputs.environment == 'dev' && secrets.ZE_SECRET_TOKEN_DEV ||
github.event.inputs.environment == 'staging' && secrets.ZE_SECRET_TOKEN_STAGING ||
secrets.ZE_SECRET_TOKEN_PROD
}}
ZE_API_GATE: |
${{
github.event.inputs.environment == 'dev' && 'https://zeapi.zephyrcloudapp.dev' ||
github.event.inputs.environment == 'staging' && 'https://zeapi.zephyrcloudapp.xyz' ||
'https://zeapi.zephyrcloud.app'
}}
ZE_API: |
${{
github.event.inputs.environment == 'dev' && 'https://api-dev.zephyr-cloud.io' ||
github.event.inputs.environment == 'staging' && 'https://zephyr-api-prerelease-1a6b535d0499.herokuapp.com' ||
'https://api.zephyr-cloud.io'
}}
jobs:
setup-and-upgrade:
name: Setup and Upgrade Plugins
runs-on: ubuntu-latest
outputs:
cache-key: ${{ steps.cache-key.outputs.key }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 10.6.3
run_install: false
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: "https://registry.npmjs.org"
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: pnpm-store-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
pnpm-store-${{ runner.os }}-
- name: Install scripts dependencies
run: |
cd scripts
pnpm install --prefer-offline
- name: Upgrade Zephyr plugins
if: github.event_name != 'pull_request' && github.event_name != 'push'
run: |
cd scripts
if [ -n "${{ github.event.inputs.plugin_version }}" ]; then
echo "Upgrading plugins to version: ${{ github.event.inputs.plugin_version }}"
pnpm upgrade-plugins --version=${{ github.event.inputs.plugin_version }}
elif [ -n "${{ github.event.client_payload.plugin_version }}" ]; then
echo "Upgrading plugins to version: ${{ github.event.client_payload.plugin_version }}"
pnpm upgrade-plugins --version=${{ github.event.client_payload.plugin_version }}
else
echo "Upgrading plugins to latest (next)"
pnpm upgrade-plugins
fi
- name: Generate cache key
id: cache-key
run: |
echo "key=pnpm-store-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}" >> $GITHUB_OUTPUT
- name: Upload workspace files
uses: actions/upload-artifact@v4
with:
name: workspace-files
path: |
nx/
vanilla/
turborepo/
scripts/
.github/
retention-days: 1
build-workspace:
name: Build ${{ matrix.workspace }}
needs: setup-and-upgrade
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
workspace: [nx, vanilla, turborepo]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download workspace files
uses: actions/download-artifact@v4
with:
name: workspace-files
- uses: pnpm/action-setup@v4
with:
version: 10.6.3
run_install: false
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: "https://registry.npmjs.org"
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ needs.setup-and-upgrade.outputs.cache-key }}
restore-keys: |
pnpm-store-${{ runner.os }}-
- name: Install ${{ matrix.workspace }} dependencies
if: matrix.workspace == 'vanilla'
run: |
cd ${{ matrix.workspace }}
pnpm install --prefer-offline
- name: Install example dependencies for nx and turborepo
if: matrix.workspace == 'nx' || matrix.workspace == 'turborepo'
run: |
cd ${{ matrix.workspace }}/examples
for example in */; do
if [ -f "${example}package.json" ]; then
echo "Installing dependencies for ${example}"
cd "$example"
pnpm install --prefer-offline
cd ..
fi
done
- name: Install scripts dependencies
run: |
cd scripts
pnpm install --prefer-offline
- name: Get workspace examples
id: get-examples
run: |
cd ${{ matrix.workspace }}/examples
examples=$(ls -d */ 2>/dev/null | sed 's/\///g' | tr '\n' ',' | sed 's/,$//')
echo "examples=$examples" >> $GITHUB_OUTPUT
echo "Found examples: $examples"
- name: Build ${{ matrix.workspace }} examples
run: |
cd scripts
if [ "${{ github.event.inputs.skip_cache }}" == "true" ] || [ "${{ github.event.client_payload.skip_cache }}" == "true" ]; then
echo "Building ${{ matrix.workspace }} with --skip-cache flag"
pnpm build-packages --skip-cache --packages=${{ steps.get-examples.outputs.examples }}
else
echo "Building ${{ matrix.workspace }} with cache enabled"
pnpm build-packages --packages=${{ steps.get-examples.outputs.examples }}
fi
env:
NODE_ENV: production
ZE_SECRET_TOKEN: ${{ env.ZE_SECRET_TOKEN }}
ZE_API_GATE: ${{ env.ZE_API_GATE }}
ZE_API: ${{ env.ZE_API }}
- name: Upload ${{ matrix.workspace }} build logs
uses: actions/upload-artifact@v4
if: always()
with:
name: build-logs-${{ matrix.workspace }}
path: scripts/tmp/build/
retention-days: 3
- name: Upload zephyr deployment cache
uses: actions/upload-artifact@v4
if: always()
with:
name: zephyr-cache-${{ matrix.workspace }}
path: ~/.zephyr/
retention-days: 1
test-deployments:
name: Test All Deployments
needs: [build-workspace]
runs-on: ubuntu-latest
steps:
- name: Download workspace files
uses: actions/download-artifact@v4
with:
name: workspace-files
- name: Download zephyr deployment caches
uses: actions/download-artifact@v4
with:
pattern: zephyr-cache-*
path: zephyr-caches
merge-multiple: false
- name: Restore zephyr cache
run: |
mkdir -p ~/.zephyr
if [ -d "zephyr-caches" ]; then
for cache_dir in zephyr-caches/zephyr-cache-*/; do
if [ -d "$cache_dir" ]; then
echo "Merging cache from $cache_dir"
cp -r "$cache_dir"* ~/.zephyr/ 2>/dev/null || true
fi
done
fi
echo "Total files in zephyr cache: $(ls -1 ~/.zephyr/ 2>/dev/null | wc -l)"
- uses: pnpm/action-setup@v4
with:
version: 10.6.3
run_install: false
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install scripts dependencies
run: |
cd scripts
pnpm install --prefer-offline
- name: Wait for deployments to be ready
run: |
echo "Waiting 60 seconds for all deployments to propagate..."
sleep 60
- name: Install Playwright browsers
run: |
cd scripts
npx playwright install chromium
- name: Run deployment validation tests
run: |
cd scripts
pnpm test
env:
CI: true
ZE_SECRET_TOKEN: ${{ env.ZE_SECRET_TOKEN }}
ZE_API_GATE: ${{ env.ZE_API_GATE }}
ZE_API: ${{ env.ZE_API }}
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: |
scripts/test-results/
scripts/playwright-report/
retention-days: 7