Skip to content

Add Postman CLI and run API tests on UAT #37

Add Postman CLI and run API tests on UAT

Add Postman CLI and run API tests on UAT #37

name: ie-bank-backend
on:
push:
pull_request:
branches: [ "main" ]
workflow_dispatch:
permissions:
contents: read
id-token: write
env:
BACKEND_WEBAPP_DEV: aguadamillas-be-dev
BACKEND_WEBAPP_UAT: aguadamillas-be-uat
source_branch_name: ${{ github.ref }}
pr_target_branch_name: ${{ github.base_ref }}
jobs:
build:
runs-on: ubuntu-latest
env:
ENV: ghci
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Lint with flake8
run: |
pip install flake8 pytest
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
python -m pytest --cov=iebank_api -v
- name: Upload artifact for deployment jobs
uses: actions/upload-artifact@v2
with:
name: python-app
path: |
.
deploy-dev:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Development'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: python-app
path: .
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v2
id: deploy-to-webapp
with:
app-name: ${{ env.BACKEND_WEBAPP_DEV }}
package: .
deploy-uat:
runs-on: ubuntu-latest
needs: [build, deploy-dev]
# if: ${{ pr_target_branch_name == 'refs/heads/main' }} #deploys only on PR to main branch
environment:
name: 'User Acceptance Testing'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: python-app
path: .
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v2
id: deploy-to-webapp
with:
app-name: ${{ env.BACKEND_WEBAPP_UAT }}
package: .
- name: Install Postman CLI
run: |
curl -o- "https://dl-cli.pstmn.io/install/linux64.sh" | sh
- name: Login to Postman CLI
run: postman login --with-api-key ${{ secrets.POSTMAN_API_KEY }}
- name: Run API tests on UAT
run: |
postman collection run "1147254-bb79b80f-ce5e-4b26-85e2-c21da3697682"