-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (114 loc) · 4.2 KB
/
api-dog-e2e-tests.yml
File metadata and controls
126 lines (114 loc) · 4.2 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: "API Dog E2E Tests"
# This reusable workflow handles automated API testing using Apidog CLI
# It runs API test scenarios and generates HTML reports
on:
workflow_call:
inputs:
node_version:
description: 'Node.js version to use'
type: string
default: '20'
test_iterations:
description: 'Number of test iterations'
type: string
default: '1'
output_formats:
description: 'Output report formats (comma-separated)'
type: string
default: 'html,cli'
runner_type:
description: 'GitHub runner type to use'
type: string
default: 'firmino-lxc-runners'
auto_detect_environment:
description: 'Enable automatic environment detection from tag (beta/rc)'
type: boolean
default: false
secrets:
test_scenario_id:
description: 'Apidog test scenario ID'
required: true
apidog_access_token:
description: 'Apidog access token for authentication'
required: true
environment_id:
description: 'Apidog environment ID (optional - will auto-detect from tag if not provided)'
required: false
dev_environment_id:
description: 'Apidog dev environment ID (for beta tags)'
required: false
stg_environment_id:
description: 'Apidog staging environment ID (for rc tags)'
required: false
jobs:
api-dog-e2e-tests:
runs-on: ${{ inputs.runner_type }}
steps:
- name: Checkout Repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ inputs.node_version }}
- name: Install Apidog CLI
run: npm install -g apidog-cli
- name: Determine environment ID based on tag
if: ${{ inputs.auto_detect_environment }}
id: set-env
run: |
TAG_NAME="${{ github.ref_name }}"
echo "Processing tag: $TAG_NAME"
if [[ "$TAG_NAME" == *"-beta."* ]]; then
echo "ENVIRONMENT_ID=${{ secrets.dev_environment_id }}" >> $GITHUB_ENV
echo "TAG_TYPE=beta" >> $GITHUB_ENV
echo "Detected beta tag - using dev environment"
elif [[ "$TAG_NAME" == *"-rc."* ]]; then
echo "ENVIRONMENT_ID=${{ secrets.stg_environment_id }}" >> $GITHUB_ENV
echo "TAG_TYPE=rc" >> $GITHUB_ENV
echo "Detected rc tag - using stg environment"
else
echo "::error::Unrecognized tag format for e2e tests: $TAG_NAME. Expected a tag containing '-beta.' or '-rc.'"
exit 1
fi
- name: Set manual environment ID
if: ${{ !inputs.auto_detect_environment }}
run: |
echo "ENVIRONMENT_ID=${{ secrets.environment_id }}" >> $GITHUB_ENV
echo "TAG_TYPE=manual" >> $GITHUB_ENV
- name: Run Apidog Test Scenario
env:
APIDOG_ACCESS_TOKEN: ${{ secrets.apidog_access_token }}
run: |
echo "Running e2e tests for $TAG_TYPE environment with ID: $ENVIRONMENT_ID"
apidog run \
--access-token "$APIDOG_ACCESS_TOKEN" \
--test-scenario ${{ secrets.test_scenario_id }} \
-e ${{ env.ENVIRONMENT_ID }} \
--color on \
-n ${{ inputs.test_iterations }} \
-r ${{ inputs.output_formats }} \
--out-dir ./apidog-reports
- name: Upload Test Reports
if: always()
uses: actions/upload-artifact@v7
with:
name: apidog-e2e-test-reports-${{ env.TAG_TYPE }}
path: ./apidog-reports
retention-days: 30
- name: Cleanup apidog-cli
if: always()
run: |
npm uninstall -g apidog-cli || true
rm -rf $(npm root -g)/apidog-cli || true
# TODO: Add Slack notification when ready
# notify:
# name: Notify
# needs: [api-dog-e2e-tests]
# if: always()
# uses: ./.github/workflows/slack-notify.yml
# with:
# status: ${{ needs.api-dog-e2e-tests.result }}
# workflow_name: "API Dog E2E Tests"
# failed_jobs: ${{ needs.api-dog-e2e-tests.result == 'failure' && 'E2E Tests' || '' }}
# secrets:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}