Skip to content

Commit ac81097

Browse files
authored
Merge pull request #72 from ntuscse/task/SCSE-210
[SCSE-210] Fix GitHub Actions: Fix missing env vars in CI
2 parents 36e7e6c + 0c83c24 commit ac81097

File tree

10 files changed

+300
-2562
lines changed

10 files changed

+300
-2562
lines changed

.coveragerc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[run]
2+
omit = **/__init__.py

.github/workflows/ci.yml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Setup Node
2323
uses: actions/setup-node@v2
2424
with:
25-
node-version: "14"
25+
node-version: "16"
2626

2727
- name: Setup Python
2828
uses: actions/setup-python@v2
@@ -38,6 +38,17 @@ jobs:
3838
virtualenvs-path: ./poetry_virtualenv
3939
installer-parallel: true
4040

41+
- name: Create dummy .env file for tests
42+
run: |
43+
touch .env
44+
echo "
45+
STRIPE_SECRET_KEY=key
46+
FRONTEND_HOST='http://localhost:3000'
47+
PRODUCTS_TABLE_NAME=testing-products
48+
PRODUCT_CATEGORIES_TABLE_NAME=testing-products-categories
49+
ORDER_HOLD_TABLE_NAME=testing-order-hold
50+
" >> .env
51+
4152
- name: Setup aws dummy credentials
4253
run: |
4354
mkdir ~/.aws
@@ -47,7 +58,7 @@ jobs:
4758
run: npm run setup
4859

4960
- name: Pytest
50-
run: npm run test
61+
run: npm run test:py # TODO: change this to `npm run test`
5162

5263
env:
5364
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
@@ -63,6 +74,11 @@ jobs:
6374
FRONTEND_HOST: 'https://dev.merch.ntuscse.com'
6475

6576
BASE_API_SERVER_URL: 'https://api.dev.ntuscse.com'
77+
78+
- name: Pytest coverage comment
79+
uses: MishaKav/pytest-coverage-comment@main
80+
with:
81+
pytest-xml-coverage-path: ./coverage.xml
6682

6783
lint:
6884
runs-on: ubuntu-latest
@@ -78,9 +94,20 @@ jobs:
7894
- name: Setup Python
7995
uses: actions/setup-python@v2
8096
with:
81-
python-version: "3.9"
97+
python-version: "3.9.16"
8298
architecture: "x64"
8399

100+
- name: Create dummy .env file for lint
101+
run: |
102+
touch .env
103+
echo "
104+
STRIPE_SECRET_KEY=key
105+
FRONTEND_HOST='http://localhost:3000'
106+
PRODUCTS_TABLE_NAME=testing-products
107+
PRODUCT_CATEGORIES_TABLE_NAME=testing-products-categories
108+
ORDER_HOLD_TABLE_NAME=testing-order-hold
109+
" >> .env
110+
84111
- name: Install and configure Poetry
85112
uses: snok/install-poetry@v1
86113
with:

.gitignore

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,14 @@ node_modules/
1414
out/
1515
docs_server/swagger/openapi.json
1616

17-
.env.*
17+
#env vars
18+
.env.*
19+
20+
# pytest
21+
/.pytest_cache/
22+
23+
# test coverage
24+
/.coverage
25+
/coverage_html/
26+
/coverage.lcov
27+
/coverage.xml

be/api/v1/endpoints/payments/intent/post_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
import pytest
12
from utils.test_app import createTestClient
23
from be.api.v1.endpoints.payments.intent.post import router
34

45
client = createTestClient(router)
56

7+
8+
@pytest.mark.skip(
9+
reason="test fails in ci, stripe key is not valid. we should mock the stripe library. DO NOT USE A LIVE OR TEST "
10+
"STRIPE KEY IN CI!")
611
def test_post_payment_intent():
712
req_body = {"amount": 200}
813
response = client.post("/payments/intent", json=req_body)

0 commit comments

Comments
 (0)