|
| 1 | +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions |
| 2 | +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions |
| 3 | + |
| 4 | +name: CI |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + pull_request: |
| 9 | + branches: [ dev ] |
| 10 | + # This guards against unknown PR until a community member vet it and label it. |
| 11 | + types: [ labeled ] |
| 12 | + |
| 13 | +jobs: |
| 14 | + ci: |
| 15 | + |
| 16 | + runs-on: ${{ matrix.os }} |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + python-version: [3.7, 3.8, 3.9, 2.7] |
| 20 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 21 | + include: |
| 22 | + # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-environment-variables-in-a-matrix |
| 23 | + - python-version: 3.7 |
| 24 | + toxenv: "py37" |
| 25 | + - python-version: 3.8 |
| 26 | + toxenv: "py38" |
| 27 | + - python-version: 3.9 |
| 28 | + toxenv: "py39" |
| 29 | + - python-version: 2.7 |
| 30 | + toxenv: "py27" |
| 31 | + - python-version: 3.9 |
| 32 | + os: ubuntu-latest |
| 33 | + lint: "true" |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v2 |
| 36 | + - name: Set up Python ${{ matrix.python-version }} |
| 37 | + uses: actions/setup-python@v2 |
| 38 | + with: |
| 39 | + python-version: ${{ matrix.python-version }} |
| 40 | + - name: Install Linux dependencies for Python 2 |
| 41 | + if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '2.7' }} |
| 42 | + run: | |
| 43 | + sudo apt update |
| 44 | + sudo apt install python-dev libgirepository1.0-dev libcairo2-dev gir1.2-secret-1 gnome-keyring |
| 45 | + - name: Install Linux dependencies for Python 3 |
| 46 | + if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version != '2.7' }} |
| 47 | + run: | |
| 48 | + sudo apt update |
| 49 | + sudo apt install python3-dev libgirepository1.0-dev libcairo2-dev gir1.2-secret-1 gnome-keyring |
| 50 | + - name: Install PyGObject on Linux |
| 51 | + if: ${{ matrix.os == 'ubuntu-latest' }} |
| 52 | + run: | |
| 53 | + python -m pip install --upgrade pip |
| 54 | + python -m pip install pygobject |
| 55 | + - name: Install Python dependencies |
| 56 | + run: | |
| 57 | + python -m pip install --upgrade pip |
| 58 | + python -m pip install pylint tox pytest |
| 59 | + pip install . |
| 60 | + - name: Lint |
| 61 | + if: ${{ matrix.lint == 'true' }} |
| 62 | + run: | |
| 63 | + pylint msal_extensions |
| 64 | + # stop the build if there are Python syntax errors or undefined names |
| 65 | + #flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
| 66 | + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide |
| 67 | + #flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
| 68 | + - name: Test on Linux with encryption |
| 69 | + if: ${{ matrix.os == 'ubuntu-latest' }} |
| 70 | + run: | |
| 71 | + # Don't know why, but the pytest and "." have to be re-installed again for them to be used |
| 72 | + echo "echo secret_placeholder | gnome-keyring-daemon --unlock; pip install pytest .; pytest" > linux_test.sh |
| 73 | + chmod +x linux_test.sh |
| 74 | + sudo dbus-run-session -- ./linux_test.sh |
| 75 | + - name: Test on other platforms without encryption |
| 76 | + if: ${{ matrix.os != 'ubuntu-latest' }} |
| 77 | + env: |
| 78 | + TOXENV: ${{ matrix.toxenv }} |
| 79 | + run: | |
| 80 | + tox |
| 81 | +
|
| 82 | + cd: |
| 83 | + needs: ci |
| 84 | + if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/master') |
| 85 | + runs-on: ubuntu-latest |
| 86 | + steps: |
| 87 | + - uses: actions/checkout@v2 |
| 88 | + - name: Set up Python 3.9 |
| 89 | + uses: actions/setup-python@v2 |
| 90 | + with: |
| 91 | + python-version: 3.9 |
| 92 | + - name: Build a package for release |
| 93 | + run: | |
| 94 | + python -m pip install build --user |
| 95 | + python -m build --sdist --wheel --outdir dist/ . |
| 96 | + - name: Publish to TestPyPI |
| 97 | + |
| 98 | + if: github.ref == 'refs/heads/master' |
| 99 | + with: |
| 100 | + user: __token__ |
| 101 | + password: ${{ secrets.TEST_PYPI_API_TOKEN }} |
| 102 | + repository_url: https://test.pypi.org/legacy/ |
| 103 | + - name: Publish to PyPI |
| 104 | + if: startsWith(github.ref, 'refs/tags') |
| 105 | + |
| 106 | + with: |
| 107 | + user: __token__ |
| 108 | + password: ${{ secrets.PYPI_API_TOKEN }} |
| 109 | + |
0 commit comments