Skip to content

Commit

Permalink
Merge pull request #450 from tlsfuzzer/migrate-to-actions-local-pytho…
Browse files Browse the repository at this point in the history
…n-submitter

Add Github Actions based CI (coveralls-python submitter)
  • Loading branch information
tomato42 authored Jan 21, 2021
2 parents 298159f + ec08486 commit c6a27b9
Show file tree
Hide file tree
Showing 3 changed files with 346 additions and 0 deletions.
342 changes: 342 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,342 @@
name: GitHub CI

on:
push:
branches:
- master
- tlslite-ng-0.7
pull_request:

jobs:
test:
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
strategy:
fail-fast: false
matrix:
include:
# first test on vanilla environments
- name: py2.7
os: ubuntu-16.04
python-version: 2.7
- name: py3.3
os: ubuntu-18.04
python-version: 3.3
- name: py3.4
os: ubuntu-18.04
python-version: 3.4
- name: py3.5
os: ubuntu-18.04
python-version: 3.5
- name: py3.6
os: ubuntu-18.04
python-version: 3.6
- name: py3.7
os: ubuntu-latest
python-version: 3.7
- name: py3.8
os: ubuntu-latest
python-version: 3.8
- name: py3.9
os: ubuntu-latest
python-version: 3.9
- name: py2.6
os: ubuntu-latest
container: centos:6
python-version: 2.6
# then test with the different optional dependencies installed
- name: py3.6 with tackpy
os: ubuntu-latest
python-version: 3.6
opt-deps: ['tackpy']
- name: py2.7 with m2crypto
os: ubuntu-16.04
python-version: 2.7
opt-deps: ['m2crypto']
- name: py3.6 with m2crypto
os: ubuntu-latest
python-version: 3.6
opt-deps: ['m2crypto']
- name: py3.7 with m2crypto
os: ubuntu-latest
python-version: 3.7
opt-deps: ['m2crypto']
- name: py3.8 with m2crypto
os: ubuntu-latest
python-version: 3.8
opt-deps: ['m2crypto']
- name: py3.9 with m2crypto
os: ubuntu-latest
python-version: 3.9
opt-deps: ['m2crypto']
- name: py2.7 with pycrypto
os: ubuntu-latest
python-version: 2.7
opt-deps: ['pycrypto']
- name: py3.6 with pycrypto
os: ubuntu-latest
python-version: 3.6
opt-deps: ['pycrypto']
- name: py3.7 with pycrypto
os: ubuntu-latest
# note: 3.7 is the last version where pycrypto is installable
python-version: 3.7
opt-deps: ['pycrypto']
- name: py3.9 with pycryptodome
os: ubuntu-latest
python-version: 3.9
# we don't support pycryptodome, just test that when it's installed
# it doesn't break pycrypto code
opt-deps: ['pycryptodome']
- name: py2.7 with gmpy
os: ubuntu-latest
python-version: 2.7
opt-deps: ['gmpy']
- name: py3.6 with gmpy
os: ubuntu-latest
python-version: 3.6
opt-deps: ['gmpy']
- name: py3.7 with gmpy
os: ubuntu-latest
python-version: 3.7
opt-deps: ['gmpy']
- name: py3.8 with gmpy
os: ubuntu-latest
python-version: 3.8
opt-deps: ['gmpy']
- name: py3.9 with gmpy
os: ubuntu-latest
python-version: 3.9
opt-deps: ['gmpy']
- name: py2.7 with gmpy2
os: ubuntu-latest
python-version: 2.7
opt-deps: ['gmpy2']
- name: py3.6 with gmpy2
os: ubuntu-latest
python-version: 3.6
opt-deps: ['gmpy2']
- name: py3.7 with gmpy2
os: ubuntu-latest
python-version: 3.7
opt-deps: ['gmpy2']
- name: py3.8 with gmpy2
os: ubuntu-latest
python-version: 3.8
opt-deps: ['gmpy2']
- name: py3.9 with gmpy2
os: ubuntu-latest
python-version: 3.9
opt-deps: ['gmpy2']
# finally test with multiple dependencies installed at the same time
- name: py2.7 with m2crypto, pycrypto, gmpy, and gmpy2
os: ubuntu-latest
python-version: 2.7
opt-deps: ['m2crypto', 'pycrypto', 'gmpy', 'gmpy2']
- name: py3.6 with m2crypto, pycrypto, gmpy, and gmpy2
os: ubuntu-latest
python-version: 3.6
opt-deps: ['m2crypto', 'pycrypto', 'gmpy', 'gmpy2']
- name: py3.7 with m2crypto, pycrypto, gmpy, and gmpy2
os: ubuntu-latest
python-version: 3.7
opt-deps: ['m2crypto', 'pycrypto', 'gmpy', 'gmpy2']
- name: py3.8 with m2crypto, gmpy, and gmpy2
os: ubuntu-latest
python-version: 3.8
opt-deps: ['m2crypto', 'gmpy', 'gmpy2']
- name: py3.8 with m2crypto, gmpy, and gmpy2
os: ubuntu-latest
python-version: 3.9
# coverage to codeclimate can be submitted just once
opt-deps: ['m2crypto', 'gmpy', 'gmpy2', 'codeclimate']
steps:
- uses: actions/checkout@v2
if: ${{ !matrix.container }}
with:
fetch-depth: 50
- uses: actions/checkout@v1
# centos 6 doesn't have glibc new enough for the nodejs used by v2
if: ${{ matrix.container }}
with:
fetch-depth: 50
- name: Ensure dependencies on CentOS
if: ${{ matrix.container }}
run: |
ls /etc/yum.repos.d/
cat /etc/yum.repos.d/CentOS-Base.repo
rm /etc/yum.repos.d/CentOS-Base.repo
cat > /etc/yum.repos.d/CentOS-Base.repo <<EOF
[base]
name=CentOS-$releasever - Base
baseurl=https://vault.centos.org/6.10/os/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[updates]
name=CentOS-$releasever - Updates
baseurl=https://vault.centos.org/6.10/updates/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[extras]
name=CentOS-$releasever - Extras
baseurl=https://vault.centos.org/6.10/extras/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
EOF
echo installing
yum clean all
yum repolist all
yum install -y git make python curl gcc libffi-devel python-devel glibc-devel openssl-devel
- name: Verify git status
run: |
git status
git remote -v
- name: Ensure we have baseline branch for quality coverage
run: git fetch origin master:refs/remotes/origin/master
- name: Set up Python ${{ matrix.python-version }}
# we use containers to use the native python version from them
if: ${{ !matrix.container }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Display installed python package versions
run: |
pip list || :
- name: Ensure working pip on 3.3
if: ${{ matrix.python-version == '3.3' }}
run: |
curl -o get-pip.py https://bootstrap.pypa.io/3.3/get-pip.py;
python get-pip.py
- name: Ensure working pip on 2.6
if: ${{ matrix.python-version == '2.6' }}
run: |
curl -o get-pip.py https://bootstrap.pypa.io/2.6/get-pip.py;
python get-pip.py
pip list
pip install setuptools==28.8.0 wheel==0.30.0a0
- name: Install M2Crypto
if: ${{ contains(matrix.opt-deps, 'm2crypto') }}
run: pip install --pre m2crypto
- name: Install tackpy
if: ${{ contains(matrix.opt-deps, 'tackpy') }}
run: pip install tackpy
- name: Install pycrypto
if: ${{ contains(matrix.opt-deps, 'pycrypto') }}
run: pip install pycrypto
- name: Install pycryptodome
if: ${{ contains(matrix.opt-deps, 'pycryptodome') }}
run: pip install pycryptodome
- name: Install gmpy
if: ${{ contains(matrix.opt-deps, 'gmpy') }}
run: pip install gmpy
- name: Install gmpy2 dependencies
if: ${{ contains(matrix.opt-deps, 'gmpy2') }}
run: sudo apt-get install -y libmpfr-dev libmpc-dev
- name: Install gmpy2
if: ${{ contains(matrix.opt-deps, 'gmpy2') }}
run: pip install gmpy2
- name: Install build dependencies
run: |
if [[ -e build-requirements-${{ matrix.python-version }}.txt ]]; then
pip install -r build-requirements-${{ matrix.python-version }}.txt;
else
pip install -r build-requirements.txt;
fi
- name: Install dependencies
run: pip install -r requirements.txt
- name: Display installed python package versions
run: pip list
- name: Prepare Codeclimate environment
if: ${{ contains(matrix.opt-deps, 'codeclimate') }}
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
- name: Run unit tests (2.7+)
if: ${{ matrix.python-version != '2.6' }}
run: coverage run --branch --source tlslite -m unittest discover
- name: Run unit tests (2.6)
if: ${{ matrix.python-version == '2.6' }}
run: coverage run --branch --source tlslite -m unittest2 discover
- name: Run connection tests
run: make test-local
- name: Combine coverage from unit tests and connection tests
run: |
coverage combine --append
coverage report -m
- name: Verify instability
run: ./setup.py install
- name: Verify install
run: make test
- name: Lint the code
# pylint doesn't work on 2.6: https://bitbucket.org/logilab/pylint/issue/390/py26-compatiblity-broken
if: ${{ matrix.python-version != '2.6' }}
run: |
pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" tlslite > pylint_report.txt || :
diff-quality --violations=pylint --fail-under=90 pylint_report.txt
- name: Verify that intermediate commits are testable
if: ${{ github.event.pull_request }}
env:
PYTHON_VERSION: ${{ matrix.python-version }}
BASE_REF: ${{ github.event.pull_request.base.ref }}
run: |
BASE_DIR="$(pwd)"
echo BASE_REF: $BASE_REF
echo GITHUB_SHA: $GITHUB_SHA
echo GITHUB_REF: $GITHUB_REF
git fetch origin $BASE_REF
COMMIT_RANGE=origin/$BASE_REF..HEAD
echo COMMIT_RANGE: $COMMIT_RANGE
echo Will test the following commits:
git log --oneline --reverse $COMMIT_RANGE
for i in $(git log --pretty=format:%H --reverse $COMMIT_RANGE); do
git checkout $i
make clean
if [[ $PYTHON_VERSION == '2.6' ]]; then
unit2 discover || exit 1
else
python -m unittest discover || exit 1
fi
make test-local || exit 1
cd "$BASE_DIR"
done
- name: Publish coverage to Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
COVERALLS_FLAG_NAME: ${{ matrix.name }}
COVERALLS_PARALLEL: true
COVERALLS_SERVICE_NAME: git hub actions
run: coveralls
- name: Publish coverage to Codeclimate
if: ${{ contains(matrix.opt-deps, 'codeclimate') }}
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: |
coverage xml
./cc-test-reporter after-build
coveralls:
name: Indicate completion to coveralls.io
needs: test
runs-on: ubuntu-latest
steps:
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Finished
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_SERVICE_NAME: git hub actions
run: |
pip install --upgrade coveralls
coveralls --service=github --finish
2 changes: 2 additions & 0 deletions build-requirements-2.6.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
isort<4.3
inflect<0.3.1
pyopenssl<18
cffi<1.14
unittest2
coverage
hypothesis<3
Expand All @@ -9,3 +10,4 @@ pylint
diff_cover
pycparser<2.19
idna<2.8
mock==2.0.0
2 changes: 2 additions & 0 deletions build-requirements-3.3.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
six>=1.10.0
enum34
coverage<5.0
hypothesis<3.44
Expand All @@ -7,3 +8,4 @@ diff_cover<2.5.0
typed-ast<1.3.0
inflect<4.0.0
typing<3.7.4
isort==4.2.5

0 comments on commit c6a27b9

Please sign in to comment.