mirror of
https://github.com/Kong/insomnia.git
synced 2026-09-18 02:56:36 -04:00
176 lines
6.2 KiB
YAML
176 lines
6.2 KiB
YAML
name: Test App
|
|
|
|
on:
|
|
merge_group:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- develop
|
|
pull_request:
|
|
types:
|
|
- opened
|
|
- synchronize
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
permissions: {}
|
|
|
|
jobs:
|
|
Test:
|
|
timeout-minutes: 20
|
|
runs-on: ubuntu-24.04
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
packages: read
|
|
steps:
|
|
- name: Harden Runner
|
|
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
|
|
with:
|
|
egress-policy: audit
|
|
|
|
- name: Checkout branch
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
|
with:
|
|
node-version-file: .nvmrc
|
|
cache: npm
|
|
cache-dependency-path: package-lock.json
|
|
registry-url: 'https://npm.pkg.github.com'
|
|
scope: '@kong'
|
|
|
|
- name: Install packages
|
|
run: npm ci
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
|
|
|
|
- name: Lint
|
|
run: npm run lint
|
|
|
|
- name: Type checks
|
|
run: npm run type-check
|
|
|
|
- name: Unit Tests
|
|
run: npm test
|
|
|
|
- name: Check autocomplete snippets are up to date
|
|
run: |
|
|
npm run generate:autocomplete -w insomnia-scripting-environment
|
|
if ! git diff --exit-code packages/insomnia-scripting-environment/src/autocomplete-snippets.json; then
|
|
echo "::error::autocomplete-snippets.json is out of date. Run 'npm run generate:autocomplete -w insomnia-scripting-environment' and commit the result."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Check Insomnia JSON schema is up to date
|
|
run: |
|
|
npm run generate:schema -w insomnia
|
|
# `git add -N` marks any newly-generated versioned file (e.g. after a
|
|
# schema version bump) as intent-to-add so `git diff` flags it too.
|
|
git add -N schemas/
|
|
if ! git diff --exit-code schemas/; then
|
|
echo "::error::schemas/ is out of date. Run 'npm run generate:schema -w insomnia' and commit the result."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Install sandbox-vendored packages and check pins never exceed app versions
|
|
run: npm run sandbox:vendored:ci -w insomnia
|
|
|
|
- name: Check sandbox-vendored bundles are up to date
|
|
run: |
|
|
npm run sandbox:vendored:generate -w insomnia
|
|
if ! git diff --exit-code packages/insomnia/src/templating/sandbox/vendored/*.generated.ts; then
|
|
echo "::error::Sandbox-vendored bundles are out of date or hand-edited. Run 'npm run sandbox:vendored:ci -w insomnia && npm run sandbox:vendored:generate -w insomnia' and commit the result."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Check for sandbox-vendored changes
|
|
id: vendor-changed
|
|
if: github.event_name == 'pull_request'
|
|
env:
|
|
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
|
run: |
|
|
git fetch origin "$BASE_SHA" --depth=1
|
|
if git diff --name-only "$BASE_SHA"...HEAD | grep -qE '^packages/insomnia/src/templating/sandbox/(vendored/(pkg/|.*\.generated\.ts$)|module-registry\.ts$)'; then
|
|
echo "changed=true" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Sandbox-vendored regression suite
|
|
if: github.event_name != 'pull_request' || steps.vendor-changed.outputs.changed == 'true'
|
|
run: npm run sandbox:vendored:test-regression -w insomnia
|
|
|
|
- name: Check circular references
|
|
id: check-cycles
|
|
continue-on-error: true
|
|
shell: bash
|
|
run: npm run check-cycle-references | tee cycle-report.txt
|
|
|
|
- name: Post circular references PR comment
|
|
if: github.event_name == 'pull_request' && always() && steps.check-cycles.outcome != 'skipped'
|
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
const fs = require('fs');
|
|
|
|
const passed = '${{ steps.check-cycles.outcome }}' === 'success';
|
|
const report = fs.readFileSync('cycle-report.txt', 'utf8').trim();
|
|
const markdownContent = `<details>
|
|
<summary>${passed ? '✅' : '⚠️'} Circular References Report</summary>
|
|
|
|
**Status:** ${passed ? 'No new circular references' : 'New circular references detected'}
|
|
|
|
\`\`\`
|
|
${report}
|
|
\`\`\`
|
|
</details>
|
|
`;
|
|
|
|
const { data: comments } = await github.rest.issues.listComments({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: context.issue.number,
|
|
});
|
|
|
|
const botComment = comments.find(comment =>
|
|
comment.user?.type === 'Bot' &&
|
|
comment.body?.includes('Circular References Report')
|
|
);
|
|
|
|
if (passed) {
|
|
if (botComment) {
|
|
await github.rest.issues.deleteComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
comment_id: botComment.id,
|
|
});
|
|
console.log('Deleted stale PR comment (no new circular references)');
|
|
} else {
|
|
console.log('No new circular references, skipping PR comment');
|
|
}
|
|
} else if (botComment) {
|
|
await github.rest.issues.updateComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
comment_id: botComment.id,
|
|
body: markdownContent
|
|
});
|
|
console.log('Updated existing PR comment');
|
|
} else {
|
|
await github.rest.issues.createComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: context.issue.number,
|
|
body: markdownContent
|
|
});
|
|
console.log('Created new PR comment');
|
|
}
|
|
|
|
- name: Fail if new circular references found
|
|
if: steps.check-cycles.outcome == 'failure'
|
|
run: exit 1
|