Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major Refactor, Dockerfile Changes, Unit Test Workflow, and Other Improvements #56

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/workflows/unittests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Pytest

on:
push:
branches:
- master
pull_request: {}

jobs:
test:
name: Unit Tests
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-22.04, windows-latest, macos-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]

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

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
cache: pip

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov
pip install -r requirements.txt

- name: Test
run: |
pytest

coverage:
name: Coverage Summary
runs-on: ubuntu-22.04
permissions:
pull-requests: write
contents: read

if: github.event_name == 'pull_request'
strategy:
fail-fast: false

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

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.11"
cache: pip

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov
pip install -r requirements.txt

- name: Run Coverage
run: |
pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=semver | tee pytest-coverage.txt

- name: Comment Result Summary
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ dist/
*.zip
env
# Byte-compiled / optimized / DLL files
tests/
__pycache__/
*.py[cod]
*$py.class
Expand Down
48 changes: 26 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
FROM centos/python-36-centos7

USER root
# ======= #
# Builder #
# ======= #
FROM python:3.11-slim as builder
COPY / /semver
RUN pip wheel --no-cache-dir --wheel-dir /wheels /semver

#Perform updates
RUN pip install --upgrade pip
RUN yum update -y
RUN yum -y remove git
RUN yum -y install https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm
RUN yum -y install git
# ======== #
# Finalize #
# ======== #
FROM python:3.11-slim

#Setup semver
ADD / /semver
WORKDIR /semver
RUN python setup.py sdist
RUN pip install dist/semver-*.tar.gz
# Update and install git
RUN apt-get update && apt-get install -y git

# Create user
RUN mkdir /semver && \
groupadd -g 10001 semver && \
useradd -u 10000 -g semver -d /semver semver \
&& chown -R semver:semver /semver

# Prep workspace
RUN mkdir /workspace
WORKDIR /workspace
RUN mkdir /workspace && \
chown -R semver:semver /workspace
VOLUME /workspace

#Permissions
RUN useradd -d /semverUser semverUser
RUN chown -R semverUser:semverUser /workspace
# Setup semver
COPY --from=builder /wheels /semver/wheels
RUN pip install --no-cache /semver/wheels/*

CMD [ "semver" ]

USER semverUser
USER semver:semver
WORKDIR /workspace
ENTRYPOINT [ "semver" ]
41 changes: 41 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[project]
name = "semver"
authors = [
{ name = "RightBrain Networks", email = "cloud@rightbrainnetworks.com"}
]
description = "Automatic Semantic Versioner"
readme = "README.md"
requires-python = ">=3.8"
keywords = ["Semantic", "Version", "Git", "Auto-Versioning"]
license = {file = "license.txt"}
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",

# Development Status
"Development Status :: 3 - Alpha",

# Audience
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"Topic :: Software Development :: Build Tools"
]
dependencies = [
"toml"
]
dynamic = ["version"]

[project.urls]
homepage = "https://github.com/RightBrain-Networks/auto-semver"
repository = "https://github.com/RightBrain-Networks/auto-semver"

[project.scripts]
semver = "semver:main"
semver_get_version = "semver.get_version:main"

[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[tool.setuptools.packages.find]
exclude = ["contrib*", "docs*", "test*"]
Loading
Loading