mirror of
https://github.com/samschott/maestral.git
synced 2024-09-22 19:42:53 +03:00
118 lines
3.5 KiB
YAML
118 lines
3.5 KiB
YAML
name: Run tests
|
|
|
|
on:
|
|
pull_request_target:
|
|
paths:
|
|
# run tests only when the python code has changed
|
|
- 'src/**.py'
|
|
- 'tests/**.py'
|
|
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
offline-tests:
|
|
name: Run offline tests
|
|
strategy:
|
|
matrix:
|
|
platform: [ubuntu-latest, macos-latest]
|
|
python-version: [3.6, 3.7, 3.8, 3.9]
|
|
|
|
runs-on: ${{ matrix.platform }}
|
|
steps:
|
|
- name: Checkout project
|
|
uses: actions/checkout@v2
|
|
with:
|
|
ref: 'refs/pull/${{ github.event.number }}/merge'
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
uses: actions/setup-python@v2
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
python -m pip install --upgrade pytest
|
|
python -m pip install --upgrade pytest-cov
|
|
python -m pip install .
|
|
|
|
- name: Test with pytest
|
|
run: |
|
|
pytest --cov=maestral --cov-report=xml tests/offline
|
|
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v1
|
|
with:
|
|
file: ./coverage.xml
|
|
flags: pytest
|
|
env_vars: OS,PYTHON,TYPE
|
|
name: pytests
|
|
env:
|
|
OS: ${{ matrix.platform }}
|
|
PYTHON: ${{ matrix.python-version }}
|
|
TYPE: 'offline'
|
|
|
|
online-tests:
|
|
name: Run online tests
|
|
needs: offline-tests
|
|
strategy:
|
|
max-parallel: 2
|
|
fail-fast: false
|
|
matrix:
|
|
platform: [ubuntu-latest, macos-latest]
|
|
python-version: [3.6, ]
|
|
include:
|
|
# use two different Dropbox accounts to run tests in parallel
|
|
- platform: ubuntu-latest
|
|
token: DROPBOX_REFRESH_TOKEN_1
|
|
|
|
- platform: macos-latest
|
|
token: DROPBOX_REFRESH_TOKEN_2
|
|
|
|
runs-on: ${{ matrix.platform }}
|
|
steps:
|
|
- name: Checkout project
|
|
uses: actions/checkout@v2
|
|
with:
|
|
ref: ${{ github.event.pull_request.merged.sha }}
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
uses: actions/setup-python@v2
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
python -m pip install --upgrade pytest
|
|
python -m pip install --upgrade pytest-cov
|
|
python -m pip install .
|
|
|
|
- name: Get short-lived Dropbox token
|
|
# We generate a short-lived auth token which is passed to the test runner as
|
|
# an environment variable. At no point does the test code, potentially from a
|
|
# malicious PR, get access to a long lived token.
|
|
run: |
|
|
auth_result=$(curl https://api.dropbox.com/oauth2/token \
|
|
-d grant_type=refresh_token \
|
|
-d refresh_token=${{ secrets[matrix.token] }} \
|
|
-d client_id=2jmbq42w7vof78h)
|
|
token=$(echo $auth_result | python -c "import sys, json; print(json.load(sys.stdin)['access_token'])")
|
|
echo "::add-mask::$token"
|
|
echo "DROPBOX_TOKEN=$token" >> $GITHUB_ENV
|
|
|
|
- name: Test with pytest
|
|
run: |
|
|
pytest --cov=maestral --cov-report=xml tests/linked
|
|
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v1
|
|
with:
|
|
file: ./coverage.xml
|
|
flags: pytest
|
|
env_vars: OS,PYTHON,TYPE
|
|
name: pytests
|
|
env:
|
|
OS: ${{ matrix.platform }}
|
|
PYTHON: ${{ matrix.python-version }}
|
|
TYPE: 'linked' |