Skip to content

Commit

Permalink
add testing for python3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-mangin committed Jun 11, 2024
1 parent e271b0e commit dd414b0
Show file tree
Hide file tree
Showing 12 changed files with 1,322 additions and 86 deletions.
66 changes: 0 additions & 66 deletions .github/workflows/ci.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
Expand All @@ -33,8 +22,6 @@ jobs:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/functional-3.6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Functional Legacy

on:
push:
branches: [ main, 4.2, 3.4 ]
pull_request:
branches: [ main ]

permissions:
contents: read

jobs:
build:

# runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [ "3.6" ]
os: [ "ubuntu-20.04" ]

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}

- name: run python version
run: |
python --version
- name: Install dependencies
run: |
python -m pip install --no-cache-dir --upgrade pip
pip install --no-cache-dir -r requirements.txt
pip install psutil
- name: change ownership to exa user
run : |
echo "EXABGP_DAEMON_USER=$(whoami)" >> $GITHUB_ENV
- name: Python 3.6 Coverage
run: |
./qa/bin/functional-3.6 run
50 changes: 50 additions & 0 deletions .github/workflows/functional-testing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Functional Testing

on:
push:
branches: [ main, 4.2, 3.4 ]
pull_request:
branches: [ main ]

permissions:
contents: read

jobs:
build:

# runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12" ]
os: [ "ubuntu-latest" ]

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}

- name: run python version
run: |
python --version
- name: Install dependencies
run: |
python -m pip install --no-cache-dir --upgrade pip
pip install --no-cache-dir -r requirements.txt
pip install psutil
- name: Configuration
run: |
./qa/bin/functional parsing
- name: Functional
run: |
./qa/bin/functional encoding
- name: Decoding
run: |
./qa/bin/functional decoding
39 changes: 39 additions & 0 deletions .github/workflows/linting.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Linting

on:
push:
branches: [ main, 4.2, 3.4 ]
pull_request:
branches: [ main ]

permissions:
contents: read

jobs:
build:

# runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [ "3.12" ]
os: [ "ubuntu-latest" ]

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install psutil
pip install flake8
- name: flake8
run: |
flake8 . --exclude src/exabgp/vendoring/ --exclude build/ --exclude site-packages --count --select=E9,F63,F7,F82 --show-source --statistics
41 changes: 41 additions & 0 deletions .github/workflows/unit-testing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Unit Testing

on:
push:
branches: [ main, 4.2, 3.4 ]
pull_request:
branches: [ main ]

permissions:
contents: read

jobs:
build:

# runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12" ]
os: [ "ubuntu-latest" ]

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov
- name: pytest
run: |
env PYTHONPATH=src exabgp_log_enable=false pytest --cov --cov-reset ./tests/*_test.py
18 changes: 11 additions & 7 deletions qa/bin/functional
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class Exec(object):
self.code = -1
self.stdout = b''
self.stderr = b''
self.message = ''
self._process = None
self.command = []

Expand Down Expand Up @@ -130,6 +131,7 @@ class Exec(object):
print(f'return: {self.code}')
print(f'stdout: {self.stdout}')
print(f'stderr: {self.stderr}')
print(f'message: {self.message}')
return False

def collect(self):
Expand All @@ -142,13 +144,15 @@ class Exec(object):

signal.signal(signal.SIGALRM, alarm_handler)
try:
signal.alarm(5)
signal.alarm(15)
self.stdout, self.stderr = self._process.communicate()
self.code = self._process.returncode
signal.alarm(0)
except ValueError: # I/O operation on closed file
except ValueError as exc: # I/O operation on closed file
self.message = str(exc)
pass
except Alarm:
self.message = str(exc)
pass

def terminate(self):
Expand Down Expand Up @@ -327,7 +331,7 @@ class EncodingTests(Tests):
if self._check in self.stderr:
return True

return self.failed()
return self.failed('completed successfully')

API = re.compile(r'^\s*run\s+(.*)\s*?;\s*?$')

Expand Down Expand Up @@ -498,10 +502,10 @@ class DecodingTests(Tests):

def success(self):
self.collect()
if not self.stdout:
return self.failed()
if self.stderr:
return self.failed()
return self.failed('stderr is \n' + self.stderr)
if not self.stdout:
return self.failed('no stdout received')
try:
decoded = json.loads(self.stdout)
self._cleanup(decoded)
Expand Down Expand Up @@ -601,7 +605,7 @@ class ParsingTests(Tests):
def success(self):
self.collect()
if self.code != 0:
return self.failed()
return self.failed('return code is not zero')

return self.code == 0

Expand Down
Loading

0 comments on commit dd414b0

Please sign in to comment.