Skip to content

Runtime Compatibility #51

Runtime Compatibility

Runtime Compatibility #51

Workflow file for this run

name: Runtime Compatibility
on:
schedule:
- cron: "0 0 * * 1"
workflow_dispatch:
permissions:
contents: read
jobs:
detect-changes:
name: Detect repository changes (last 7 days)
runs-on: ubuntu-latest
outputs:
has_changes: ${{ steps.diff.outputs.has_changes }}
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 0
- id: diff
name: Check for recent changes
run: |
if [ "$(git rev-list --count --since='7 days ago' HEAD)" -gt 0 ]; then
echo "has_changes=true" >> "$GITHUB_OUTPUT"
else
echo "has_changes=false" >> "$GITHUB_OUTPUT"
fi
test-deno:
name: Test with Deno
needs: detect-changes
if: needs.detect-changes.outputs.has_changes == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup Deno
uses: denoland/setup-deno@v2
with:
deno-version: 2.9.6
cache: true
- name: Run tests
run: |
deno task test:unit
deno task test:spec
test-nodejs:
name: Test with Node.js (JSR import)
needs: detect-changes
if: needs.detect-changes.outputs.has_changes == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v7.0.0
with:
node-version: 24.19
- name: Create test package
working-directory: /tmp
run: |
mkdir -p test-package
cd test-package
npm init -y
npx jsr add @anitrend/request-client
- name: Run Node.js compatibility test
working-directory: /tmp/test-package
run: |
cp ${{ github.workspace }}/examples/node-compatibility.mjs .
node node-compatibility.mjs
test-bun:
name: Test with Bun (JSR import)
needs: detect-changes
if: needs.detect-changes.outputs.has_changes == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4
- name: Create test package
working-directory: /tmp
run: |
mkdir -p test-package
cd test-package
bun init -y
bunx jsr add @anitrend/request-client
- name: Run Bun compatibility test
working-directory: /tmp/test-package
run: |
cp ${{ github.workspace }}/examples/node-compatibility.mjs ./test.mjs
bun run test.mjs
summary:
name: Compatibility Summary
runs-on: ubuntu-latest
needs: [detect-changes, test-deno, test-nodejs, test-bun]
if: always()
steps:
- name: No changes — skipped heavy jobs
if: needs.detect-changes.outputs.has_changes != 'true'
run: |
echo "## Runtime Compatibility Test Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "No repository changes in the last 7 days. Skipping compatibility tests." >> $GITHUB_STEP_SUMMARY
- name: Generate summary
if: needs.detect-changes.outputs.has_changes == 'true'
run: |
echo "## Runtime Compatibility Test Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Runtime | Status |" >> $GITHUB_STEP_SUMMARY
echo "|---------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| Deno | ${{ needs.test-deno.result == 'success' && '✅ Pass' || needs.test-deno.result == 'skipped' && '⏭️ Skipped' || '❌ Fail' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Node.js | ${{ needs.test-nodejs.result == 'success' && '✅ Pass' || needs.test-nodejs.result == 'skipped' && '⏭️ Skipped' || '❌ Fail' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Bun | ${{ needs.test-bun.result == 'success' && '✅ Pass' || needs.test-bun.result == 'skipped' && '⏭️ Skipped' || '❌ Fail' }} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Note:** Node.js and Bun tests require the package to be published to JSR." >> $GITHUB_STEP_SUMMARY