2020-07-01 17:17:12 +03:00
|
|
|
name: Run tests
|
2020-07-01 17:13:52 +03:00
|
|
|
|
2020-10-05 23:58:23 +03:00
|
|
|
on:
|
|
|
|
pull_request_target:
|
|
|
|
paths:
|
2020-10-06 01:34:02 +03:00
|
|
|
# run tests only when the python code has changed
|
2020-12-05 19:26:13 +03:00
|
|
|
- 'src/**.py'
|
2020-10-05 23:58:23 +03:00
|
|
|
- 'tests/**.py'
|
2020-10-08 11:09:08 +03:00
|
|
|
workflow_dispatch:
|
|
|
|
|
2020-07-01 17:13:52 +03:00
|
|
|
jobs:
|
2020-12-05 19:26:13 +03:00
|
|
|
offline-tests:
|
|
|
|
name: offline
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
platform: [ubuntu-latest, macos-latest]
|
2022-02-11 15:19:34 +03:00
|
|
|
python-version: ['3.7', '3.10']
|
2020-12-05 19:26:13 +03:00
|
|
|
|
|
|
|
runs-on: ${{ matrix.platform }}
|
|
|
|
steps:
|
2021-02-14 22:48:05 +03:00
|
|
|
|
|
|
|
- name: Checkout merge commit
|
2020-12-05 19:26:13 +03:00
|
|
|
uses: actions/checkout@v2
|
2021-02-14 22:48:05 +03:00
|
|
|
if: github.event_name == 'pull_request_target'
|
2020-12-05 19:26:13 +03:00
|
|
|
with:
|
|
|
|
ref: 'refs/pull/${{ github.event.number }}/merge'
|
2021-02-28 17:15:46 +03:00
|
|
|
persist-credentials: false
|
2020-12-05 19:26:13 +03:00
|
|
|
|
2021-02-14 22:48:05 +03:00
|
|
|
- name: Checkout head commit
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
if: github.event_name != 'pull_request_target'
|
|
|
|
|
2020-12-05 19:26:13 +03:00
|
|
|
- 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
|
2021-06-16 15:50:32 +03:00
|
|
|
python -m pip install -U .[dev]
|
2020-12-05 19:26:13 +03:00
|
|
|
|
|
|
|
- name: Test with pytest
|
|
|
|
run: |
|
2022-01-17 22:34:53 +03:00
|
|
|
python -m pytest --cov=maestral --cov-report=xml tests/offline
|
2020-12-05 19:26:13 +03:00
|
|
|
|
|
|
|
- name: Upload coverage to Codecov
|
2021-12-23 15:29:13 +03:00
|
|
|
uses: codecov/codecov-action@v2.1.0
|
2020-12-05 19:26:13 +03:00
|
|
|
with:
|
|
|
|
file: ./coverage.xml
|
|
|
|
flags: pytest
|
|
|
|
env_vars: OS,PYTHON,TYPE
|
2021-02-14 22:48:05 +03:00
|
|
|
name: pytests -v
|
2020-12-05 19:26:13 +03:00
|
|
|
env:
|
|
|
|
OS: ${{ matrix.platform }}
|
|
|
|
PYTHON: ${{ matrix.python-version }}
|
|
|
|
TYPE: 'offline'
|
|
|
|
|
|
|
|
online-tests:
|
|
|
|
name: online
|
|
|
|
needs: offline-tests
|
2020-07-01 17:13:52 +03:00
|
|
|
strategy:
|
2020-10-05 23:58:23 +03:00
|
|
|
max-parallel: 2
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
platform: [ubuntu-latest, macos-latest]
|
2022-02-11 20:19:59 +03:00
|
|
|
python-version: ['3.10', ]
|
2020-10-05 17:19:10 +03:00
|
|
|
include:
|
2020-10-06 01:34:02 +03:00
|
|
|
# use two different Dropbox accounts to run tests in parallel
|
2020-10-05 17:19:10 +03:00
|
|
|
- platform: ubuntu-latest
|
|
|
|
token: DROPBOX_REFRESH_TOKEN_1
|
2020-10-12 15:38:07 +03:00
|
|
|
|
2020-10-05 17:19:10 +03:00
|
|
|
- platform: macos-latest
|
|
|
|
token: DROPBOX_REFRESH_TOKEN_2
|
2020-10-12 15:38:07 +03:00
|
|
|
|
2020-07-01 17:13:52 +03:00
|
|
|
runs-on: ${{ matrix.platform }}
|
|
|
|
steps:
|
2021-02-14 22:48:05 +03:00
|
|
|
- name: Checkout merge commit
|
2020-10-12 15:38:07 +03:00
|
|
|
uses: actions/checkout@v2
|
2021-02-14 22:48:05 +03:00
|
|
|
if: github.event_name == 'pull_request_target'
|
2020-10-12 15:38:07 +03:00
|
|
|
with:
|
2020-12-05 19:26:13 +03:00
|
|
|
ref: 'refs/pull/${{ github.event.number }}/merge'
|
2021-02-28 17:15:46 +03:00
|
|
|
persist-credentials: false
|
2020-10-12 15:38:07 +03:00
|
|
|
|
2021-02-14 22:48:05 +03:00
|
|
|
- name: Checkout head commit
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
if: github.event_name != 'pull_request_target'
|
|
|
|
|
2020-10-12 15:38:07 +03:00
|
|
|
- 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
|
2021-06-16 15:50:32 +03:00
|
|
|
python -m pip install -U .[dev]
|
2020-10-12 15:38:07 +03:00
|
|
|
|
|
|
|
- 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
|
2021-09-10 23:55:09 +03:00
|
|
|
# malicious PR, get access to a long-lived token.
|
2020-10-12 15:38:07 +03:00
|
|
|
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"
|
2021-02-14 22:48:05 +03:00
|
|
|
echo "DROPBOX_ACCESS_TOKEN=$token" >> $GITHUB_ENV
|
2020-10-12 15:38:07 +03:00
|
|
|
|
|
|
|
- name: Test with pytest
|
|
|
|
run: |
|
2021-07-13 01:02:54 +03:00
|
|
|
pytest -v --cov=maestral --cov-report=xml tests/linked
|
2020-10-26 18:22:43 +03:00
|
|
|
|
2021-02-27 01:14:48 +03:00
|
|
|
- name: Upload Code Coverage
|
2021-12-23 15:29:13 +03:00
|
|
|
uses: codecov/codecov-action@v2.1.0
|
2021-02-27 01:14:48 +03:00
|
|
|
with:
|
|
|
|
file: ./coverage.xml
|
|
|
|
flags: pytest
|
|
|
|
env_vars: OS,PYTHON,TYPE
|
|
|
|
name: pytests
|
|
|
|
env:
|
|
|
|
OS: ${{ matrix.platform }}
|
|
|
|
PYTHON: ${{ matrix.python-version }}
|
|
|
|
TYPE: 'linked'
|