-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (94 loc) · 3.39 KB
/
run-collections.yaml
File metadata and controls
111 lines (94 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Run Postman Collections (Template)
# This is a TEMPLATE workflow. Customize it for your project.
# See docs/CI_CD.md for detailed instructions.
on:
pull_request:
branches: [main, develop]
push:
branches: [main, develop]
workflow_dispatch:
jobs:
run-collections:
name: Run Postman Collections
runs-on: ubuntu-latest
# TEMPLATE: Uncomment to test on multiple Node versions
# strategy:
# matrix:
# node-version: [18, 20]
# fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
# uses: actions/setup-node@v4
# with:
# node-version: ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Install Postman CLI
run: curl -o- "https://dl-cli.pstmn.io/install/unix.sh" | sh
# TEMPLATE: Add your project-specific setup here
# - name: Setup database
# run: |
# docker-compose up -d postgres
# npm run db:migrate
# - name: Start API server
# run: |
# npm start &
# SERVER_PID=$!
# echo "SERVER_PID=$SERVER_PID" >> $GITHUB_ENV
# - name: Wait for server
# run: |
# timeout 60 bash -c '
# until curl -f http://localhost:3000/health; do
# sleep 2
# done
# '
- name: Authenticate with Postman
env:
POSTMAN_API_KEY: ${{ secrets.POSTMAN_API_KEY }}
run: postman login --with-api-key "$POSTMAN_API_KEY"
- name: Run Postman collections
run: |
echo "📬 Running Postman collections..."
echo ""
echo "⚠️ This is a template workflow."
echo "Customize it to run your collections against your API."
echo ""
echo "Example:"
echo " postman collection run \\"
echo " postman/collections/your-api.postman_collection.json \\"
echo " --environment postman/environments/dev.postman_environment.json"
echo ""
# TEMPLATE: Uncomment and customize for your project
# for collection in postman/collections/*.postman_collection.json; do
# if [ -f "$collection" ]; then
# echo "Running: $(basename "$collection")"
# postman collection run "$collection" \
# --environment postman/environments/dev.postman_environment.json \
# --reporter cli,json \
# --reporter-json-export "results-$(basename "$collection").json"
# fi
# done
# - name: Upload test results
# if: always()
# uses: actions/upload-artifact@v3
# with:
# name: postman-results
# path: results-*.json
# - name: Stop server
# if: always()
# run: kill $SERVER_PID 2>/dev/null || true
- name: Template reminder
run: |
echo "✅ Template workflow completed!"
echo ""
echo "📚 To customize this workflow for your project:"
echo " 1. Uncomment and configure the server setup steps"
echo " 2. Update collection paths and environment files"
echo " 3. Add your API's health check endpoint"
echo " 4. See docs/CI_CD.md for detailed examples"