azure-pipelines.yml•5.45 kB
# Azure DevOps CI/CD Pipeline for Simplifier MCP Server
# Runs unit tests, publishes test results, and publishes to npm
trigger:
branches:
include:
- main
- develop
- feature/*
paths:
exclude:
- README.md
- CLAUDE.md
- .gitignore
pr:
branches:
include:
- main
- develop
paths:
exclude:
- README.md
- CLAUDE.md
- .gitignore
pool:
vmImage: 'ubuntu-latest'
variables:
nodeVersion: '18.x'
# Only publish to npm on main branch and when not a pull request
isMainBranch: $[eq(variables['Build.SourceBranch'], 'refs/heads/main')]
isNotPR: $[eq(variables['Build.Reason'], 'IndividualCI')]
jobs:
- job: Build_and_Test
displayName: 'Build and Test'
steps:
- task: NodeTool@0
displayName: 'Install Node.js'
inputs:
versionSpec: $(nodeVersion)
- task: Cache@2
displayName: 'Cache npm dependencies'
inputs:
key: 'npm | "$(Agent.OS)" | package-lock.json'
restoreKeys: |
npm | "$(Agent.OS)"
path: $(Pipeline.Workspace)/.npm
- script: |
npm config set cache $(Pipeline.Workspace)/.npm
npm ci
displayName: 'Install dependencies'
- script: |
npm run build
displayName: 'Build TypeScript'
- script: |
npm test -- --ci --coverage --testResultsProcessor=jest-junit
displayName: 'Run unit tests'
env:
JEST_JUNIT_OUTPUT_DIR: $(Agent.TempDirectory)/test-results
JEST_JUNIT_OUTPUT_NAME: test-results.xml
- task: PublishTestResults@2
displayName: 'Publish test results'
condition: succeededOrFailed()
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '$(Agent.TempDirectory)/test-results/test-results.xml'
failTaskOnFailedTests: true
testRunTitle: 'Unit Tests'
- script: |
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' | node dist/index.js
displayName: 'Test MCP Server functionality'
env:
SIMPLIFIER_BASE_URL: 'http://localhost:8080'
SIMPLIFIER_TOKEN: TEST
- task: PublishBuildArtifacts@1
displayName: 'Publish build artifacts'
condition: succeeded()
inputs:
PathtoPublish: 'dist'
ArtifactName: 'dist'
publishLocation: 'Container'
- job: Publish_to_NPM
displayName: 'Publish to NPM'
dependsOn: Build_and_Test
condition: and(succeeded(), eq(variables.isMainBranch, true), eq(variables.isNotPR, true))
steps:
- checkout: self
displayName: 'Checkout source code'
persistCredentials: true
- task: NodeTool@0
displayName: 'Install Node.js'
inputs:
versionSpec: $(nodeVersion)
- task: Cache@2
displayName: 'Cache npm dependencies'
inputs:
key: 'npm | "$(Agent.OS)" | package-lock.json'
restoreKeys: |
npm | "$(Agent.OS)"
path: $(Pipeline.Workspace)/.npm
- script: |
npm config set cache $(Pipeline.Workspace)/.npm
npm ci
displayName: 'Install dependencies'
- script: |
npm run build
displayName: 'Build TypeScript'
- task: npmAuthenticate@0
displayName: 'NPM Authenticate'
inputs:
workingFile: .npmrc
customEndpoint: 'npm simplifierag simplifier mcp'
- script: |
git config --global user.email "azure-pipelines@simplifier.io"
git config --global user.name "Azure Pipelines"
displayName: 'Configure git for version tagging'
# NOTE: Using [skip ci] in commit message to prevent infinite pipeline loop
# When we push the updated package.json back to git, [skip ci] prevents
# the pipeline from triggering again on that version bump commit
# force is needed, because .npmrc has been changed by pipeline
- script: |
git status
echo "--"
npm version --force patch -m "chore: bump version to %s [skip ci]"
echo "##vso[task.setvariable variable=packageVersion]$(node -p "require('./package.json').version")"
displayName: 'Bump patch version with [skip ci]'
- script: |
npm publish --access public
displayName: 'Publish to NPM'
env:
NPM_TOKEN: $(NPM_TOKEN)
# Push version commit and tag to Azure Repos
# The version commit includes [skip ci] so it won't trigger another pipeline run
- script: |
echo "Current branch info:"
echo " Build.SourceBranch: $(Build.SourceBranch)"
echo " Build.SourceBranchName: $(Build.SourceBranchName)"
echo "Pushing version bump commit (with [skip ci]) to Azure Repos"
# Push from detached HEAD to the source branch
git push origin HEAD:$(Build.SourceBranch)
echo "Pushing tag to Azure Repos"
git push origin "v$(packageVersion)"
displayName: 'Push version commit and tag to Azure Repos'
condition: succeeded()
- script: |
echo "##vso[task.logissue type=warning]Successfully published @simplifierag/simplifier-mcp@$(packageVersion) to npm"
echo "##vso[build.updatebuildnumber]$(packageVersion)"
echo "=========================================="
echo "🎉 SUCCESSFUL NPM PUBLICATION"
echo "=========================================="
echo "Package: @simplifierag/simplifier-mcp"
echo "Version: $(packageVersion)"
echo "Published to: https://www.npmjs.com/package/@simplifierag/simplifier-mcp"
echo "Install with: npm install @simplifierag/simplifier-mcp"
echo "=========================================="
displayName: 'Update build number and log success'
condition: succeeded()