name: Main Workflow on: push: branches: [ master ] pull_request: branches: ['*'] jobs: test: name: Test and Build runs-on: ubuntu-latest strategy: matrix: node-version: [18.x, 20.x] steps: - name: Checkout code uses: https://github.com/actions/checkout@v4 with: github-server-url: https://gitea.p-lao.com - name: Setup Node.js ${{ matrix.node-version }} uses: https://github.com/actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} cache: 'npm' - name: Install dependencies run: npm ci - name: Run linter run: npm run lint - name: Build project run: npm run build - name: Run tests run: npm test - name: Generate coverage report run: npm test -- --coverage --coverageReporters=lcov - name: Upload coverage reports uses: https://github.com/actions/upload-artifact@v3 if: matrix.node-version == '18.x' with: github-server-url: https://gitea.p-lao.com name: coverage-reports path: coverage/ retention-days: 30 security: name: Security Audit runs-on: ubuntu-latest steps: - name: Checkout code uses: https://github.com/actions/checkout@v4 with: github-server-url: https://gitea.p-lao.com - name: Setup Node.js uses: https://github.com/actions/setup-node@v4 with: node-version: '18.x' cache: 'npm' - name: Install dependencies run: npm ci - name: Run security audit run: npm audit --audit-level=moderate - name: Check for vulnerabilities run: npm audit --audit-level=high --production build-artifacts: name: Build Release Artifacts runs-on: ubuntu-latest needs: [test, security] if: github.ref == 'refs/heads/master' steps: - name: Checkout code uses: https://github.com/actions/checkout@v4 with: github-server-url: https://gitea.p-lao.com - name: Setup Node.js uses: https://github.com/actions/setup-node@v4 with: node-version: '18.x' cache: 'npm' - name: Install dependencies run: npm ci - name: Build project run: npm run build - name: Create distribution package run: | mkdir -p dist cp -r build/ dist/ cp package.json dist/ cp package-lock.json dist/ cp README.md dist/ cp LICENSE dist/ cp mcp-config-example.json dist/ cp -r templates/ dist/ - name: Create tarball run: | cd dist tar -czf ../drawio-mcp-server-${{ github.sha }}.tar.gz . cd .. - name: Upload build artifacts uses: https://github.com/actions/upload-artifact@v3 with: github-server-url: https://gitea.p-lao.com name: release-artifacts path: | drawio-mcp-server-${{ github.sha }}.tar.gz dist/ retention-days: 90 lint-check: name: Code Quality Check runs-on: ubuntu-latest steps: - name: Checkout code uses: https://github.com/actions/checkout@v4 with: github-server-url: https://gitea.p-lao.com - name: Setup Node.js uses: https://github.com/actions/setup-node@v4 with: node-version: '18.x' cache: 'npm' - name: Install dependencies run: npm ci - name: Check TypeScript compilation run: npx tsc --noEmit - name: Run linter with detailed output run: npm run lint -- --format=json --output-file=lint-results.json continue-on-error: true - name: Upload lint results uses: https://github.com/actions/upload-artifact@v3 if: always() with: github-server-url: https://gitea.p-lao.com name: lint-results path: lint-results.json retention-days: 7 notify: name: Notification runs-on: ubuntu-latest needs: [test, security, lint-check] if: always() steps: - name: Notify success if: needs.test.result == 'success' && needs.security.result == 'success' && needs.lint-check.result == 'success' run: | echo "✅ All checks passed successfully!" echo "Branch: ${{ github.ref_name }}" echo "Commit: ${{ github.sha }}" - name: Notify failure if: needs.test.result == 'failure' || needs.security.result == 'failure' || needs.lint-check.result == 'failure' run: | echo "❌ Some checks failed!" echo "Test result: ${{ needs.test.result }}" echo "Security result: ${{ needs.security.result }}" echo "Lint result: ${{ needs.lint-check.result }}" echo "Branch: ${{ github.ref_name }}" echo "Commit: ${{ github.sha }}" exit 1