Skip to content

Automated Dependency Updates #39

Automated Dependency Updates

Automated Dependency Updates #39

name: Test PR on Command
# Permissions for comment-triggered testing
permissions:
contents: read # Read repository contents
pull-requests: write # Write PR reactions and comments
issues: write # Write issue reactions
checks: write # Write check results
on:
issue_comment:
types: [created]
jobs:
test-on-command:
name: Test PR on /test Command
runs-on: ubuntu-latest
# Add timeout for security
timeout-minutes: 20
# Strict conditions for security
if: |
github.event.issue.pull_request &&
contains(github.event.comment.body, '/test') &&
(github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'COLLABORATOR') &&
github.repository == 'adhocteam/usai-api'
strategy:
matrix:
node-version: [20.x, 22.x]
steps:
- name: React to comment
uses: actions/github-script@v7
with:
script: |
github.rest.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: context.payload.comment.id,
content: 'rocket'
})
- name: Get PR details
id: pr
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
})
return pr.data.head.sha
- name: Checkout PR
uses: actions/checkout@v4
with:
ref: ${{ steps.pr.outputs.result }}
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Update npm
run: |
echo "Current npm version: $(npm --version)"
npm install -g npm@latest || echo "Failed to update npm, continuing with existing version"
echo "Final npm version: $(npm --version)"
continue-on-error: true
- name: Configure npm for better reliability
run: |
echo "Configuring npm with increased timeouts and retries..."
npm config set fetch-retry-maxtimeout 60000
npm config set fetch-retry-mintimeout 10000
npm config set fetch-timeout 300000
npm config set maxsockets 15
npm config set registry https://registry.npmjs.org/
echo "npm configuration complete"
continue-on-error: true
- name: Install dependencies
run: |
echo "Node.js version: $(node --version)"
echo "npm version: $(npm --version)"
echo "Attempting npm ci..."
if npm ci; then
echo "✅ npm ci succeeded"
else
echo "❌ npm ci failed, trying recovery strategies..."
npm cache clean --force || true
if npm ci; then
echo "✅ npm ci succeeded after cache clear"
else
echo "❌ npm ci failed again, trying fresh install..."
rm -f package-lock.json
if npm install; then
echo "✅ npm install succeeded"
else
echo "❌ All npm install methods failed"
exit 1
fi
fi
fi
- name: Run linting
run: npm run lint
- name: Run tests
run: npm test
- name: Build project
run: npm run build
- name: Test examples
run: |
echo "Testing example files..."
timeout 10s node examples/basic-usage.js || echo "Expected to fail at API call - import successful"
timeout 10s node examples/embeddings.js || echo "Expected to fail at API call - import successful"
timeout 10s node examples/enhanced-features.js || echo "Expected to fail at API call - import successful"
echo "✅ All examples loaded successfully"
- name: Comment results
if: always()
uses: actions/github-script@v7
with:
script: |
const conclusion = '${{ job.status }}' === 'success' ? '✅ Tests passed' : '❌ Tests failed';
const nodeVersion = '${{ matrix.node-version }}';
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `${conclusion} for Node.js ${nodeVersion}! Check the [workflow run](${context.payload.repository.html_url}/actions/runs/${context.runId}) for details.`
})