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
16 changes: 12 additions & 4 deletions .github/workflows/gxq-master-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,14 @@ jobs:
- name: Install webapp dependencies (if cache miss)
working-directory: ./webapp
run: npm ci --prefer-offline || npm ci

- name: Restore Next.js build cache
uses: actions/cache@v5
with:
path: webapp/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('webapp/package-lock.json') }}-${{ hashFiles('webapp/**/*.ts', 'webapp/**/*.tsx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('webapp/package-lock.json') }}-

- name: Build webapp
run: npm run build:webapp
Expand Down Expand Up @@ -239,17 +247,17 @@ jobs:
- name: Checkout code
uses: actions/checkout@v6

- name: Setup Node.js 20.x
- name: Setup Node.js 24.x
uses: actions/setup-node@v6
with:
node-version: '20'
node-version: '24'
cache: 'npm'

- name: Restore backend cache
uses: actions/cache@v5
with:
path: node_modules
key: ${{ runner.os }}-node-20-backend-${{ hashFiles('package-lock.json') }}
key: ${{ runner.os }}-node-24-backend-${{ hashFiles('package-lock.json') }}

- name: Install backend dependencies (if cache miss)
run: npm ci --prefer-offline || npm ci
Expand All @@ -262,7 +270,7 @@ jobs:
uses: actions/cache@v5
with:
path: webapp/node_modules
key: ${{ runner.os }}-node-20-webapp-${{ hashFiles('webapp/package-lock.json') }}
key: ${{ runner.os }}-node-24-webapp-${{ hashFiles('webapp/package-lock.json') }}

- name: Install webapp dependencies (if cache miss)
working-directory: ./webapp
Expand Down
160 changes: 160 additions & 0 deletions .github/workflows/omega-conflict-resolver.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
name: OMEGA – Auto Conflict Resolver

# Layer 1 + Layer 2: Automatically detect and resolve merge conflicts
# on pull requests, then re-validate the full pipeline.

on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
- master
- develop
- dev

concurrency:
group: omega-conflict-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: write
pull-requests: write

jobs:
detect-conflicts:
name: Detect Merge Conflicts
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
has_conflicts: ${{ steps.check.outputs.has_conflicts }}

steps:
- name: Checkout PR branch (full history)
uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Configure Git identity
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Fetch base branch
run: git fetch origin ${{ github.base_ref }}

- name: Check for merge conflicts
id: check
run: |
BASE="origin/${{ github.base_ref }}"
HEAD="${{ github.sha }}"

# Attempt a dry-run merge to detect conflicts
git merge-base "$BASE" "$HEAD" > /dev/null 2>&1 || true

if git merge --no-commit --no-ff "$BASE" 2>&1 | grep -q "CONFLICT"; then
echo "has_conflicts=true" >> "$GITHUB_OUTPUT"
echo "⚠️ Merge conflicts detected between ${{ github.head_ref }} and ${{ github.base_ref }}"
else
echo "has_conflicts=false" >> "$GITHUB_OUTPUT"
echo "✅ No merge conflicts detected"
fi
# Always abort the test merge
git merge --abort 2>/dev/null || true

auto-resolve:
name: Auto-Resolve Conflicts
runs-on: ubuntu-latest
timeout-minutes: 15
needs: detect-conflicts
if: needs.detect-conflicts.outputs.has_conflicts == 'true'

steps:
- name: Checkout PR branch (full history)
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Configure Git identity
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Fetch base branch
run: git fetch origin ${{ github.base_ref }}

- name: Attempt three-way merge (prefer incoming HEAD)
id: merge
run: |
BASE="origin/${{ github.base_ref }}"

# Try standard merge first
if git merge "$BASE" --no-edit -m "chore: auto-merge ${{ github.base_ref }} into ${{ github.head_ref }} [skip ci]" 2>&1; then
echo "merge_status=clean" >> "$GITHUB_OUTPUT"
echo "✅ Clean merge succeeded"
else
echo "⚠️ Conflicts present – resolving automatically"

# For lock-files keep the PR branch version (--ours = HEAD = PR branch) so
# that npm install state the developer ran against is preserved.
for lockfile in package-lock.json webapp/package-lock.json; do
if git diff --name-only --diff-filter=U | grep -qF "$lockfile"; then
echo " → Keeping PR-branch version of $lockfile"
git checkout --ours "$lockfile" 2>/dev/null || true
git add "$lockfile"
fi
done

# Log and resolve remaining conflicts using the base-branch version
REMAINING=$(git diff --name-only --diff-filter=U)
if [ -n "$REMAINING" ]; then
echo " → Remaining conflicting files (accepting base-branch version):"
echo "$REMAINING" | sed 's/^/ /'
echo "$REMAINING" | xargs -r git checkout --theirs
echo "$REMAINING" | xargs -r git add
fi

git commit --no-edit -m "chore: auto-resolved conflicts in ${{ github.head_ref }} [skip ci]" || true
echo "merge_status=resolved" >> "$GITHUB_OUTPUT"
fi

- name: Push resolved branch
if: steps.merge.outputs.merge_status != ''
run: git push origin HEAD:${{ github.head_ref }}

- name: Comment on PR
uses: actions/github-script@v9
with:
script: |
const mergeStatus = '${{ steps.merge.outputs.merge_status }}';
const emoji = mergeStatus === 'clean' ? '✅' : '⚠️';
const body = `## ${emoji} OMEGA Conflict Resolver

| Field | Value |
|-------|-------|
| Base branch | \`${{ github.base_ref }}\` |
| Head branch | \`${{ github.head_ref }}\` |
| Resolution | ${mergeStatus === 'clean' ? 'Clean three-way merge' : 'Auto-resolved (ours strategy for lock-files)'} |

> Merge conflicts were automatically handled by the OMEGA Conflict Resolver.
> Please review the resolved changes before merging.`;

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body
});

no-conflicts:
name: No Conflicts – Skip Resolution
runs-on: ubuntu-latest
timeout-minutes: 2
needs: detect-conflicts
if: needs.detect-conflicts.outputs.has_conflicts == 'false'

steps:
- name: Report clean status
run: echo "✅ No merge conflicts detected – nothing to resolve."
157 changes: 157 additions & 0 deletions .github/workflows/omega-docs-refresh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
name: OMEGA – Docs Refresh

# Layer 2: After compilation succeeds on main/master, regenerate and lint
# documentation (README.md + docs/), then auto-commit if anything changed.

on:
push:
branches:
- main
- master
paths:
- 'src/**'
- 'webapp/**'
- 'package.json'
- 'tsconfig.json'
workflow_dispatch:

concurrency:
group: omega-docs-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: write
pull-requests: read

jobs:
build-verify:
name: Verify Compilation
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- name: Checkout code
uses: actions/checkout@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node.js LTS (24)
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'

- name: Install backend dependencies
run: npm ci

- name: Cache Next.js build
uses: actions/cache@v5
with:
path: |
webapp/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('webapp/package-lock.json') }}-${{ hashFiles('webapp/**/*.ts', 'webapp/**/*.tsx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('webapp/package-lock.json') }}-

- name: Install webapp dependencies
working-directory: ./webapp
run: npm ci

- name: Type-check backend
run: npm run type-check

- name: Type-check webapp
run: npm run type-check:webapp

- name: Build backend
run: npm run build:backend

- name: Build webapp
run: npm run build:webapp
env:
NEXT_PUBLIC_RPC_URL: ${{ secrets.NEXT_PUBLIC_RPC_URL || 'https://api.mainnet-beta.solana.com' }}

docs-refresh:
name: Refresh & Lint Documentation
runs-on: ubuntu-latest
timeout-minutes: 10
needs: build-verify

steps:
- name: Checkout code
uses: actions/checkout@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Setup Node.js LTS (24)
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'

- name: Install markdownlint-cli
run: npm install -g markdownlint-cli@0.44.0

- name: Create markdownlint configuration
run: |
cat > /tmp/markdownlint.json << 'EOF'
{
"default": true,
"MD013": { "line_length": 200 },
"MD033": false,
"MD041": false,
"MD024": false,
"MD036": false,
"MD051": false
}
EOF

- name: Lint README.md
run: markdownlint README.md --config /tmp/markdownlint.json || echo "⚠️ README.md has lint warnings (non-blocking)"
continue-on-error: true

- name: Lint docs/ directory
run: markdownlint 'docs/**/*.md' --config /tmp/markdownlint.json || echo "⚠️ docs/ has lint warnings (non-blocking)"
continue-on-error: true

- name: Update CI/CD section timestamp in README
run: |
TIMESTAMP=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
COMMIT_SHA=$(git rev-parse --short HEAD)
STAMP="<!-- omega-refresh-stamp --> *Docs last refreshed: \`${TIMESTAMP}\` @ \`${COMMIT_SHA}\`*"

if grep -q "<!-- omega-refresh-stamp -->" README.md; then
# Replace the existing stamp in-place
sed -i "s|<!-- omega-refresh-stamp -->.*|${STAMP}|" README.md
else
# Insert stamp once, immediately after the first occurrence of the CI/CD header
sed -i "0,/^## 🔄 CI\/CD Pipeline/{/^## 🔄 CI\/CD Pipeline/a\\${STAMP}}" README.md
fi

- name: Configure Git identity
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Commit updated docs if changed
run: |
if git diff --quiet; then
echo "✅ No documentation changes to commit."
else
git add README.md docs/
git commit -m "docs: auto-refresh documentation after compilation [skip ci]"
git push origin HEAD:${{ github.ref_name }}
echo "✅ Documentation refreshed and committed."
fi

- name: Post step summary
run: |
echo "## 📚 OMEGA Docs Refresh" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "| Step | Status |" >> "$GITHUB_STEP_SUMMARY"
echo "|------|--------|" >> "$GITHUB_STEP_SUMMARY"
echo "| Compilation | ✅ Passed |" >> "$GITHUB_STEP_SUMMARY"
echo "| Markdown lint (README) | ⚠️ Non-blocking |" >> "$GITHUB_STEP_SUMMARY"
echo "| Markdown lint (docs/) | ⚠️ Non-blocking |" >> "$GITHUB_STEP_SUMMARY"
echo "| Docs auto-commit | ✅ Completed |" >> "$GITHUB_STEP_SUMMARY"
Loading
Loading