Skip to content

[FU-61] newman API 테스트 자동화 #11

[FU-61] newman API 테스트 자동화

[FU-61] newman API 테스트 자동화 #11

Workflow file for this run

name: Run Newman Tests
on:
push:
branches: ["develop"]
pull_request:
branches: ["develop"]
permissions:
issues: write
pull-requests: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install Newman
run: npm install -g newman
- name: env 설정
run: |
echo "POSTMAN_COLLECTION_ID=${{ secrets.POSTMAN_COLLECTION_ID }}" >> .env
echo "POSTMAN_API_KEY=${{ secrets.POSTMAN_API_KEY }}" >> .env
- name: Download Postman Collection
run: |
curl --location "https://api.getpostman.com/collections/$POSTMAN_COLLECTION_ID" \
--header "X-Api-Key: $POSTMAN_API_KEY" \
--output postman_collection.json
- name: Create reports directory
run: mkdir -p newman-reports
- name: Run Newman Tests
run: |
newman run postman_collection.json \
--reporters cli,junit \
--reporter-junit-export newman-reports/test-results.xml
- name: Upload Test Results
uses: actions/upload-artifact@v2
with:
name: test-results
path: newman-reports/test-results.xml
- name: Fetch Artifacts
id: fetch_artifacts
run: |
curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" > artifacts.json
cat artifacts.json
- name: Extract Artifact ID
id: extract_artifact_id
run: |
ARTIFACT_ID=$(jq -r '.artifacts[0].id' artifacts.json)
echo "artifact_id=$ARTIFACT_ID" >> $GITHUB_ENV
- name: Comment on Pull Request
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
header: 'Newman Test Results'
message: |
**Test Results:**
Test results are available [here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ env.artifact_id }}).