Skip to content

Commit

Permalink
Merge pull request #9 from sebhmg/GEOPY-1162
Browse files Browse the repository at this point in the history
GEOPY-1162: review dependencies and CI script in las-geoh5
  • Loading branch information
sebhmg authored Oct 31, 2023
2 parents 21e4e3a + d6d1d17 commit 26e338a
Show file tree
Hide file tree
Showing 12 changed files with 183 additions and 80 deletions.
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ updates:
directory: "/"
schedule:
interval: "monthly"
target-branch: "develop"
36 changes: 36 additions & 0 deletions .github/workflows/issue_to_jira.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow will create a JIRA issue upon creation of a GitHub issue

name: Create JIRA issue

on:
issues:
types: [opened]

jobs:
new_jira_issue:
runs-on: ubuntu-latest

steps:
- name: JIRA Login
uses: atlassian/[email protected]
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
- name: Jira Create issue
id: create_jira_issue
uses: atlassian/[email protected]
with:
project: GEOPY
issuetype: Story
summary: ${{ github.event.issue.title }}
description: "_from [GitHub issue #${{ github.event.issue.number }}|${{ github.event.issue.html_url }}]_"
# Additional fields in JSON format
fields: '{"components": [{"name": "LAS"}]}'
- name: Post JIRA link
uses: peter-evans/create-or-update-comment@v3
with:
# The number of the issue or pull request in which to create a comment.
issue-number: ${{ github.event.issue.number }}
# The comment body.
body: "JIRA issue [${{ steps.create_jira_issue.outputs.issue }}] was created."
50 changes: 50 additions & 0 deletions .github/workflows/pr_add_jira_summary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This workflow will comment the PR with the JIRA issue summary
# if a JIRA issue number is detected in the branch name or title

name: Add JIRA issue summary

on:
pull_request_target:
types: [opened]

jobs:
add_jira_summary:
runs-on: ubuntu-latest

steps:
- name: Find JIRA issue key
id: find_jira_key
env:
HEAD_REF: ${{ github.head_ref}}
PR_TITLE: ${{ github.event.pull_request.title }}
run: >
echo $HEAD_REF $PR_TITLE
| echo "issue_key=$(grep -os "\b\(GA\|GEOPY\)-[0-9]\+" | head -n1)" >> $GITHUB_OUTPUT
- name: Get JIRA summary
id: get_jira_summary
if: ${{ steps.find_jira_key.outputs.issue_key }}
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_BASIC_AUTH: ${{ secrets.JIRA_BASIC_AUTH }}
run: >
curl -sS -X GET
-H "Authorization: Basic $JIRA_BASIC_AUTH"
-H "Content-Type: application/json"
"$JIRA_BASE_URL/rest/api/2/issue/${{ steps.find_jira_key.outputs.issue_key }}"
| echo "summary=$(jq -r '.fields.summary')" >> $GITHUB_OUTPUT
- name: Add comment
if: ${{ steps.find_jira_key.outputs.issue_key }}
env:
ISSUE_SUMMARY: ${{ steps.get_jira_summary.outputs.summary }}
PR_BODY: ${{ github.event.pull_request.body }}
run: >
jq
--arg ISSUE_ID "${{ steps.find_jira_key.outputs.issue_key }}"
--arg ISSUE_SUMMARY "$(cat <<< $ISSUE_SUMMARY)"
--arg PR_BODY "$(cat <<< $PR_BODY)"
-c '."body"="**" + $ISSUE_ID + " - " + $ISSUE_SUMMARY + "**\n" + $PR_BODY' <<< {}
| curl -sS -X POST -d @-
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}"
-H "Content-Type: application/json"
"$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/pulls/${{ github.event.pull_request.number }}"
> /dev/null
1 change: 0 additions & 1 deletion .github/workflows/pytest-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,3 @@ jobs:
uses: codecov/codecov-action@v3
with:
name: GitHub
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
28 changes: 0 additions & 28 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,6 @@ env:
source_dir: las_geoh5

jobs:
pre-commit:
name: pre-commit
strategy:
fail-fast: false
runs-on: ubuntu-latest
env:
SKIP: pylint
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- name: capture modified files
if: github.event_name == 'pull_request'
run: >-
git fetch --deepen=500 origin ${{github.base_ref}}
&& echo "FILES_PARAM=$(
git diff --diff-filter=AM --name-only refs/remotes/origin/${{github.base_ref}}... -- | grep -E "^(${source_dir}|tests)/.*\.py$" | xargs
)" >> $GITHUB_ENV
- name: Run pre-commit on modified files
if: github.event_name == 'pull_request' && env.FILES_PARAM
uses: pre-commit/[email protected]
with:
extra_args: --hook-stage push --files ${{ env.FILES_PARAM }}
- name: Run pre-commit on all files
if: github.event_name == 'push'
uses: pre-commit/[email protected]
with:
extra_args: --hook-stage push --all-files

pylint:
name: pylint
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .idea/scopes/sources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 22 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,14 @@ ci:

