Skip to content

Commit 7b07b1d

Browse files
author
Lionel Untereiner
authored
Merge pull request #1 from geosiris-technologies/ci
Initial project commit
2 parents 4aee935 + 564c530 commit 7b07b1d

25 files changed

Lines changed: 4157 additions & 2 deletions
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
3+
name: Prepare Python and Poetry
4+
Description: Install Python, Poetry and dev dependencies, cached for speed
5+
6+
inputs:
7+
python-version:
8+
description: 'Python version to use'
9+
required: true
10+
default: '3.x'
11+
12+
runs:
13+
using: "composite"
14+
steps:
15+
- name: Set up Python
16+
id: setup-python
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: ${{ inputs.python-version }}
20+
21+
- name: Load cached Poetry installation
22+
uses: actions/cache@v3
23+
with:
24+
path: ~/.local # the path depends on the OS
25+
key: poetry-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-0 # increment to reset cache
26+
27+
- name: Install Poetry
28+
uses: snok/install-poetry@v1
29+
with:
30+
version: 1.1.13
31+
virtualenvs-create: true
32+
virtualenvs-in-project: true
33+
34+
- name: Install Poetry Plugins
35+
run: |
36+
python -m pip install --upgrade pip
37+
pip install poetry-dynamic-versioning
38+
shell: bash
39+
40+
- name: Load cached venv
41+
id: cached-poetry-dependencies
42+
uses: actions/cache@v3
43+
with:
44+
path: .venv
45+
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}-1
46+
47+
- name: Install dependencies and library
48+
# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
49+
run: poetry install --no-interaction
50+
shell: bash
51+

.github/codecov.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
# Configuration for CodeCov
3+
# See https://docs.codecov.io/docs/codecov-yaml
4+
5+
codecov:
6+
require_ci_to_pass: yes
7+
8+
coverage:
9+
# Colour chart range
10+
# In future, aim to update range to stricter standard
11+
range: "20...80"
12+
13+
comment:
14+
# Only post a comment if coverage changes
15+
require_changes: true

.github/dependabot.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
version: 2
3+
4+
updates:
5+
- package-ecosystem: github-actions
6+
directory: /
7+
schedule:
8+
interval: monthly
9+
commit-message:
10+
prefix: "ci"
11+
prefix-development: "ci"
12+
include: "scope"
13+
- package-ecosystem: pip
14+
directory: /
15+
schedule:
16+
interval: monthly
17+
commit-message:
18+
prefix: "build"
19+
prefix-development: "build"
20+
include: "scope"
21+
versioning-strategy: lockfile-only
22+
allow:
23+
- dependency-type: "all"
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
build:
9+
name: Build distribution
10+
runs-on: ubuntu-latest
11+
steps:
12+
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: '3.9'
22+
23+
- name: Install Poetry
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install poetry
27+
pip install poetry-dynamic-versioning
28+
29+
- name: Build
30+
run: |
31+
poetry build
32+
33+
- name: Save build artifacts
34+
uses: actions/upload-artifact@v2
35+
with:
36+
name: dist-artifact
37+
path: dist/
38+
39+
test:
40+
name: Test
41+
needs: build
42+
runs-on: ubuntu-latest
43+
steps:
44+
45+
- name: Set up Python
46+
uses: actions/setup-python@v2
47+
with:
48+
python-version: '3.9'
49+
50+
- name: Checkout code
51+
uses: actions/checkout@v3
52+
with:
53+
fetch-depth: 0
54+
55+
- name: Get build artifacts
56+
uses: actions/download-artifact@v2
57+
with:
58+
name: dist-artifact
59+
path: dist/
60+
61+
- name: Install from build
62+
run: |
63+
python -m pip install --upgrade pip
64+
pip install pytest-mock
65+
pip install etpproto --pre --target=dist --find-links=dist/
66+
67+
- name: Copy tests and example data to dist folder for testing against artifacts
68+
run: |
69+
cp -R tests dist/
70+
# cp -R example_data dist/
71+
72+
- name: Run tests
73+
run: pytest dist/tests
74+
75+
publish:
76+
name: Publish to PyPI
77+
needs: [build, test]
78+
runs-on: ubuntu-latest
79+
steps:
80+
81+
- name: Set up Python
82+
uses: actions/setup-python@v2
83+
with:
84+
python-version: '3.9'
85+
86+
# Retrieve the code and GIT history so that poetry-dynamic-versioning knows which version to upload
87+
- name: Checkout code
88+
uses: actions/checkout@v3
89+
with:
90+
fetch-depth: 0
91+
92+
- name: Get build artifacts
93+
uses: actions/download-artifact@v2
94+
with:
95+
name: dist-artifact
96+
path: dist/
97+
98+
- name: Install Poetry
99+
run: |
100+
python -m pip install --upgrade pip
101+
pip install poetry
102+
pip install poetry-dynamic-versioning
103+
104+
- name: Upload to PyPI TEST
105+
run: |
106+
poetry config repositories.test https://test.pypi.org/legacy/
107+
poetry config http-basic.test ${{ secrets.POETRY_PYPI_TOKEN_USERNAME}} ${{ secrets.POETRY_TEST_PYPI_TOKEN_PASSWORD}}
108+
poetry publish --repository test

