Skip to content
Draft
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
34 changes: 34 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"extends": ["@commitlint/config-conventional"],
"rules": {
"type-enum": [
2,
"always",
[
"feat",
"fix",
"docs",
"style",
"refactor",
"perf",
"test",
"chore",
"ci",
"build"
]
],
"scope-enum": [
1,
"always",
[
"components",
"schemas",
"build",
"ci",
"docs",
"deps",
"release"
]
]
}
}
64 changes: 64 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Release

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Build schemas
run: npm run build

- name: Verify build output
run: |
echo "Checking component count..."
find components -name "schema.json" | wc -l
echo "Checking main index..."
ls -la index.js

release:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Build schemas
run: npm run build

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm run semantic-release
231 changes: 231 additions & 0 deletions .github/workflows/sync-patternfly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
name: Sync with PatternFly Release

on:
# Manual trigger
workflow_dispatch:
inputs:
patternfly_version:
description: 'PatternFly version to sync with (e.g., v5.1.0)'
required: false
type: string

# Scheduled check for new PatternFly releases (daily at 9 AM UTC)
schedule:
- cron: '0 9 * * *'

jobs:
check-patternfly-release:
runs-on: ubuntu-latest
outputs:
should_update: ${{ steps.check.outputs.should_update }}
latest_version: ${{ steps.check.outputs.latest_version }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check for new PatternFly release
id: check
run: |
# Get latest PatternFly release
LATEST_PF_VERSION=$(curl -s "https://api.github.com/repos/patternfly/patternfly/releases/latest" | jq -r '.tag_name')
echo "Latest PatternFly version: $LATEST_PF_VERSION"

# Check if we have a manual version input
if [ -n "${{ github.event.inputs.patternfly_version }}" ]; then
LATEST_PF_VERSION="${{ github.event.inputs.patternfly_version }}"
echo "Using manual version: $LATEST_PF_VERSION"
echo "should_update=true" >> $GITHUB_OUTPUT
echo "latest_version=$LATEST_PF_VERSION" >> $GITHUB_OUTPUT
exit 0
fi

# Check if this version was already processed
if git log --oneline --grep="sync with PatternFly $LATEST_PF_VERSION" | head -1; then
echo "Already synced with $LATEST_PF_VERSION"
echo "should_update=false" >> $GITHUB_OUTPUT
else
echo "New version detected: $LATEST_PF_VERSION"
echo "should_update=true" >> $GITHUB_OUTPUT
echo "latest_version=$LATEST_PF_VERSION" >> $GITHUB_OUTPUT
fi

sync-component-schemas:
needs: check-patternfly-release
if: needs.check-patternfly-release.outputs.should_update == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Try downloading pre-built props.json
id: download_props
continue-on-error: true
run: |
echo "🔍 Attempting to download pre-built props.json..."

# Strategy 1: Try from PatternFly doc-core release assets
PROPS_URL="https://github.com/patternfly/patternfly-doc-core/releases/download/${{ needs.check-patternfly-release.outputs.latest_version }}/props.json"
echo "📥 Trying release assets: $PROPS_URL"

if curl -f -L -o ./component-metadata.json "$PROPS_URL"; then
echo "✅ Downloaded props.json from release assets"
echo "downloaded=true" >> $GITHUB_OUTPUT
exit 0
fi

# Strategy 2: Try from PatternFly main repo release assets
PROPS_URL_ALT="https://github.com/patternfly/patternfly/releases/download/${{ needs.check-patternfly-release.outputs.latest_version }}/props.json"
echo "📥 Trying main repo assets: $PROPS_URL_ALT"

if curl -f -L -o ./component-metadata.json "$PROPS_URL_ALT"; then
echo "✅ Downloaded props.json from main repo assets"
echo "downloaded=true" >> $GITHUB_OUTPUT
exit 0
fi

# Strategy 3: Try from a known CDN or public URL (if PatternFly hosts it)
PROPS_URL_CDN="https://unpkg.com/@patternfly/documentation-framework@latest/props.json"
echo "📥 Trying CDN: $PROPS_URL_CDN"

if curl -f -L -o ./component-metadata.json "$PROPS_URL_CDN"; then
echo "✅ Downloaded props.json from CDN"
echo "downloaded=true" >> $GITHUB_OUTPUT
exit 0
fi

echo "❌ Pre-built props.json not available from any source, will build from source"
echo "downloaded=false" >> $GITHUB_OUTPUT

- name: Build PatternFly props from doc-core CLI
if: steps.download_props.outputs.downloaded == 'false'
run: |
echo "🔨 Building props.json using PatternFly doc-core CLI..."

# Clone the latest doc-core (which contains the CLI at cli/cli.ts)
git clone --depth 1 https://github.com/patternfly/patternfly-doc-core.git /tmp/pf-doc-core
cd /tmp/pf-doc-core

echo "📦 Installing doc-core dependencies..."
npm ci --prefer-offline --no-audit || npm install

echo "🏗️ Building doc-core CLI..."
npm run build || npm run compile || echo "Build completed with warnings"

echo "🎯 Generating props.json using official CLI..."
# Use the CLI directly as per the source code at cli/cli.ts#L65
# The CLI should generate props.json in the expected location
npm run build:props || node dist/cli/cli.js || node cli/cli.ts

echo "📂 Locating generated props.json..."
# Check multiple possible locations where props.json might be generated
if [ -f "dist/props.json" ]; then
echo "✅ Found props.json at dist/props.json"
cp dist/props.json $GITHUB_WORKSPACE/component-metadata.json
elif [ -f "props.json" ]; then
echo "✅ Found props.json at root"
cp props.json $GITHUB_WORKSPACE/component-metadata.json
elif [ -f "packages/module/dist/props.json" ]; then
echo "✅ Found props.json at packages/module/dist/props.json"
cp packages/module/dist/props.json $GITHUB_WORKSPACE/component-metadata.json
else
echo "🔍 Searching for props.json in entire directory..."
find . -name "props.json" -type f | head -10

# Try to find the most recent props.json file
PROPS_FILE=$(find . -name "props.json" -type f -printf '%T@ %p\n' | sort -k 1nr | head -1 | cut -d' ' -f2-)
if [ -n "$PROPS_FILE" ]; then
echo "✅ Using most recent props.json: $PROPS_FILE"
cp "$PROPS_FILE" $GITHUB_WORKSPACE/component-metadata.json
else
echo "❌ No props.json file found after build"
exit 1
fi
fi

echo "✅ Successfully copied props.json to component-metadata.json"

- name: Validate and regenerate schemas
run: |
# Verify the props file is valid JSON
if ! jq empty component-metadata.json; then
echo "❌ Invalid JSON in component-metadata.json"
exit 1
fi

# Count components for verification
COMPONENT_COUNT=$(jq '. | length' component-metadata.json)
echo "📊 Found $COMPONENT_COUNT components in metadata"

if [ "$COMPONENT_COUNT" -lt 100 ]; then
echo "⚠️ Warning: Component count seems low ($COMPONENT_COUNT), expected 400+"
fi

# Regenerate schemas
npm run build

# Verify schema generation
SCHEMA_COUNT=$(find components -name "schema.json" | wc -l)
echo "📊 Generated $SCHEMA_COUNT component schemas"

- name: Check for changes
id: changes
run: |
if git diff --quiet; then
echo "No changes detected"
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "Changes detected"
echo "has_changes=true" >> $GITHUB_OUTPUT
fi

- name: Commit and push changes
if: steps.changes.outputs.has_changes == 'true'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"

# Add all changes
git add .

# Create conventional commit that triggers a release
git commit -m "feat(components): sync with PatternFly ${{ needs.check-patternfly-release.outputs.latest_version }}

- Updated component metadata from PatternFly ${{ needs.check-patternfly-release.outputs.latest_version }}
- Regenerated all component schemas
- $(git diff --name-only HEAD~1 | grep -E '\.(json|js)$' | wc -l) files updated"

# Push to main (this will trigger the release workflow)
git push origin main

- name: Create issue if sync fails
if: failure()
uses: actions/github-script@v7
with:
script: |
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `Failed to sync with PatternFly ${{ needs.check-patternfly-release.outputs.latest_version }}`,
body: `The automated sync with PatternFly ${{ needs.check-patternfly-release.outputs.latest_version }} failed. Please check the workflow logs and sync manually.

**Manual sync steps:**
1. Clone https://github.com/patternfly/patternfly-doc-core
2. Run \`npm run build:props\`
3. Copy \`dist/props.json\` to \`component-metadata.json\`
4. Run \`npm run build\`
5. Commit with: \`feat(components): sync with PatternFly ${{ needs.check-patternfly-release.outputs.latest_version }}\`

Workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`,
labels: ['automation', 'sync-failed']
})
50 changes: 32 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,48 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime
.DS_Store
# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Coverage directory used by tools like istanbul
coverage/
.nyc_output

# Environment variables
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# Cache directories
.npm
.eslintcache

# Optional npm cache directory
.npm

# Semantic Release
.semanticrc

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# IDE
.vscode/
.idea/
*.swp
*.swo

# Temporary files
*.tmp
*.temp

# Logs
logs
*.log

# Coverage directory used by tools like istanbul
coverage/
*.lcov

# Build outputs (if any)
dist/
build/

# Sample/test files (optional - remove if you want to keep sample-metadata.json)
sample-metadata.json
*.log
Loading