Skip to content

Commit

Permalink
added github workflow for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
antjes88 committed Nov 9, 2023
1 parent 56e12af commit 3d66d68
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
34 changes: 34 additions & 0 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Pytest

on:
push:
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10']
max-parallel: 1
env: # Or as an environment variable
PROJECT: ${{ secrets.PROJECT }}
SOURCE_TABLE: ${{ secrets.SOURCE_TABLE }}
DESTINATION_TABLE: ${{ secrets.DESTINATION_TABLE }}
DATASET: ${{ secrets.DATASET }}
SA_JSON: ${{ secrets.SA_JSON }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python -m pip install pytest==7.4.3
- name: Test with pytest
run: |
python -m pytest -vv
10 changes: 9 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ def env_var_loader(file_name, file_path=None):
if os.path.isfile(env_path):
load_dotenv(dotenv_path=env_path)


# load env vars
env_var_loader("tests/.env")

# load path to get python files
sys.path.append(os.path.join(os.getcwd(), 'cloud_function'))

# load sa if applicable
if os.environ.get('SA_JSON'):
file_name = 'sa.json'
with open(file_name, 'r') as f:
f.write(os.environ['SA_JSON'])
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = file_name

0 comments on commit 3d66d68

Please sign in to comment.