update payment test #35
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run payment tests | |
on: | |
push: | |
branches: | |
- payment | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Environment to run the tests in' | |
required: true | |
default: 'prod' | |
type: choice | |
options: | |
- dev | |
- staging | |
- prod | |
env: | |
jsonAccountDataPath: "./accountsData.json" | |
ENVIRONMENT: 'prod' | |
jobs: | |
setup_matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Generate matrix for account IDs | |
id: set-matrix | |
run: | | |
echo "Reading account IDs from JSON for specified environment..." | |
ACCOUNT_IDS=$(python fetch_account_ids.py --environment ${{ env.ENVIRONMENT }} --jsonFile ${{ env.jsonAccountDataPath }}) | |
echo "# ----------------- ACCOUNT IDS----------------- #" | |
echo "$ACCOUNT_IDS" | |
echo "# ------------------------------------------------ #" | |
echo "matrix=$ACCOUNT_IDS" >> $GITHUB_OUTPUT | |
run_tests: | |
needs: setup_matrix | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
account: ${{fromJson(needs.setup_matrix.outputs.matrix)}} | |
steps: | |
- name: Generate uuid | |
id: uuid | |
run: | | |
echo "RANDOM_UUID=systets-$(uuidgen)" >> $GITHUB_OUTPUT | |
- name: Create k8s Kind Cluster | |
id: kind-cluster-install | |
uses: helm/[email protected] | |
with: | |
cluster_name: ${{ steps.uuid.outputs.RANDOM_UUID }} | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Set up Python environment | |
uses: actions/setup-python@v4 | |
timeout-minutes: 10 | |
with: | |
python-version: 3.8 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Run test for each account ID | |
env: | |
email_payment: ${{ secrets.EMAIL_PAYMENT }} | |
run: | | |
PASSWORD='' | |
if [ "${{ env.ENVIRONMENT }}" == "dev" ]; then | |
PASSWORD="${{ secrets.LOGIN_PASS_PAYMENT_DEV }}" | |
elif [ "${{ env.ENVIRONMENT }}" == "staging" ]; then | |
PASSWORD="${{ secrets.LOGIN_PASS_PAYMENT_STAGING }}" | |
else # Default to prod | |
PASSWORD="${{ secrets.LOGIN_PASS_PAYMENT_PROD }}" | |
fi | |
echo "Running script for account ID: ${{ matrix.account }}" | |
python payment.py --env-name "${{ env.ENVIRONMENT }}" --account-id ${{ matrix.account }} --email "${{ secrets.EMAIL_PAYMENT }}" --password "$PASSWORD" | |
- name: upload screenshots | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: screenshots | |
path: | | |
./*.png | |