64 lines
1.6 KiB
YAML
64 lines
1.6 KiB
YAML
name: API Contract Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Restore APOPHIS cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: .apophis-cache.json
|
|
key: apophis-cache-${{ github.ref }}-${{ github.sha }}
|
|
restore-keys: |
|
|
apophis-cache-${{ github.ref }}-
|
|
apophis-cache-main-
|
|
|
|
- name: Determine changed routes
|
|
id: changed
|
|
run: |
|
|
# Example: extract changed routes from git diff
|
|
# Adjust this to match your project's structure
|
|
CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | \
|
|
grep -E 'src/routes|src/schemas' | \
|
|
sed 's|src/routes||; s|\.ts$||' | \
|
|
paste -sd ',' -)
|
|
echo "routes=$CHANGED" >> $GITHUB_OUTPUT
|
|
|
|
- name: Run contract tests
|
|
run: npm test
|
|
env:
|
|
APOPHIS_LOG_LEVEL: info
|
|
APOPHIS_CHANGED_ROUTES: ${{ steps.changed.outputs.routes }}
|
|
|
|
- name: Save APOPHIS cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: .apophis-cache.json
|
|
key: apophis-cache-${{ github.ref }}-${{ github.sha }}
|
|
|
|
- name: Upload test results
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: test-results
|
|
path: |
|
|
*.tap
|
|
.apophis-cache.json
|