Skip to content

tests

tests #809

Workflow file for this run

name: tests
on:
push:
branches: [master]
pull_request:
schedule:
# Run every Sunday
- cron: "0 0 * * 0"
workflow_dispatch:
jobs:
code-quality:
name: Code Quality
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
cache: "pip" # caching pip dependencies
cache-dependency-path: |
pyproject.toml
requirements-dev.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Lint package
run: |
make lint
tests:
name: Mocked Tests (${{ matrix.os }}, Python ${{ matrix.python-version }})
needs: code-quality
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.7, 3.8, 3.9, "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip" # caching pip dependencies
cache-dependency-path: |
pyproject.toml
requirements-dev.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Run mocked tests
run: |
make test
- name: Build distribution and test installation
shell: bash
run: |
make dist
python -m pip install dist/cloudpathlib-*.whl --no-deps --force-reinstall
python -c "import cloudpathlib"
python -m pip install dist/cloudpathlib-*.tar.gz --no-deps --force-reinstall
python -c "import cloudpathlib"
- name: Upload coverage to codecov
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
fail_ci_if_error: true
live-tests:
name: Live Tests
needs: tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
cache: "pip" # caching pip dependencies
cache-dependency-path: |
pyproject.toml
requirements-dev.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Set up Cloud SDK
uses: google-github-actions/[email protected]
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
- name: Run live tests
run: |
make test-live-cloud
env:
LIVE_AZURE_CONTAINER: ${{ secrets.LIVE_AZURE_CONTAINER }}
AZURE_STORAGE_CONNECTION_STRING: ${{ secrets.AZURE_STORAGE_CONNECTION_STRING }}
LIVE_GS_BUCKET: ${{ secrets.LIVE_GS_BUCKET }}
LIVE_S3_BUCKET: ${{ secrets.LIVE_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
CUSTOM_S3_BUCKET: ${{secrets.CUSTOM_S3_BUCKET}}
CUSTOM_S3_KEY_ID: ${{secrets.CUSTOM_S3_KEY_ID}}
CUSTOM_S3_SECRET_KEY: ${{secrets.CUSTOM_S3_SECRET_KEY}}
CUSTOM_S3_ENDPOINT: ${{secrets.CUSTOM_S3_ENDPOINT}}
- name: Upload coverage to codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
fail_ci_if_error: true
extras-test:
name: Test independent installs of clients
needs: tests
runs-on: ubuntu-latest
strategy:
matrix:
extra: ["s3", "azure", "gs"]
include:
- prefix: "s3"
extra: "s3"
- prefix: "az"
extra: "azure"
- prefix: "gs"
extra: "gs"
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
cache: "pip"
cache-dependency-path: |
pyproject.toml
requirements-dev.txt
- name: Build cloudpathlib
run: |
pip install --upgrade pip build
make dist # build cloudpathlib wheel
- name: Create empty venv
run: |
python -m venv ${{ matrix.extra }}-env
- name: Install cloudpathlib[${{ matrix.extra }}]
run: |
source ${{ matrix.extra }}-env/bin/activate
pip install "$(find dist -name 'cloudpathlib*.whl')[${{ matrix.extra }}]"
- name: Test ${{ matrix.extra }} usage
run: |
source ${{ matrix.extra }}-env/bin/activate
python -c 'from cloudpathlib import CloudPath; CloudPath("${{ matrix.prefix }}://bucket/test")'
env:
AZURE_STORAGE_CONNECTION_STRING: ${{ secrets.AZURE_STORAGE_CONNECTION_STRING }}
notify:
name: Notify failed build
needs: [code-quality, tests, live-tests, extras-test]
if: failure() && github.event.pull_request == null
runs-on: ubuntu-latest
steps:
- uses: jayqi/failed-build-issue-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}