- Created package.json and package-lock.json for CLI package. - Implemented argument parsing in args.ts to handle various flags and commands. - Developed main CLI logic in cli.ts to execute commands and handle errors. - Added configuration loading from a JSON file in config.ts, with environment variable support. - Implemented prompt resolution and provider interaction in prompt.ts. - Added usage documentation for the CLI. - Configured TypeScript settings in tsconfig.json for the CLI package. - Updated README in vscode package to reflect the new CLI functionality. - Refactored root tsconfig.json to streamline project structure.
101 lines
3.8 KiB
YAML
101 lines
3.8 KiB
YAML
name: CI — Test & Build
|
|
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
test-and-build:
|
|
name: Test & Build
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 15
|
|
container:
|
|
image: node:22-bookworm
|
|
|
|
steps:
|
|
- name: Install system deps
|
|
run: apt-get update -qq && apt-get install -y zip curl git ca-certificates -qq
|
|
|
|
- name: Clone repository (triggering ref)
|
|
run: |
|
|
git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git /tmp/lexai
|
|
cd /tmp/lexai
|
|
if [ "${{ gitea.event_name }}" = "pull_request" ]; then
|
|
git fetch origin pull/${{ gitea.event.pull_request.number }}/head:pr
|
|
git checkout pr
|
|
else
|
|
git checkout ${{ gitea.sha }}
|
|
fi
|
|
|
|
- name: Install Chrome package dependencies
|
|
run: npm ci --prefer-offline --no-audit --no-fund
|
|
working-directory: /tmp/lexai/packages/chrome
|
|
|
|
# Generates .wxt/types (ImportMeta.env etc.) required by typecheck.
|
|
- name: Prepare WXT types
|
|
run: npx wxt prepare
|
|
working-directory: /tmp/lexai/packages/chrome
|
|
|
|
- name: Type check
|
|
run: npm run typecheck
|
|
working-directory: /tmp/lexai/packages/chrome
|
|
|
|
- name: Run unit tests
|
|
run: npm test -- --run
|
|
working-directory: /tmp/lexai/packages/chrome
|
|
|
|
- name: Build extension
|
|
run: npm run build
|
|
working-directory: /tmp/lexai/packages/chrome
|
|
|
|
- name: Verify build output
|
|
run: ls -la .output/chrome-mv3/
|
|
working-directory: /tmp/lexai/packages/chrome
|
|
|
|
- name: Package as ZIP
|
|
run: |
|
|
SHA=$(echo "${{ gitea.sha }}" | cut -c1-7)
|
|
TS=$(date +%Y%m%d%H%M%S)
|
|
VERSION=$(node -p "require('./package.json').version")-${SHA}-${TS}
|
|
zip -r /tmp/lexai-chrome-mv3-${VERSION}.zip .output/chrome-mv3/
|
|
echo "PACKAGE_VERSION=${VERSION}" >> $GITHUB_ENV
|
|
echo "✅ Packaged: lexai-chrome-mv3-${VERSION}.zip"
|
|
working-directory: /tmp/lexai/packages/chrome
|
|
|
|
- name: Publish to Gitea Package Registry
|
|
if: gitea.event_name == 'push'
|
|
run: |
|
|
RESPONSE=$(curl -s -w "\n%{http_code}" -X PUT \
|
|
"${{ gitea.server_url }}/api/packages/kibin/generic/lexai-extension/${PACKAGE_VERSION}/lexai-chrome-mv3-${PACKAGE_VERSION}.zip" \
|
|
-H "Authorization: token ${{ secrets.GITEATOKEN }}" \
|
|
-T "/tmp/lexai-chrome-mv3-${PACKAGE_VERSION}.zip")
|
|
HTTP_CODE=$(echo "$RESPONSE" | tail -n 1)
|
|
BODY=$(echo "$RESPONSE" | sed '$d')
|
|
echo "HTTP: $HTTP_CODE | Response: $BODY"
|
|
if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then
|
|
echo "✅ Published: https://git.juankibin.space/kibin/-/packages"
|
|
else
|
|
echo "⚠️ Package publish returned $HTTP_CODE: $BODY"
|
|
exit 1
|
|
fi
|
|
env:
|
|
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
|
|
|
|
- name: Notify Success
|
|
if: success()
|
|
run: |
|
|
SHA=$(echo "${{ gitea.sha }}" | cut -c1-7)
|
|
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
|
|
-d "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \
|
|
-d "text=✅ LexAI CI Passed%0A%0ABranch: ${{ gitea.ref_name }}%0ACommit: ${SHA}%0A%0AAll steps green — new build published to packages."
|
|
|
|
- name: Notify Failure
|
|
if: failure()
|
|
run: |
|
|
SHA=$(echo "${{ gitea.sha }}" | cut -c1-7)
|
|
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
|
|
-d "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \
|
|
-d "text=❌ LexAI CI FAILED%0A%0ABranch: ${{ gitea.ref_name }}%0ACommit: ${SHA}%0A%0ACheck: https://git.juankibin.space/kibin/LexAI/actions"
|