|
| 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: Python package |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + pull_request: |
| 9 | + branches: [ dev ] |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + env: |
| 14 | + # Fake a TRAVIS env so that the pre-existing test cases would behave like before |
| 15 | + TRAVIS: true |
| 16 | + LAB_APP_CLIENT_ID: ${{ secrets.LAB_APP_CLIENT_ID }} |
| 17 | + LAB_APP_CLIENT_SECRET: ${{ secrets.LAB_APP_CLIENT_SECRET }} |
| 18 | + LAB_OBO_CLIENT_SECRET: ${{ secrets.LAB_OBO_CLIENT_SECRET }} |
| 19 | + LAB_OBO_CONFIDENTIAL_CLIENT_ID: ${{ secrets.LAB_OBO_CONFIDENTIAL_CLIENT_ID }} |
| 20 | + LAB_OBO_PUBLIC_CLIENT_ID: ${{ secrets.LAB_OBO_PUBLIC_CLIENT_ID }} |
| 21 | + |
| 22 | + runs-on: ubuntu-latest |
| 23 | + strategy: |
| 24 | + matrix: |
| 25 | + python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9] |
| 26 | + |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v2 |
| 29 | + - name: Set up Python ${{ matrix.python-version }} |
| 30 | + uses: actions/setup-python@v2 |
| 31 | + with: |
| 32 | + python-version: ${{ matrix.python-version }} |
| 33 | + |
| 34 | + # Derived from https://github.com/actions/cache/blob/main/examples.md#using-pip-to-get-cache-location |
| 35 | + # However, a before-and-after test shows no improvement in this repo, |
| 36 | + # possibly because the bottlenect was not in downloading those small python deps. |
| 37 | + - name: Get pip cache dir from pip 20.1+ |
| 38 | + id: pip-cache |
| 39 | + run: | |
| 40 | + echo "::set-output name=dir::$(pip cache dir)" |
| 41 | + - name: pip cache |
| 42 | + uses: actions/cache@v2 |
| 43 | + with: |
| 44 | + path: ${{ steps.pip-cache.outputs.dir }} |
| 45 | + key: ${{ runner.os }}-py${{ matrix.python-version }}-pip-${{ hashFiles('**/setup.py', '**/requirements.txt') }} |
| 46 | + |
| 47 | + - name: Install dependencies |
| 48 | + run: | |
| 49 | + python -m pip install --upgrade pip |
| 50 | + python -m pip install flake8 pytest |
| 51 | + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
| 52 | + - name: Lint with flake8 |
| 53 | + run: | |
| 54 | + # stop the build if there are Python syntax errors or undefined names |
| 55 | + #flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
| 56 | + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide |
| 57 | + #flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
| 58 | + - name: Test with pytest |
| 59 | + run: | |
| 60 | + pytest |
0 commit comments