-
Notifications
You must be signed in to change notification settings - Fork 249
133 lines (115 loc) · 4.06 KB
/
ci_action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: build
on:
pull_request:
push:
branches:
- "master"
- "develop"
workflow_call:
concurrency:
# This will cancel outdated runs on the same pull-request, but not runs for other triggers
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
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@v3
with:
ref: ${{ env.CHECKOUT_BRANCH }}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.8"
- uses: pre-commit/[email protected]
with:
extra_args: --all-files --verbose
check-code-pylint-and-mypy:
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v3
with:
ref: ${{ env.CHECKOUT_BRANCH }}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.8"
cache: pip # caching the entire environment is faster when cache exists but slower for cache creation
- name: Install packages
run: pip install --upgrade --upgrade-strategy eager -e .[AWS,DEV]
- name: Run mypy
run: mypy sentinelhub
- name: Run pylint
if: success() || failure() # always() has the issue that it also runs when the workflow is cancelled
run: pylint sentinelhub
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@v3
with:
ref: ${{ env.CHECKOUT_BRANCH }}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Install packages
run: pip install --upgrade --upgrade-strategy eager -e .[AWS,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 }}" \
--instance_id "${{ secrets.INSTANCE_ID }}" \
--aws_access_key_id "${{ secrets.AWS_ACCESS_KEY_ID }}" \
--aws_secret_access_key "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
if [ ${{ github.event_name }} == 'push' ]; then
pytest --cov --cov-report=term --cov-report=xml
else
pytest
fi
- name: Run reduced tests
if: ${{ !matrix.full_test_suite }}
run: |
pytest -m "not sh_integration and not aws_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
mirror-and-integration-test-on-gitlab:
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Mirror + trigger CI
uses: SvanBoxel/gitlab-mirror-and-ci-action@master
with:
args: "https://hello.planet.com/code/eo/code/sentinelhub-py-dev/"
env:
FOLLOW_TAGS: "true"
GITLAB_HOSTNAME: "hello.planet.com/code"
GITLAB_USERNAME: "github-action"
GITLAB_PASSWORD: ${{ secrets.GITLAB_PASSWORD }}
GITLAB_PROJECT_ID: "9711"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}