Skip to content

Commit

Permalink
Merge pull request #6 from RohithSurya/features/gh_actions
Browse files Browse the repository at this point in the history
Github workflow for docs, coverage, tests
  • Loading branch information
amila-desilva authored Jun 13, 2024
2 parents 78fa01c + 3b13f7a commit e958fef
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 40 deletions.
18 changes: 18 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- Before opening a PR, please read our PR guidelines in CONTRIBUTING.md-->

<!-- PR title: Copy-and-paste the name of the issue this PR is fixing, -->
<!-- and include the issue number in front in square brackets. -->
<!-- e.g. [#1020] Make bash_runcommand in WorkUnitSubmit class configurable -->

<!-- Add the issue number to the "Fixes" keyword below. This will automatically close the issue once the PR is merged -->
Fixes #

### Type of change: <!--- Bug, Feature, Test, Doc -->

### Description
<!--- Describe your changes in detail -->

### Checklist
- Did I make sure I wrote the tests if I have implemented new functionality?
- Did I make sure the test coverage meets the guidelines specified in CONTRIBUTING.md?
- Did I lint and format the code?
28 changes: 28 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Make build
on:
push:
branches:
main
pull_request:
branches:
main
env:
POETRY_HOME: ${{vars.POETRY_HOME}}
POETRY: ${{vars.POETRY}}
jobs:
poetry:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install Poetry and dependencies
run: ./scripts/poetry-install.sh
- name: Make build
run: $POETRY build
- uses: actions/upload-artifact@v4
with:
name: dist
path: ./dist
25 changes: 25 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Make docs
on:
push:
branches:
main
pull_request:
branches:
main
env:
POETRY_HOME: ${{vars.POETRY_HOME}}
POETRY: ${{vars.POETRY}}
jobs:
poetry:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install Poetry and dependencies
run: ./scripts/poetry-install.sh
- name: Check docs
working-directory: ./docs
run: $POETRY run make html
34 changes: 0 additions & 34 deletions .github/workflows/only-run-tests.yaml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/pytest-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test Coverage
on:
push:
branches:
main
pull_request:
branches:
main
workflow_dispatch:
env:
POETRY_HOME: ${{vars.POETRY_HOME}}
POETRY: ${{vars.POETRY}}
jobs:
coverage:
name: PyTest coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install Poetry and dependencies
run: ./scripts/poetry-install.sh
- name: Run Tests
run: |
$POETRY run coverage run -m pytest
continue-on-error: true
- name: Run Coverage
run: $POETRY run coverage xml
- name: Get Cover
uses: orgoro/[email protected]
with:
coverageFile: ./coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
14 changes: 14 additions & 0 deletions .github/workflows/ruff.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Ruff
on:
push:
branches:
main
pull_request:
branches:
main
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
32 changes: 32 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Run tests
on:
push:
branches:
main
pull_request:
branches:
main
env:
POETRY_HOME: ${{vars.POETRY_HOME}}
POETRY: ${{vars.POETRY}}
HPCC_USERNAME: ${{ secrets.HPCC_USERNAME }}
HPCC_PASSWORD: ${{ secrets.HPCC_PASSWORD }}
DUMMY_USERNAME: ${{ secrets.DUMMY_USERNAME }}
DUMMY_PASSWORD: ${{ secrets.DUMMY_PASSWORD }}
HPCC_HOST: ${{ secrets.HPCC_HOST }}
HPCC_PORT: ${{ secrets.HPCC_PORT }}
DUMMY_HOST: ${{ secrets.DUMMY_HOST }}
DUMMY_PORT: ${{ secrets.DUMMY_PORT }}
jobs:
poetry:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install Poetry and dependencies
run: ./scripts/poetry-install.sh
- name: Python tests
run: $POETRY run pytest
18 changes: 18 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,23 @@ ruff format # For formatting your code.
```


## PR Guidelines
For test coverage, please make sure to have more than 85% code coverage for both the individual and overall.
To check code coverage, run the following commands
``` bash
poetry run coverage run
poetry run coverage report
```

## Submitting an PR
[Create a PR](https://help.github.com/articles/creating-a-pull-request/) with the following configuration:

The base branch is the main repo's main branch.
- PR name: copy-and-paste the relevant issue name and include the issue number in front in square brackets, e.g. `[#1020] Make bash_runcommand in WorkUnitSubmit class configurable `
- PR description: mention the issue number in this format: Fixes #1020. Doing so will automatically close the related issue once the PR is merged.
- Please Ensure that "Allow edits from maintainers" is ticked.
- Please describe the changes you have made in your branch and how they resolve the issue.




7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ elementpath = "^3.0.2" # XPath selectors for XML Data structures
pytest = "^7.1.3"
pytest-mock = "^3.0.2"

[tool.poetry.group.coverage.dependencies]
coverage = "^7.5.3"


#For Python Coverage
[tool.coverage.run]
command_line = "-m pytest"
source = ["."]


[build-system]
Expand Down
4 changes: 4 additions & 0 deletions scripts/poetry-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
python3 -m venv $POETRY_HOME
$POETRY_HOME/bin/pip install poetry==1.2.0
$POETRY install
11 changes: 6 additions & 5 deletions tests/test_hpcc_api.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Unit tests to test the authentication module
import config
import os # used by test_UploadFile
import unittest

from datetime import datetime # used by test_UploadFile
from pyhpcc.auth import auth
from pyhpcc.models import hpcc

import config

from pyhpcc.auth import Auth
from pyhpcc.errors import HPCCException
from pyhpcc.models import hpcc


class TestHPCCAPI(unittest.TestCase):
Expand All @@ -19,7 +20,7 @@ class TestHPCCAPI(unittest.TestCase):
DUMMY_HPCC_HOST = config.DUMMY_HPCC_HOST
DUMMY_HPCC_PORT = config.DUMMY_HPCC_PORT

AUTH_OBJ = auth(HPCC_HOST, HPCC_PORT, HPCC_USERNAME, HPCC_PASSWORD, True, "https")
AUTH_OBJ = Auth(HPCC_HOST, HPCC_PORT, HPCC_USERNAME, HPCC_PASSWORD, True, "https")
HPCC_OBJ = hpcc(AUTH_OBJ)

# Used by test_AddtoSuperfileRequest, test_getSubFileInfoall
Expand Down

0 comments on commit e958fef

Please sign in to comment.