From 47187ab92a42cf30e4ee2b517fd4b6b71e1386d9 Mon Sep 17 00:00:00 2001 From: Bushra Asif Date: Thu, 20 Nov 2025 09:16:34 +0500 Subject: [PATCH 1/8] Update GitHub Actions workflow for Python tests --- .github/workflows/main.yml | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7a959d6..a2abbe5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,5 +1,3 @@ -# This workflow will install Python dependencies, run flake8, isort and integration tests with tox - name: Python tests on: @@ -10,22 +8,38 @@ on: jobs: test: + runs-on: ubuntu-22.04 - runs-on: ubuntu-20.04 + strategy: + matrix: + python-version: [3.6, 3.7, 3.9] steps: - - uses: actions/checkout@v2 - - name: Setup Python - run: sudo add-apt-repository -y ppa:deadsnakes/ppa && sudo apt-get install -y python3.6 python3.7 python3.9 python3.6-distutils python3.7-distutils python3.9-distutils + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - name: Install dependencies run: | - python -m pip install --upgrade pip + pip install --upgrade pip pip install responses requests six isort flake8 nose tox - + - name: Create config for integration tests - run: 'echo altapay_account=\"${{secrets.GATEWAYUSER}}\" > __init__.py && echo altapay_password=\"${{secrets.GATEWAYPASS}}\" >> __init__.py && echo altapay_url=\"${{secrets.GATEWAYURL}}/merchant/\" >> __init__.py && echo altapay_test_terminal_name=\"${{secrets.CC_TERMINAL_NAME}}\" >> __init__.py && echo altapay_invoice_test_terminal_name=\"${{ secrets.INVOICE_TERMINAL_NAME}}\" >> __init__.py && echo altapay_contract_identifier=\"${{ secrets.GATEWAY_CONTRACT_IDENTIFIER }}\" >> __init__.py' - working-directory: tests/integration - - - name: Run tests with tox + run: | + echo altapay_account="${{secrets.GATEWAYUSER}}" > __init__.py + echo altapay_password="${{secrets.GATEWAYPASS}}" >> __init__.py + echo altapay_url="${{secrets.GATEWAYURL}}/merchant/" >> __init__.py + echo altapay_test_terminal_name="${{secrets.CC_TERMINAL_NAME}}" >> __init__.py + echo altapay_invoice_test_terminal_name="${{ secrets.INVOICE_TERMINAL_NAME}}" >> __init__.py + echo altapay_contract_identifier="${{ secrets.GATEWAY_CONTRACT_IDENTIFIER }}" >> __init__.py + working-directory: tests/integration + + - name: Run tests run: tox From 997ad2baed29edefec7917c476e31c0a9696aecb Mon Sep 17 00:00:00 2001 From: Bushra Asif Date: Thu, 20 Nov 2025 09:20:56 +0500 Subject: [PATCH 2/8] Change workflow runner to Ubuntu 20.04 Updated the workflow to run on Ubuntu 20.04 instead of 22.04. --- .github/workflows/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a2abbe5..cb1c147 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,3 +1,5 @@ +# This workflow will install Python dependencies, run flake8, isort and integration tests with tox + name: Python tests on: @@ -8,7 +10,7 @@ on: jobs: test: - runs-on: ubuntu-22.04 + runs-on: ubuntu-20.04 strategy: matrix: From c397d6f0ac7c5730c88a25b4b196a6b0d67a134c Mon Sep 17 00:00:00 2001 From: Bushra Asif Date: Thu, 20 Nov 2025 09:32:27 +0500 Subject: [PATCH 3/8] Update workflow to use ubuntu-latest and install legacy Python Updated the GitHub Actions workflow to use the latest Ubuntu version and added steps to install legacy Python and pip. --- .github/workflows/main.yml | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cb1c147..82aca32 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,34 @@ on: jobs: test: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: [3.6, 3.7, 3.9] + + steps: + - uses: actions/checkout@v4 + + - name: Install legacy Python + run: | + sudo add-apt-repository -y ppa:deadsnakes/ppa + sudo apt-get update + sudo apt-get install -y python${{ matrix.python-version }} python${{ matrix.python-version }}-distutils + sudo update-alternatives --install /usr/bin/python python /usr/bin/python${{ matrix.python-version }} 1 + + - name: Install pip for legacy Python + run: | + curl -sS https://bootstrap.pypa.io/get-pip.py | sudo -H python${{ matrix.python-version }} + + - name: Install dependencies + run: python${{ matrix.python-version }} -m pip install responses requests six isort flake8 nose tox + + - name: Run tests + run: python${{ matrix.python-version }} -m tox + + test: + runs-on: ubuntu-latest strategy: matrix: From a9f0d993bd7f471526e0d94a53760cc082784625 Mon Sep 17 00:00:00 2001 From: Bushra Asif Date: Thu, 20 Nov 2025 09:34:25 +0500 Subject: [PATCH 4/8] Refactor GitHub Actions workflow for testing --- .github/workflows/main.yml | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 82aca32..19c06c0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -35,40 +35,3 @@ jobs: - name: Run tests run: python${{ matrix.python-version }} -m tox - - test: - runs-on: ubuntu-latest - - strategy: - matrix: - python-version: [3.6, 3.7, 3.9] - - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - - - name: Install dependencies - run: | - pip install --upgrade pip - pip install responses requests six isort flake8 nose tox - - - name: Create config for integration tests - run: | - echo altapay_account="${{secrets.GATEWAYUSER}}" > __init__.py - echo altapay_password="${{secrets.GATEWAYPASS}}" >> __init__.py - echo altapay_url="${{secrets.GATEWAYURL}}/merchant/" >> __init__.py - echo altapay_test_terminal_name="${{secrets.CC_TERMINAL_NAME}}" >> __init__.py - echo altapay_invoice_test_terminal_name="${{ secrets.INVOICE_TERMINAL_NAME}}" >> __init__.py - echo altapay_contract_identifier="${{ secrets.GATEWAY_CONTRACT_IDENTIFIER }}" >> __init__.py - working-directory: tests/integration - - - name: Run tests - run: tox From 2fe931cbc52c51201980bc50a5b271bb97667142 Mon Sep 17 00:00:00 2001 From: Bushra Asif Date: Thu, 20 Nov 2025 09:39:20 +0500 Subject: [PATCH 5/8] Refactor Python setup in GitHub Actions workflow Updated Python installation steps and removed matrix strategy for legacy versions. --- .github/workflows/main.yml | 40 +++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 19c06c0..65b0627 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,26 +12,40 @@ jobs: test: runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.6, 3.7, 3.9] - steps: - uses: actions/checkout@v4 - - name: Install legacy Python + # Install Python 3.6, 3.7, 3.9 from deadsnakes on Ubuntu 22.04 + - name: Setup Python run: | sudo add-apt-repository -y ppa:deadsnakes/ppa sudo apt-get update - sudo apt-get install -y python${{ matrix.python-version }} python${{ matrix.python-version }}-distutils - sudo update-alternatives --install /usr/bin/python python /usr/bin/python${{ matrix.python-version }} 1 - - name: Install pip for legacy Python - run: | - curl -sS https://bootstrap.pypa.io/get-pip.py | sudo -H python${{ matrix.python-version }} + # Install Python 3.6 (EOL - requires fallback) + sudo apt-get install -y python3.6 python3.6-distutils || true + curl -sS https://bootstrap.pypa.io/pip/3.6/get-pip.py | sudo -H python3.6 + + # Install Python 3.7 + 3.9 normally + sudo apt-get install -y python3.7 python3.7-distutils + sudo apt-get install -y python3.9 python3.9-distutils + + # Set default python → python3.9 (needed by pip install) + sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1 - name: Install dependencies - run: python${{ matrix.python-version }} -m pip install responses requests six isort flake8 nose tox + run: | + python -m pip install --upgrade pip + pip install responses requests six isort flake8 nose tox - - name: Run tests - run: python${{ matrix.python-version }} -m tox + - name: Create config for integration tests + run: | + echo altapay_account="${{secrets.GATEWAYUSER}}" > __init__.py + echo altapay_password="${{secrets.GATEWAYPASS}}" >> __init__.py + echo altapay_url="${{secrets.GATEWAYURL}}/merchant/" >> __init__.py + echo altapay_test_terminal_name="${{secrets.CC_TERMINAL_NAME}}" >> __init__.py + echo altapay_invoice_test_terminal_name="${{ secrets.INVOICE_TERMINAL_NAME}}" >> __init__.py + echo altapay_contract_identifier="${{ secrets.GATEWAY_CONTRACT_IDENTIFIER }}" >> __init__.py + working-directory: tests/integration + + - name: Run tests with tox + run: tox From 7bb4d4fd098425b4b240e36b42e966d1e1d4fe6e Mon Sep 17 00:00:00 2001 From: Bushra Asif Date: Thu, 20 Nov 2025 09:42:24 +0500 Subject: [PATCH 6/8] Update GitHub Actions workflow to use Conda --- .github/workflows/main.yml | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 65b0627..75931f8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,30 +12,26 @@ jobs: test: runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.9] + steps: - uses: actions/checkout@v4 - # Install Python 3.6, 3.7, 3.9 from deadsnakes on Ubuntu 22.04 - - name: Setup Python - run: | - sudo add-apt-repository -y ppa:deadsnakes/ppa - sudo apt-get update - - # Install Python 3.6 (EOL - requires fallback) - sudo apt-get install -y python3.6 python3.6-distutils || true - curl -sS https://bootstrap.pypa.io/pip/3.6/get-pip.py | sudo -H python3.6 - - # Install Python 3.7 + 3.9 normally - sudo apt-get install -y python3.7 python3.7-distutils - sudo apt-get install -y python3.9 python3.9-distutils - - # Set default python → python3.9 (needed by pip install) - sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1 + - name: Setup Conda Python ${{ matrix.python-version }} + uses: conda-incubator/setup-miniconda@v3 + with: + activate-environment: testenv + python-version: ${{ matrix.python-version }} + auto-update-conda: true + auto-activate-base: false + use-mamba: true - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install responses requests six isort flake8 nose tox + conda run -n testenv python -m pip install --upgrade pip + conda run -n testenv pip install responses requests six isort flake8 nose tox - name: Create config for integration tests run: | @@ -48,4 +44,5 @@ jobs: working-directory: tests/integration - name: Run tests with tox - run: tox + run: | + conda run -n testenv tox From eda64f5e740db5eba93af9eda2b3021aed07760b Mon Sep 17 00:00:00 2001 From: Bushra Asif Date: Thu, 20 Nov 2025 09:44:12 +0500 Subject: [PATCH 7/8] Refactor GitHub Actions workflow to use system Python --- .github/workflows/main.yml | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 75931f8..5c9fc3d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,27 +12,20 @@ jobs: test: runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.6, 3.7, 3.9] - steps: - uses: actions/checkout@v4 - - name: Setup Conda Python ${{ matrix.python-version }} - uses: conda-incubator/setup-miniconda@v3 - with: - activate-environment: testenv - python-version: ${{ matrix.python-version }} - auto-update-conda: true - auto-activate-base: false - use-mamba: true + - name: Setup Python + run: | + sudo add-apt-repository -y ppa:deadsnakes/ppa + sudo apt-get update + sudo apt-get install -y python3.7 python3.9 python3.7-distutils python3.9-distutils - name: Install dependencies run: | - conda run -n testenv python -m pip install --upgrade pip - conda run -n testenv pip install responses requests six isort flake8 nose tox - + python -m pip install --upgrade pip + pip install responses requests six isort flake8 nose tox + - name: Create config for integration tests run: | echo altapay_account="${{secrets.GATEWAYUSER}}" > __init__.py @@ -44,5 +37,4 @@ jobs: working-directory: tests/integration - name: Run tests with tox - run: | - conda run -n testenv tox + run: tox From ab2686bafd92158cfba2f5437bcd1861ce11d5c9 Mon Sep 17 00:00:00 2001 From: Bushra Asif Date: Thu, 20 Nov 2025 10:04:25 +0500 Subject: [PATCH 8/8] Refactor integration test config creation in workflow Consolidate echo commands into a single line for creating integration test config. --- .github/workflows/main.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5c9fc3d..960830b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,14 +27,8 @@ jobs: pip install responses requests six isort flake8 nose tox - name: Create config for integration tests - run: | - echo altapay_account="${{secrets.GATEWAYUSER}}" > __init__.py - echo altapay_password="${{secrets.GATEWAYPASS}}" >> __init__.py - echo altapay_url="${{secrets.GATEWAYURL}}/merchant/" >> __init__.py - echo altapay_test_terminal_name="${{secrets.CC_TERMINAL_NAME}}" >> __init__.py - echo altapay_invoice_test_terminal_name="${{ secrets.INVOICE_TERMINAL_NAME}}" >> __init__.py - echo altapay_contract_identifier="${{ secrets.GATEWAY_CONTRACT_IDENTIFIER }}" >> __init__.py - working-directory: tests/integration + run: 'echo altapay_account=\"${{secrets.GATEWAYUSER}}\" > __init__.py && echo altapay_password=\"${{secrets.GATEWAYPASS}}\" >> __init__.py && echo altapay_url=\"${{secrets.GATEWAYURL}}/merchant/\" >> __init__.py && echo altapay_test_terminal_name=\"${{secrets.CC_TERMINAL_NAME}}\" >> __init__.py && echo altapay_invoice_test_terminal_name=\"${{ secrets.INVOICE_TERMINAL_NAME}}\" >> __init__.py && echo altapay_contract_identifier=\"${{ secrets.GATEWAY_CONTRACT_IDENTIFIER }}\" >> __init__.py' + working-directory: tests/integration - name: Run tests with tox run: tox