|
| 1 | +name: GitHub CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + - tlslite-ng-0.7 |
| 8 | + pull_request: |
| 9 | + |
| 10 | +jobs: |
| 11 | + test: |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + container: ${{ matrix.container }} |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + include: |
| 18 | + # first test on vanilla environments |
| 19 | + - name: py2.7 |
| 20 | + os: ubuntu-16.04 |
| 21 | + python-version: 2.7 |
| 22 | + - name: py3.3 |
| 23 | + os: ubuntu-18.04 |
| 24 | + python-version: 3.3 |
| 25 | + - name: py3.4 |
| 26 | + os: ubuntu-18.04 |
| 27 | + python-version: 3.4 |
| 28 | + - name: py3.5 |
| 29 | + os: ubuntu-18.04 |
| 30 | + python-version: 3.5 |
| 31 | + - name: py3.6 |
| 32 | + os: ubuntu-18.04 |
| 33 | + python-version: 3.6 |
| 34 | + - name: py3.7 |
| 35 | + os: ubuntu-latest |
| 36 | + python-version: 3.7 |
| 37 | + - name: py3.8 |
| 38 | + os: ubuntu-latest |
| 39 | + python-version: 3.8 |
| 40 | + - name: py3.9 |
| 41 | + os: ubuntu-latest |
| 42 | + python-version: 3.9 |
| 43 | + - name: py2.6 |
| 44 | + os: ubuntu-latest |
| 45 | + container: centos:6 |
| 46 | + python-version: 2.6 |
| 47 | + # then test with the different optional dependencies installed |
| 48 | + - name: py3.6 with tackpy |
| 49 | + os: ubuntu-latest |
| 50 | + python-version: 3.6 |
| 51 | + opt-deps: ['tackpy'] |
| 52 | + - name: py2.7 with m2crypto |
| 53 | + os: ubuntu-16.04 |
| 54 | + python-version: 2.7 |
| 55 | + opt-deps: ['m2crypto'] |
| 56 | + - name: py3.6 with m2crypto |
| 57 | + os: ubuntu-latest |
| 58 | + python-version: 3.6 |
| 59 | + opt-deps: ['m2crypto'] |
| 60 | + - name: py3.7 with m2crypto |
| 61 | + os: ubuntu-latest |
| 62 | + python-version: 3.7 |
| 63 | + opt-deps: ['m2crypto'] |
| 64 | + - name: py3.8 with m2crypto |
| 65 | + os: ubuntu-latest |
| 66 | + python-version: 3.8 |
| 67 | + opt-deps: ['m2crypto'] |
| 68 | + - name: py3.9 with m2crypto |
| 69 | + os: ubuntu-latest |
| 70 | + python-version: 3.9 |
| 71 | + opt-deps: ['m2crypto'] |
| 72 | + - name: py2.7 with pycrypto |
| 73 | + os: ubuntu-latest |
| 74 | + python-version: 2.7 |
| 75 | + opt-deps: ['pycrypto'] |
| 76 | + - name: py3.6 with pycrypto |
| 77 | + os: ubuntu-latest |
| 78 | + python-version: 3.6 |
| 79 | + opt-deps: ['pycrypto'] |
| 80 | + - name: py3.7 with pycrypto |
| 81 | + os: ubuntu-latest |
| 82 | + # note: 3.7 is the last version where pycrypto is installable |
| 83 | + python-version: 3.7 |
| 84 | + opt-deps: ['pycrypto'] |
| 85 | + - name: py3.9 with pycryptodome |
| 86 | + os: ubuntu-latest |
| 87 | + python-version: 3.9 |
| 88 | + # we don't support pycryptodome, just test that when it's installed |
| 89 | + # it doesn't break pycrypto code |
| 90 | + opt-deps: ['pycryptodome'] |
| 91 | + - name: py2.7 with gmpy |
| 92 | + os: ubuntu-latest |
| 93 | + python-version: 2.7 |
| 94 | + opt-deps: ['gmpy'] |
| 95 | + - name: py3.6 with gmpy |
| 96 | + os: ubuntu-latest |
| 97 | + python-version: 3.6 |
| 98 | + opt-deps: ['gmpy'] |
| 99 | + - name: py3.7 with gmpy |
| 100 | + os: ubuntu-latest |
| 101 | + python-version: 3.7 |
| 102 | + opt-deps: ['gmpy'] |
| 103 | + - name: py3.8 with gmpy |
| 104 | + os: ubuntu-latest |
| 105 | + python-version: 3.8 |
| 106 | + opt-deps: ['gmpy'] |
| 107 | + - name: py3.9 with gmpy |
| 108 | + os: ubuntu-latest |
| 109 | + python-version: 3.9 |
| 110 | + opt-deps: ['gmpy'] |
| 111 | + - name: py2.7 with gmpy2 |
| 112 | + os: ubuntu-latest |
| 113 | + python-version: 2.7 |
| 114 | + opt-deps: ['gmpy2'] |
| 115 | + - name: py3.6 with gmpy2 |
| 116 | + os: ubuntu-latest |
| 117 | + python-version: 3.6 |
| 118 | + opt-deps: ['gmpy2'] |
| 119 | + - name: py3.7 with gmpy2 |
| 120 | + os: ubuntu-latest |
| 121 | + python-version: 3.7 |
| 122 | + opt-deps: ['gmpy2'] |
| 123 | + - name: py3.8 with gmpy2 |
| 124 | + os: ubuntu-latest |
| 125 | + python-version: 3.8 |
| 126 | + opt-deps: ['gmpy2'] |
| 127 | + - name: py3.9 with gmpy2 |
| 128 | + os: ubuntu-latest |
| 129 | + python-version: 3.9 |
| 130 | + opt-deps: ['gmpy2'] |
| 131 | + # finally test with multiple dependencies installed at the same time |
| 132 | + - name: py2.7 with m2crypto, pycrypto, gmpy, and gmpy2 |
| 133 | + os: ubuntu-latest |
| 134 | + python-version: 2.7 |
| 135 | + opt-deps: ['m2crypto', 'pycrypto', 'gmpy', 'gmpy2'] |
| 136 | + - name: py3.6 with m2crypto, pycrypto, gmpy, and gmpy2 |
| 137 | + os: ubuntu-latest |
| 138 | + python-version: 3.6 |
| 139 | + opt-deps: ['m2crypto', 'pycrypto', 'gmpy', 'gmpy2'] |
| 140 | + - name: py3.7 with m2crypto, pycrypto, gmpy, and gmpy2 |
| 141 | + os: ubuntu-latest |
| 142 | + python-version: 3.7 |
| 143 | + opt-deps: ['m2crypto', 'pycrypto', 'gmpy', 'gmpy2'] |
| 144 | + - name: py3.8 with m2crypto, gmpy, and gmpy2 |
| 145 | + os: ubuntu-latest |
| 146 | + python-version: 3.8 |
| 147 | + opt-deps: ['m2crypto', 'gmpy', 'gmpy2'] |
| 148 | + - name: py3.8 with m2crypto, gmpy, and gmpy2 |
| 149 | + os: ubuntu-latest |
| 150 | + python-version: 3.9 |
| 151 | + # coverage to codeclimate can be submitted just once |
| 152 | + opt-deps: ['m2crypto', 'gmpy', 'gmpy2', 'codeclimate'] |
| 153 | + steps: |
| 154 | + - uses: actions/checkout@v2 |
| 155 | + if: ${{ !matrix.container }} |
| 156 | + with: |
| 157 | + fetch-depth: 50 |
| 158 | + - uses: actions/checkout@v1 |
| 159 | + # centos 6 doesn't have glibc new enough for the nodejs used by v2 |
| 160 | + if: ${{ matrix.container }} |
| 161 | + with: |
| 162 | + fetch-depth: 50 |
| 163 | + - name: Ensure dependencies on CentOS |
| 164 | + if: ${{ matrix.container }} |
| 165 | + run: | |
| 166 | + ls /etc/yum.repos.d/ |
| 167 | + cat /etc/yum.repos.d/CentOS-Base.repo |
| 168 | + rm /etc/yum.repos.d/CentOS-Base.repo |
| 169 | + cat > /etc/yum.repos.d/CentOS-Base.repo <<EOF |
| 170 | + [base] |
| 171 | + name=CentOS-$releasever - Base |
| 172 | + baseurl=https://vault.centos.org/6.10/os/x86_64/ |
| 173 | + gpgcheck=1 |
| 174 | + gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 |
| 175 | +
|
| 176 | + [updates] |
| 177 | + name=CentOS-$releasever - Updates |
| 178 | + baseurl=https://vault.centos.org/6.10/updates/x86_64/ |
| 179 | + gpgcheck=1 |
| 180 | + gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 |
| 181 | +
|
| 182 | + [extras] |
| 183 | + name=CentOS-$releasever - Extras |
| 184 | + baseurl=https://vault.centos.org/6.10/extras/x86_64/ |
| 185 | + gpgcheck=1 |
| 186 | + gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 |
| 187 | +
|
| 188 | + EOF |
| 189 | + echo installing |
| 190 | + yum clean all |
| 191 | + yum repolist all |
| 192 | + yum install -y git make python curl gcc libffi-devel python-devel glibc-devel openssl-devel |
| 193 | + - name: Verify git status |
| 194 | + run: | |
| 195 | + git status |
| 196 | + git remote -v |
| 197 | + - name: Ensure we have baseline branch for quality coverage |
| 198 | + run: git fetch origin master:refs/remotes/origin/master |
| 199 | + - name: Set up Python ${{ matrix.python-version }} |
| 200 | + # we use containers to use the native python version from them |
| 201 | + if: ${{ !matrix.container }} |
| 202 | + uses: actions/setup-python@v2 |
| 203 | + with: |
| 204 | + python-version: ${{ matrix.python-version }} |
| 205 | + - name: Display Python version |
| 206 | + run: python -c "import sys; print(sys.version)" |
| 207 | + - name: Display installed python package versions |
| 208 | + run: | |
| 209 | + pip list || : |
| 210 | + - name: Ensure working pip on 3.3 |
| 211 | + if: ${{ matrix.python-version == '3.3' }} |
| 212 | + run: | |
| 213 | + curl -o get-pip.py https://bootstrap.pypa.io/3.3/get-pip.py; |
| 214 | + python get-pip.py |
| 215 | + - name: Ensure working pip on 2.6 |
| 216 | + if: ${{ matrix.python-version == '2.6' }} |
| 217 | + run: | |
| 218 | + curl -o get-pip.py https://bootstrap.pypa.io/2.6/get-pip.py; |
| 219 | + python get-pip.py |
| 220 | + pip list |
| 221 | + pip install setuptools==28.8.0 wheel==0.30.0a0 |
| 222 | + - name: Install M2Crypto |
| 223 | + if: ${{ contains(matrix.opt-deps, 'm2crypto') }} |
| 224 | + run: pip install --pre m2crypto |
| 225 | + - name: Install tackpy |
| 226 | + if: ${{ contains(matrix.opt-deps, 'tackpy') }} |
| 227 | + run: pip install tackpy |
| 228 | + - name: Install pycrypto |
| 229 | + if: ${{ contains(matrix.opt-deps, 'pycrypto') }} |
| 230 | + run: pip install pycrypto |
| 231 | + - name: Install pycryptodome |
| 232 | + if: ${{ contains(matrix.opt-deps, 'pycryptodome') }} |
| 233 | + run: pip install pycryptodome |
| 234 | + - name: Install gmpy |
| 235 | + if: ${{ contains(matrix.opt-deps, 'gmpy') }} |
| 236 | + run: pip install gmpy |
| 237 | + - name: Install gmpy2 dependencies |
| 238 | + if: ${{ contains(matrix.opt-deps, 'gmpy2') }} |
| 239 | + run: sudo apt-get install -y libmpfr-dev libmpc-dev |
| 240 | + - name: Install gmpy2 |
| 241 | + if: ${{ contains(matrix.opt-deps, 'gmpy2') }} |
| 242 | + run: pip install gmpy2 |
| 243 | + - name: Install build dependencies |
| 244 | + run: | |
| 245 | + if [[ -e build-requirements-${{ matrix.python-version }}.txt ]]; then |
| 246 | + pip install -r build-requirements-${{ matrix.python-version }}.txt; |
| 247 | + else |
| 248 | + pip install -r build-requirements.txt; |
| 249 | + fi |
| 250 | + - name: Install dependencies |
| 251 | + run: pip install -r requirements.txt |
| 252 | + - name: Display installed python package versions |
| 253 | + run: pip list |
| 254 | + - name: Prepare Codeclimate environment |
| 255 | + if: ${{ contains(matrix.opt-deps, 'codeclimate') }} |
| 256 | + env: |
| 257 | + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} |
| 258 | + run: | |
| 259 | + curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter |
| 260 | + chmod +x ./cc-test-reporter |
| 261 | + ./cc-test-reporter before-build |
| 262 | + - name: Run unit tests (2.7+) |
| 263 | + if: ${{ matrix.python-version != '2.6' }} |
| 264 | + run: coverage run --branch --source tlslite -m unittest discover |
| 265 | + - name: Run unit tests (2.6) |
| 266 | + if: ${{ matrix.python-version == '2.6' }} |
| 267 | + run: coverage run --branch --source tlslite -m unittest2 discover |
| 268 | + - name: Run connection tests |
| 269 | + run: make test-local |
| 270 | + - name: Combine coverage from unit tests and connection tests |
| 271 | + run: | |
| 272 | + coverage combine --append |
| 273 | + coverage report -m |
| 274 | +
|
| 275 | + - name: Verify instability |
| 276 | + run: ./setup.py install |
| 277 | + - name: Verify install |
| 278 | + run: make test |
| 279 | + - name: Lint the code |
| 280 | + # pylint doesn't work on 2.6: https://bitbucket.org/logilab/pylint/issue/390/py26-compatiblity-broken |
| 281 | + if: ${{ matrix.python-version != '2.6' }} |
| 282 | + run: | |
| 283 | + pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" tlslite > pylint_report.txt || : |
| 284 | + diff-quality --violations=pylint --fail-under=90 pylint_report.txt |
| 285 | + - name: Verify that intermediate commits are testable |
| 286 | + if: ${{ github.event.pull_request }} |
| 287 | + env: |
| 288 | + PYTHON_VERSION: ${{ matrix.python-version }} |
| 289 | + BASE_REF: ${{ github.event.pull_request.base.ref }} |
| 290 | + run: | |
| 291 | + BASE_DIR="$(pwd)" |
| 292 | + echo BASE_REF: $BASE_REF |
| 293 | + echo GITHUB_SHA: $GITHUB_SHA |
| 294 | + echo GITHUB_REF: $GITHUB_REF |
| 295 | + git fetch origin $BASE_REF |
| 296 | + COMMIT_RANGE=origin/$BASE_REF..HEAD |
| 297 | + echo COMMIT_RANGE: $COMMIT_RANGE |
| 298 | + echo Will test the following commits: |
| 299 | + git log --oneline --reverse $COMMIT_RANGE |
| 300 | + for i in $(git log --pretty=format:%H --reverse $COMMIT_RANGE); do |
| 301 | + git checkout $i |
| 302 | + make clean |
| 303 | + if [[ $PYTHON_VERSION == '2.6' ]]; then |
| 304 | + unit2 discover || exit 1 |
| 305 | + else |
| 306 | + python -m unittest discover || exit 1 |
| 307 | + fi |
| 308 | + make test-local || exit 1 |
| 309 | + cd "$BASE_DIR" |
| 310 | + done |
| 311 | + - name: Publish coverage to Coveralls |
| 312 | + env: |
| 313 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 314 | + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} |
| 315 | + COVERALLS_FLAG_NAME: ${{ matrix.name }} |
| 316 | + COVERALLS_PARALLEL: true |
| 317 | + COVERALLS_SERVICE_NAME: git hub actions |
| 318 | + run: coveralls |
| 319 | + - name: Publish coverage to Codeclimate |
| 320 | + if: ${{ contains(matrix.opt-deps, 'codeclimate') }} |
| 321 | + env: |
| 322 | + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} |
| 323 | + run: | |
| 324 | + coverage xml |
| 325 | + ./cc-test-reporter after-build |
| 326 | +
|
| 327 | + coveralls: |
| 328 | + name: Indicate completion to coveralls.io |
| 329 | + needs: test |
| 330 | + runs-on: ubuntu-latest |
| 331 | + steps: |
| 332 | + - name: Set up Python 3.8 |
| 333 | + uses: actions/setup-python@v2 |
| 334 | + with: |
| 335 | + python-version: 3.8 |
| 336 | + - name: Finished |
| 337 | + env: |
| 338 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 339 | + COVERALLS_SERVICE_NAME: git hub actions |
| 340 | + run: | |
| 341 | + pip install --upgrade coveralls |
| 342 | + coveralls --service=github --finish |
0 commit comments