.github/workflows/ci-publish.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
3+
name: Publish release
4+
5+
on:
6+
release:
7+
types: [published]
8+
9+
jobs:
10+
build:
11+
name: Build distribution
12+
runs-on: ubuntu-latest
13+
steps:
14+
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v2
22+
with:
23+
python-version: '3.9'
24+
25+
- name: Install Poetry
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install poetry
29+
pip install poetry-dynamic-versioning
30+
31+
- name: Build
32+
run: |
33+
poetry build
34+
35+
- name: Save build artifacts
36+
uses: actions/upload-artifact@v2
37+
with:
38+
name: dist-artifact
39+
path: dist/
40+
41+
test:
42+
name: Test
43+
needs: build
44+
runs-on: ubuntu-latest
45+
steps:
46+
47+
- name: Set up Python
48+
uses: actions/setup-python@v2
49+
with:
50+
python-version: '3.9'
51+
52+
- name: Checkout code
53+
uses: actions/checkout@v3
54+
with:
55+
fetch-depth: 0
56+
57+
- name: Get build artifacts
58+
uses: actions/download-artifact@v2
59+
with:
60+
name: dist-artifact
61+
path: dist/
62+
63+
- name: Install from build
64+
run: |
65+
python -m pip install --upgrade pip
66+
pip install pytest-mock
67+
pip install etpproto --pre --target=dist --find-links=dist/
68+
69+
- name: Copy tests and example data to dist folder for testing against artifacts
70+
run: |
71+
cp -R tests dist/
72+
# cp -R example_data dist/
73+
74+
- name: Run tests
75+
run: pytest dist/tests
76+
77+
publish:
78+
name: Publish to PyPI
79+
needs: [build, test]
80+
runs-on: ubuntu-latest
81+
steps:
82+
83+
- name: Set up Python
84+
uses: actions/setup-python@v2
85+
with:
86+
python-version: '3.9'
87+
88+
# Retrieve the code and GIT history so that poetry-dynamic-versioning knows which version to upload
89+
- name: Checkout code
90+
uses: actions/checkout@v3
91+
with:
92+
fetch-depth: 0
93+
94+
- name: Get build artifacts
95+
uses: actions/download-artifact@v2
96+
with:
97+
name: dist-artifact
98+
path: dist/
99+
100+
- name: Install Poetry
101+
run: |
102+
python -m pip install --upgrade pip
103+
pip install poetry
104+
pip install poetry-dynamic-versioning
105+
106+
- name: Upload to PyPI
107+
run: |
108+
poetry config repositories.test https://test.pypi.org/legacy/
109+
poetry publish --username ${{ secrets.POETRY_PYPI_TOKEN_USERNAME}} --password ${{ secrets.POETRY_PYPI_TOKEN_PASSWORD}}

.github/workflows/ci-tests.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
ame: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
static-analysis:
11+
name: Static analysis
12+
runs-on: ubuntu-latest
13+
steps:
14+
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
18+
- name: Install dependencies
19+
uses: ./.github/actions/prepare-poetry
20+
with:
21+
python-version: 3.9
22+
23+
# Post in-line comments for any issues found
24+
# Do not run if coming from a forked repo
25+
# See https://github.com/marketplace/actions/lint-action
26+
- name: Run linters (with annotations)
27+
if: github.event.pull_request.head.repo.full_name == github.repository
28+
uses: wearerequired/lint-action@v2
29+
with:
30+
flake8: true
31+
flake8_command_prefix: poetry run
32+
flake8_dir: etpproto
33+
mypy: true
34+
mypy_command_prefix: poetry run
35+
mypy_args: etpproto
36+
37+
# Alternative step that works with forked repo
38+
- name: Run linters (without annotations)
39+
if: github.event.pull_request.head.repo.full_name != github.repository
40+
run: |
41+
poetry run flake8 .
42+
poetry run mypy etpproto
43+
- name: Code formatting
44+
run: poetry run black --check .
45+
46+
unit-tests:
47+
name: Unit tests (Python ${{ matrix.python-version }})
48+
runs-on: ubuntu-latest
49+
50+
strategy:
51+
matrix:
52+
python-version: ["3.9", "3.10"]
53+
54+
steps:
55+
- uses: actions/checkout@v3
56+
57+
- name: Install dependencies
58+
uses: ./.github/actions/prepare-poetry
59+
with:
60+
python-version: ${{ matrix.python-version }}
61+
62+
- name: Run pytest
63+
run: poetry run pytest --cov=etpproto --cov-report=xml --junitxml=pytest.xml
64+
65+
- name: Upload pytest artifacts
66+
if: ${{ always() }}
67+
uses: actions/upload-artifact@v3
68+
with:
69+
name: Unit Test Results (Python ${{ matrix.python-version }})
70+
path: pytest.xml
71+
72+
- name: Upload coverage to Codecov
73+
uses: codecov/codecov-action@v2
74+
with:
75+
token: ${{ secrets.CODECOV_TOKEN }}
76+
files: coverage.xml
77+
fail_ci_if_error: true

0 commit comments

Comments
 (0)