repos:
- repo: https://github.com/psf/black
rev: 23.7.0
rev: 23.10.1
hooks:
- id: black
- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
hooks:
- id: seed-isort-config
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
additional_dependencies: [toml] # to read config from pyproject.toml
additional_dependencies: [tomli] # to read config from pyproject.toml
- repo: https://github.com/humitos/mirrors-autoflake
rev: v1.1
hooks:
Expand All @@ -33,17 +29,23 @@ repos:
hooks:
- id: flake8
- repo: https://github.com/asottile/pyupgrade
rev: v3.10.1
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py39-plus]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.1
rev: v1.6.1
hooks:
- id: mypy
additional_dependencies: [types-toml]
args: [--ignore-missing-imports, --scripts-are-modules, --show-error-context,
--show-column-numbers]
additional_dependencies: [
types-toml,
tomli, # to read config from pyproject.toml
]
- repo: https://github.com/codingjoe/relint
rev: 3.1.0
hooks:
- id: relint
args: [-W] # to fail on warnings
- repo: local
hooks:
- id: pylint
Expand All @@ -57,16 +59,17 @@ repos:
name: Check copyright
entry: python devtools/check-copyright.py
language: python
types: [python]
exclude: (^setup.py$|(docs|assets)/)
files: (^LICENSE|README.rst|\.py|\.pyi)$
types: [text]
exclude: (^setup.py$|^\.|\b(docs|assets)/)
- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
rev: v2.2.6
hooks:
- id: codespell
exclude: (\.ipynb$|poetry.lock)
exclude: (.lock|\.ipynb|^THIRD_PARTY_SOFTWARE\.rst)$
entry: codespell -I .codespellignore
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude: \.mdj$
Expand All @@ -82,11 +85,13 @@ repos:
- id: mixed-line-ending
- id: name-tests-test
- repo: https://github.com/rstcheck/rstcheck
rev: v6.1.2
rev: v6.2.0
hooks:
- id: rstcheck
exclude: ^THIRD_PARTY_SOFTWARE.rst$
additional_dependencies: [sphinx]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: rst-backticks
exclude: ^THIRD_PARTY_SOFTWARE.rst$
10 changes: 10 additions & 0 deletions .relint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- name: No import os.path
pattern: 'from os import\b.*\bpath\b'
hint: Use from pathlib import Path
filePattern: .*\.pyi?
error: false
- name: No os.path
pattern: '\bos\.path\b'
hint: Use pathlib.Path
filePattern: .*\.pyi?
error: false
15 changes: 2 additions & 13 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 38 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ python = "^3.9, <3.11"

## dependencies on github repos
#geoh5py = { url = "https://github.com/MiraGeoscience/geoh5py/archive/refs/heads/release/0.8.0.zip#sha256=" }
geoh5py = {version ="~0.8.0rc1", source = "pypi", allow-prereleases = true}
geoh5py = {version ="~0.8.0rc1", allow-prereleases = true}

## pip dependencies
lasio = {version = "~0.31", source = "pypi", allow-prereleases = true}
tqdm = {version = "^4.64.0"}
lasio = "~0.31"
tqdm = "^4.64.0"

[tool.poetry.dev-dependencies]
pylint = "*"
pytest = "*"
pytest-cov = "*"
toml = "*"
tomli = "*"

[tool.isort]
# settings for compatibility between ``isort`` and ``black`` formatting
Expand All @@ -28,12 +28,44 @@ include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
line_length = 88
# auto-updated by seed-isort-config
known_third_party = ["geoh5py", "lasio", "numpy", "pytest", "toml", "tqdm"]

[tool.black]
# defaults are just fine

[tool.mypy]
warn_unused_configs = true
ignore_missing_imports = true
scripts_are_modules = true
show_error_context = true
show_column_numbers = true
check_untyped_defs = true

plugins = [
# 'numpy.typing.mypy_plugin'
]

[tool.pytest.ini_options]
addopts = "--cov las_geoh5 --cov-report html --cov-report term-missing:skip-covered"

[tool.coverage.run]
branch = true
source = ["las_geoh5"]
omit = []

[tool.coverage.report]
exclude_lines = [
"raise NotImplementedError",
"pass",
"if TYPE_CHECKING",
"pragma: no cover"
]

fail_under = 80

[tool.coverage.html]
skip_empty = true
skip_covered = true

[build-system]
requires = ["poetry-core>=1.0.0", "setuptools"]
build-backend = "poetry.core.masonry.api"
21 changes: 21 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 2023 Mira Geoscience Ltd.
#
# This file is part of las_geoh5 project.
#
# All rights reserved.

from __future__ import annotations

from pathlib import Path

import pytest
import tomli as toml


@pytest.fixture
def pyproject() -> dict:
"""Return the pyproject.toml as a dictionary."""

pyproject_path = Path(__file__).resolve().parents[1] / "pyproject.toml"
with open(pyproject_path, "rb") as pyproject_file:
return toml.load(pyproject_file)
16 changes: 2 additions & 14 deletions tests/version_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,12 @@
from __future__ import annotations

import re
from pathlib import Path

import toml

import las_geoh5


def get_version():
path = Path(__file__).resolve().parents[1] / "pyproject.toml"

with open(str(path), encoding="utf-8") as file:
pyproject = toml.loads(file.read())

return pyproject["tool"]["poetry"]["version"]


def test_version_is_consistent():
assert las_geoh5.__version__ == get_version()
def test_version_is_consistent(pyproject: dict):
assert las_geoh5.__version__ == pyproject["tool"]["poetry"]["version"]


def test_version_is_semver():
Expand Down

0 comments on commit 26e338a

Please sign in to comment.