build #678
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
pull_request: | |
push: | |
branches: | |
- "master" | |
- "develop" | |
schedule: | |
- cron: "5 0 * * *" | |
env: | |
# The only way to simulate if-else statement | |
CHECKOUT_BRANCH: ${{ github.event_name == 'schedule' && 'develop' || github.ref }} | |
jobs: | |
check-pre-commit-hooks: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout branch | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ env.CHECKOUT_BRANCH }} | |
- name: Setup Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.8" | |
architecture: x64 | |
- name: Prepare pre-commit validators | |
run: | | |
pip install pre-commit | |
pre-commit install | |
- name: Check code compliance with pre-commit validators | |
run: pre-commit run --all-files | |
check-code-pylint-and-mypy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout branch | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ env.CHECKOUT_BRANCH }} | |
- name: Setup Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.8" | |
architecture: x64 | |
- name: Install packages | |
run: pip install -e .[DEV] | |
- name: Run pylint | |
run: pylint s2cloudless | |
- name: Run mypy | |
run: mypy s2cloudless | |
test-on-github: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: | |
- "3.9" | |
- "3.10" | |
- "3.11" | |
include: | |
# A flag marks whether full or partial tests should be run | |
# We don't run integration tests on pull requests from outside repos, because they don't have secrets | |
- python-version: "3.8" | |
full_test_suite: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} | |
steps: | |
- name: Checkout branch | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ env.CHECKOUT_BRANCH }} | |
- name: Setup Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
architecture: x64 | |
- name: Install packages | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y build-essential libopenjp2-7 | |
pip install -e .[DEV] | |
- name: Run full tests and code coverage | |
if: ${{ matrix.full_test_suite }} | |
run: | | |
sentinelhub.config \ | |
--sh_client_id "${{ secrets.SH_CLIENT_ID }}" \ | |
--sh_client_secret "${{ secrets.SH_CLIENT_SECRET }}" | |
pytest --cov --cov-report=term --cov-report=xml | |
- name: Run reduced tests | |
if: ${{ !matrix.full_test_suite }} | |
run: | | |
pytest -m "not sh_integration" | |
- name: Upload code coverage | |
if: ${{ matrix.full_test_suite && github.event_name == 'push' }} | |
uses: codecov/codecov-action@v2 | |
with: | |
files: coverage.xml | |
fail_ci_if_error: true | |
verbose: false |