-
Notifications
You must be signed in to change notification settings - Fork 127
134 lines (116 loc) · 4.53 KB
/
public_api_tests.yml
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
name: Public API Tests
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
postman-and-sdk-tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
services:
postgres:
image: timescale/timescaledb:latest-pg14
env:
POSTGRES_USER: lotus
POSTGRES_PASSWORD: lotus
SSLMODE: PREFER
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis
ports:
- 6379:6379
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
environment: Development
env:
DJANGO_SETTINGS_MODULE: "lotus.settings"
PYTHONPATH: "."
SECRET_KEY: ${{ secrets.SECRET_KEY }}
STRIPE_LIVE_SECRET_KEY: ${{ secrets.STRIPE_LIVE_SECRET_KEY }}
STRIPE_TEST_SECRET_KEY: ${{ secrets.STRIPE_TEST_SECRET_KEY }}
DEBUG: False
KAFKA_URL: "localhost:9092"
PYTHONDONTWRITEBYTECODE: 1
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
SELF_HOSTED: "${{ secrets.SELF_HOSTED }}"
steps:
- uses: actions/checkout@v3
- name: start redpanda
uses: redpanda-data/[email protected]
with:
version: "latest"
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: "3.9"
- name: Install poetry
run: |
python -m pip install --upgrade poetry wheel
- id: cache-poetry
uses: actions/cache@v3
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cache-poetry.outputs.cache-hit != 'true'
run: |
poetry install
- name: Migrate
run: |
poetry run python manage.py migrate --noinput
- name: Install jq
run: sudo apt-get install -y jq
- name: Capture Outputs
run: |
OUTPUTS=$(poetry run python manage.py postman_ci_outputs)
KEY=$(echo "$OUTPUTS" | grep "KEY=" | cut -d= -f2)
PLAN_ID=$(echo "$OUTPUTS" | grep "PLAN_ID=" | cut -d= -f2)
INVOICE_ID=$(echo "$OUTPUTS" | grep "INVOICE_ID=" | cut -d= -f2)
ADDON_ID=$(echo "$OUTPUTS" | grep "ADDON_ID=" | cut -d= -f2)
METRIC_ID=$(echo "$OUTPUTS" | grep "METRIC_ID=" | cut -d= -f2)
UNUSED_METRIC_ID=$(echo "$OUTPUTS" | grep "UNUSED_MID=" | cut -d= -f2)
FEATURE_ID=$(echo "$OUTPUTS" | grep "FEATURE_ID=" | cut -d= -f2)
FEATURE_NAME=$(echo "$OUTPUTS" | grep "FEATURE_NAME=" | cut -d= -f2)
EVENT_NAME=$(echo "$OUTPUTS" | grep "EVENT_NAME=" | cut -d= -f2)
CUSTOMER_ID=$(echo "$OUTPUTS" | grep "CUSTOMER_ID=" | cut -d= -f2)
ENV_JSON=$(jq -n \
--arg key "$KEY" \
--arg plan_id "$PLAN_ID" \
--arg invoice_id "$INVOICE_ID" \
--arg addon_id "$ADDON_ID" \
--arg metric_id "$METRIC_ID" \
--arg feature_name "$FEATURE_NAME" \
--arg feature_id "$FEATURE_ID" \
--arg event_name "$EVENT_NAME" \
--arg customer_id "$CUSTOMER_ID" \
'{KEY: $key, PLAN_ID: $plan_id, INVOICE_ID: $invoice_id, ADDON_ID: $addon_id, METRIC_ID: $metric_id, FEATURE_NAME: $feature_name, FEATURE_ID: $feature_id,EVENT_NAME: $event_name, CUSTOMER_ID: $customer_id, URL: "http://localhost:8000"}')
echo "$ENV_JSON" > environment.json
echo "LOTUS_API_KEY=$KEY" >> $GITHUB_ENV
echo "PLAN_ID=$PLAN_ID" >> $GITHUB_ENV
echo "METRIC_ID=$METRIC_ID" >> $GITHUB_ENV
echo "UNUSED_METRIC_ID=$UNUSED_METRIC_ID" >> $GITHUB_ENV
echo "FEATURE_ID=$FEATURE_ID" >> $GITHUB_ENV
echo "ADDON_ID=$ADDON_ID" >> $GITHUB_ENV
echo "LOTUS_HOST=http://localhost:8000" >> $GITHUB_ENV
- name: Run server
run: |
poetry run python manage.py runserver &
- name: Run Postman
uses: anthonyvscode/newman-action@v1
with:
apiKey: ${{ secrets.postmanApiKey }}
collection: 18225965-f895719c-ab58-4f3d-ba21-5c918691697e
environment: environment.json
reporters: cli
- name: Output summary to console
run: echo ${{ steps.run-newman.outputs.summary }}