Skip to content

Commit

Permalink
Ci (#1)
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
valentin-gauthier-geosiris authored Sep 22, 2022
1 parent aadc61b commit b1f377e
Show file tree
Hide file tree
Showing 7 changed files with 297 additions and 7 deletions.
15 changes: 15 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
# Configuration for CodeCov
# See https://docs.codecov.io/docs/codecov-yaml

codecov:
require_ci_to_pass: yes

coverage:
# Colour chart range
# In future, aim to update range to stricter standard
range: "20...80"

comment:
# Only post a comment if coverage changes
require_changes: true
106 changes: 106 additions & 0 deletions .github/workflows/ci-publish-test-repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---

on: [push,pull_request]

jobs:
build:
name: Build distribution
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'

- name: Install Poetry
run: |
python -m pip install --upgrade pip
pip install poetry
pip install poetry-dynamic-versioning
- name: Build
run: |
poetry build
- name: Save build artifacts
uses: actions/upload-artifact@v2
with:
name: dist-artifact
path: dist/

test:
name: Test
needs: build
runs-on: ubuntu-latest
steps:

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'

- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get build artifacts
uses: actions/download-artifact@v2
with:
name: dist-artifact
path: dist/

- name: Install from build
run: |
python -m pip install --upgrade pip
pip install pytest-mock
pip install etpproto --pre --target=dist --find-links=dist/
- name: Copy tests and example data to dist folder for testing against artifacts
run: |
cp -R tests dist/
# cp -R example_data dist/

- name: Run tests
run: pytest dist/tests

publish:
name: Publish to PyPI
needs: [build, test]
runs-on: ubuntu-latest
steps:

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'

# Retrieve the code and GIT history so that poetry-dynamic-versioning knows which version to upload
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get build artifacts
uses: actions/download-artifact@v2
with:
name: dist-artifact
path: dist/

- name: Install Poetry
run: |
python -m pip install --upgrade pip
pip install poetry
pip install poetry-dynamic-versioning
- name: Upload to PyPI TEST
run: |
poetry config repositories.test https://test.pypi.org/legacy/
poetry config http-basic.test ${{ secrets.POETRY_PYPI_TOKEN_USERNAME}} ${{ secrets.POETRY_TEST_PYPI_TOKEN_PASSWORD}}
poetry publish --repository test
111 changes: 111 additions & 0 deletions .github/workflows/ci-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---

name: Publish release

on:
push:
tags:
# Run when a tag is pushed with a valid semantic version number
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
build:
name: Build distribution
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'

- name: Install Poetry
run: |
python -m pip install --upgrade pip
pip install poetry
pip install poetry-dynamic-versioning
- name: Build
run: |
poetry build
- name: Save build artifacts
uses: actions/upload-artifact@v2
with:
name: dist-artifact
path: dist/

test:
name: Test
needs: build
runs-on: ubuntu-latest
steps:

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'

- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get build artifacts
uses: actions/download-artifact@v2
with:
name: dist-artifact
path: dist/

- name: Install from build
run: |
python -m pip install --upgrade pip
pip install pytest-mock
pip install etpproto --pre --target=dist --find-links=dist/
- name: Copy tests and example data to dist folder for testing against artifacts
run: |
cp -R tests dist/
# cp -R example_data dist/

- name: Run tests
run: pytest dist/tests

publish:
name: Publish to PyPI
needs: [build, test]
runs-on: ubuntu-latest
steps:

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'

# Retrieve the code and GIT history so that poetry-dynamic-versioning knows which version to upload
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get build artifacts
uses: actions/download-artifact@v2
with:
name: dist-artifact
path: dist/

- name: Install Poetry
run: |
python -m pip install --upgrade pip
pip install poetry
pip install poetry-dynamic-versioning
- name: Upload to PyPI
run: |
poetry config repositories.test https://test.pypi.org/legacy/
poetry publish --username ${{ secrets.POETRY_PYPI_TOKEN_USERNAME}} --password ${{ secrets.POETRY_PYPI_TOKEN_PASSWORD}}
44 changes: 44 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---

name: CodeQL

on:
push:
branches: [ master ]
# pull_request:
# The branches below must be a subset of the branches above
# branches: [ master ]
schedule:
# 10:16 on Fridays
- cron: '16 10 * * 5'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ docs/html
build
dist
*.egg-info
venv/

# Dynamically-generated version
resqpy/version.py
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
ETP Protocol Implementation
==========

[![License](https://img.shields.io/pypi/l/etpproto-python)](https://github.com/geosiris-technologies/etpproto-python/blob/main/LICENSE)
[![License](https://img.shields.io/pypi/l/etpproto)](https://github.com/geosiris-technologies/etpproto-python/blob/main/LICENSE)
[![Documentation Status](https://readthedocs.org/projects/etpproto-python/badge/?version=latest)](https://etpproto-python.readthedocs.io/en/latest/?badge=latest)
[![Python CI](https://github.com/geosiris-technologies/etpproto-python/actions/workflows/ci-tests.yml/badge.svg)](https://github.com/geosiris-technologies/etpproto-python/actions/workflows/ci-tests.yml)
![Python version](https://img.shields.io/pypi/pyversions/etpproto-python)
[![PyPI](https://img.shields.io/pypi/v/etpproto-python)](https://badge.fury.io/py/etpproto-python)
![Status](https://img.shields.io/pypi/status/etpproto-python)
[![codecov](https://codecov.io/gh/bp/etpproto-python/branch/master/graph/badge.svg)](https://codecov.io/gh/bp/etpproto-python)
[![codecov](https://codecov.io/gh/geosiris-technologies/etpproto-python/branch/main/graph/badge.svg)](https://codecov.io/gh/geosiris-technologies/etpproto-python)



Expand Down
23 changes: 18 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["poetry>=1.0.2", "poetry-dynamic-versioning"]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
build-backend = "poetry.masonry.api"

[tool.poetry]
Expand All @@ -16,11 +16,10 @@ maintainers = [
license = "Apache-2.0"
readme = "README.md"
repository = "https://github.com/bp/resqpy"
homepage = "www.geosiris.com"
homepage = "http://www.geosiris.com"
classifiers = [
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.9",
"License :: OSI Approved :: Apache Software License"
"License :: OSI Approved :: Apache Software License",
]
keywords = ["ETP"]

Expand Down Expand Up @@ -63,7 +62,7 @@ exclude = '''
'''

[tool.pytest.ini_options]
addopts = "-v --cache-clear -rf --cov=etpproto/ --cov-report=term --cov-report=html --junitxml=pytest.xml"
addopts = ""
console_output_style = "count"
python_classes = "Test"
python_files = "test_*.py"
Expand All @@ -77,3 +76,17 @@ source = ["etpproto"]

[tool.pylint.format]
max-line-length = "88"

[tool.poetry-dynamic-versioning]
enable = true
vcs = "git"
style = "pep440"
format-jinja = """
{%- if distance == 0 -%}
{{ serialize_pep440(base, stage, revision) }}
{%- elif revision is not none -%}
{{ serialize_pep440(base, stage, revision + 1, dev=distance) }}
{%- else -%}
{{ serialize_pep440(bump_version(base), stage, revision, dev=distance) }}
{%- endif -%}
"""

0 comments on commit b1f377e

Please sign in to comment.