-
Notifications
You must be signed in to change notification settings - Fork 1
161 lines (148 loc) · 6.88 KB
/
integration-tests.yml
File metadata and controls
161 lines (148 loc) · 6.88 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Integration Tests - SOAP vs REST API Comparison
on:
# Run daily at 12 PM IST (6:30 AM UTC)
schedule:
- cron: '30 6 * * *'
jobs:
integration-tests:
runs-on: ubuntu-latest
environment: CI Environment
env:
# SOAP credentials
INTEGRATION_TEST_INTACCT_SENDER_ID: ${{ secrets.INTEGRATION_TEST_INTACCT_SENDER_ID }}
INTEGRATION_TEST_INTACCT_SENDER_PASSWORD: ${{ secrets.INTEGRATION_TEST_INTACCT_SENDER_PASSWORD }}
INTEGRATION_TEST_INTACCT_USER_ID: ${{ secrets.INTEGRATION_TEST_INTACCT_USER_ID }}
INTEGRATION_TEST_INTACCT_COMPANY_ID: ${{ secrets.INTEGRATION_TEST_INTACCT_COMPANY_ID }}
INTEGRATION_TEST_INTACCT_USER_PASSWORD: ${{ secrets.INTEGRATION_TEST_INTACCT_USER_PASSWORD }}
INTEGRATION_TEST_INTACCT_ENTITY_ID: ${{ secrets.INTEGRATION_TEST_INTACCT_ENTITY_ID }}
# REST credentials
INTEGRATION_TEST_INTACCT_CLIENT_ID: ${{ secrets.INTEGRATION_TEST_INTACCT_CLIENT_ID }}
INTEGRATION_TEST_INTACCT_CLIENT_SECRET: ${{ secrets.INTEGRATION_TEST_INTACCT_CLIENT_SECRET }}
INTEGRATION_TEST_INTACCT_USERNAME: ${{ secrets.INTEGRATION_TEST_INTACCT_USERNAME }}
# Internal API credentials
INTEGRATION_TEST_INTERNAL_API_URL: ${{ secrets.INTEGRATION_TEST_INTERNAL_API_URL }}
INTEGRATION_TEST_INTERNAL_API_TOKEN: ${{ secrets.INTEGRATION_TEST_INTERNAL_API_TOKEN }}
INTEGRATION_TEST_INTERNAL_API_WORKSPACE_ID: ${{ secrets.INTEGRATION_TEST_INTERNAL_API_WORKSPACE_ID }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build & Up Docker image
run: |
docker compose -f tests/integration_tests/docker-compose-integration.yml build
docker compose -f tests/integration_tests/docker-compose-integration.yml up -d
- name: Run integration tests
id: run_tests
continue-on-error: true
run: |
mkdir -p test-reports
docker compose -f tests/integration_tests/docker-compose-integration.yml run --rm integration_test pytest tests/integration_tests -m integration -v --tb=short --junit-xml=test-reports/integration-report.xml --cov-report=xml --cov-report=term-missing | tee pytest-coverage.txt
TEST_EXIT_CODE=${PIPESTATUS[0]}
echo "test_exit_code=$TEST_EXIT_CODE" >> $GITHUB_OUTPUT
echo "Generated files:" && ls -R test-reports || echo "test-reports directory not found"
# Check if pytest ran successfully (regardless of test results)
if [ -f "pytest-coverage.txt" ]; then
echo "Pytest output captured successfully"
else
echo "ERROR: pytest-coverage.txt not found"
exit 1
fi
exit $TEST_EXIT_CODE
- name: Evaluate Coverage
if: always()
run: |
if [ "${{ steps.run_tests.outputs.test_exit_code }}" != "0" ]; then
echo "Tests failed with exit code: ${{ steps.run_tests.outputs.test_exit_code }}"
exit 1
else
echo "All tests passed successfully"
fi
- name: Extract Test Results
if: always()
id: test_results
run: |
if [ -f "pytest-coverage.txt" ]; then
PASSED=$(grep -oP '\d+(?= passed)' pytest-coverage.txt | head -1 || echo "0")
FAILED=$(grep -oP '\d+(?= failed)' pytest-coverage.txt | head -1 || echo "0")
SKIPPED=$(grep -oP '\d+(?= skipped)' pytest-coverage.txt | head -1 || echo "0")
DURATION=$(grep -oP '\d+\.\d+s' pytest-coverage.txt | tail -1 || echo "N/A")
echo "passed=$PASSED" >> $GITHUB_OUTPUT
echo "failed=$FAILED" >> $GITHUB_OUTPUT
echo "skipped=$SKIPPED" >> $GITHUB_OUTPUT
echo "duration=$DURATION" >> $GITHUB_OUTPUT
if [ "$FAILED" -gt "0" ]; then
echo "status=failure" >> $GITHUB_OUTPUT
echo "status_emoji=:x:" >> $GITHUB_OUTPUT
echo "status_color=#FF0000" >> $GITHUB_OUTPUT
else
echo "status=success" >> $GITHUB_OUTPUT
echo "status_emoji=:white_check_mark:" >> $GITHUB_OUTPUT
echo "status_color=#36a64f" >> $GITHUB_OUTPUT
fi
else
echo "status=error" >> $GITHUB_OUTPUT
echo "status_emoji=:warning:" >> $GITHUB_OUTPUT
echo "status_color=#FFA500" >> $GITHUB_OUTPUT
echo "passed=0" >> $GITHUB_OUTPUT
echo "failed=0" >> $GITHUB_OUTPUT
echo "skipped=0" >> $GITHUB_OUTPUT
echo "duration=N/A" >> $GITHUB_OUTPUT
fi
- name: Send Slack Notification
if: always()
uses: slackapi/slack-github-action@v1.25.0
with:
payload: |
{
"text": "Integration Tests - SOAP vs REST API Comparison",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "${{ steps.test_results.outputs.status_emoji }} Intacct Integration Tests ${{ steps.test_results.outputs.status == 'success' && 'Passed' || 'Failed' }}",
"emoji": true
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Status:*\n${{ steps.test_results.outputs.status == 'success' && 'Success :white_check_mark:' || 'Failed :x:' }}"
},
{
"type": "mrkdwn",
"text": "*Duration:*\n${{ steps.test_results.outputs.duration }}"
},
{
"type": "mrkdwn",
"text": "*Passed:*\n${{ steps.test_results.outputs.passed }}"
},
{
"type": "mrkdwn",
"text": "*Failed:*\n${{ steps.test_results.outputs.failed }}"
},
{
"type": "mrkdwn",
"text": "*Skipped:*\n${{ steps.test_results.outputs.skipped }}"
},
{
"type": "mrkdwn",
"text": "*Workflow:*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Details>"
}
]
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "cc: <!subteam^S03FMDZPN4C> | Triggered by: ${{ github.triggering_actor }} | Branch: ${{ github.ref_name }}"
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK