Skip to content

Commit

Permalink
Merge pull request #2 from u-ways/2.32.3.0
Browse files Browse the repository at this point in the history
2.32.3.0
  • Loading branch information
u-ways authored Aug 19, 2024
2 parents 20390c6 + 1847317 commit 80d7c93
Show file tree
Hide file tree
Showing 32 changed files with 2,422 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
### Summary

<!-- Please provide a brief summary of changes made (optional for small changes) -->

#### Definition of Done Checklist:

- [ ] Unit tests are added for new features. (newer projects)
- [ ] Linting and formatting checks have passed.
- [ ] CI/CD pipeline has been successfully executed.
- [ ] If an interface has changed, documentation should be updated.

___
16 changes: 16 additions & 0 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CICD

on:
pull_request:
types: [ opened, synchronize, edited ]
paths-ignore:
- '**.md'

jobs:
CI:
uses: ./.github/workflows/ci-workflow.yml
secrets: inherit
CD:
needs: [CI]
uses: ./.github/workflows/cd-workflow.yml
secrets: inherit
56 changes: 56 additions & 0 deletions .github/workflows/cd-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CD

on: [
workflow_call,
workflow_dispatch
]

env:
APP_VERSION: latest
APP_NAME: ${{ github.event.repository.name }}
APP_OWNER: ${{ github.repository_owner }}

jobs:
Export-Package:
runs-on: ubuntu-22.04
steps:
- name: 'Checkout to current branch'
uses: actions/checkout@v3
- name: 'Build library package'
run: echo "TODO..."
- name: 'Uploading library artifacts'
uses: actions/upload-artifact@v3
with:
name: library-artifacts
path: ./build/library

Publish-Package:
needs: Export-Package
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-22.04
steps:
- name: 'Downloading library artifacts'
uses: actions/download-artifact@v3
with:
name: library-artifacts
- name: 'Log in to Python Package Index (PyPI)'
run: echo "TODO..."
- name: 'Pushing library package to Python Package Index (PyPI)'
run: |
echo "TODO..."
Update-Documentation:
needs: Publish-Package
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-22.04
steps:
- name: 'Updating release version in README.md'
run: echo "TODO..."

Create-Release:
needs: Update-Documentation
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-22.04
steps:
- name: 'Creating release'
run: echo "TODO..."
31 changes: 31 additions & 0 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on: [
workflow_call,
workflow_dispatch
]

jobs:
Check-Format:
runs-on: ubuntu-22.04
steps:
- name: 'Checkout to current branch'
uses: actions/checkout@v3
- name: 'Run format check'
run: make check-format-docker

Check-Linter:
runs-on: ubuntu-22.04
steps:
- name: 'Checkout to current branch'
uses: actions/checkout@v3
- name: 'Run lint check'
run: make check-lint-docker

Check-Tests:
runs-on: ubuntu-22.04
steps:
- name: 'Checkout to current branch'
uses: actions/checkout@v3
- name: 'Run acceptance tests'
run: make check-test-docker
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,7 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.idea/

# VScode workspace settings
.vscode/
28 changes: 28 additions & 0 deletions .hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

# This script is a pre-commit hook that runs the code quality checks before
# allowing a commit to be made. If any of the checks fail, the commit is
# aborted and the user is informed of the error.

# TIP: you can enable this hook by running the following command:
# make enable-pre-commit-hook

if ! make check-format; then
echo "|"
echo "|"
echo "Code quality pre-commit hook error:"
echo "Black formatting failed! Please fix the errors before committing."
echo "TIP: you can run \"make format-code\" to try resolving the error automatically."
exit 1
fi

if ! make check-lint; then
echo "|"
echo "|"
echo "Code quality pre-commit hook error:"
echo "Flake8 linting failed! Please fix the errors before committing."
echo "TIP: you can run \"make lint-code\" to try resolving the error automatically."
exit 1
fi

exit 0
18 changes: 18 additions & 0 deletions .ide/logging-http-client.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/logging_http_client" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">
<option name="format" value="PLAIN" />
<option name="myDocStringFormat" value="Plain" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="py.test" />
</component>
</module>
11 changes: 11 additions & 0 deletions .ide/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"python.analysis.extraPaths": [
"./logging_http_client",
"./tests"
],
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
90 changes: 90 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# An optimised multistaged Dockerfile for Poetry.
# Based of https://github.com/python-poetry/poetry/discussions/1879?sort=top#discussioncomment-216865

################################
# PYTHON-BASE
# Sets up all our shared environment variables
################################
FROM python:3.12-slim as python-base
LABEL python-base=true

ENV PYTHONUNBUFFERED=1 \
# prevents python creating .pyc files
PYTHONDONTWRITEBYTECODE=1 \
\
# pip
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
\
# poetry
# see: https://python-poetry.org/docs/configuration/#using-environment-variables
POETRY_VERSION=1.8.3 \
POETRY_HOME="/opt/poetry" \
POETRY_VIRTUALENVS_IN_PROJECT=true \
POETRY_NO_INTERACTION=1 \
# paths this is where our requirements + virtual environment will live
PYSETUP_PATH="/opt/pysetup" \
# where the virtual environment will be created
VENV_PATH="/opt/pysetup/.venv"

# prepend poetry and venv to path
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"

################################
# BUILDER-BASE
# Used to build deps + create our virtual environment
################################
FROM python-base as builder-base
LABEL builder-base=true

RUN apt-get update \
&& apt-get install --no-install-recommends -y \
# deps for installing poetry
curl \
# deps for building python deps
build-essential

# Installs poetry - respects $POETRY_VERSION & $POETRY_HOME
# The --mount will mount the buildx cache directory to where
# Poetry and Pip store their cache so that they can re-use it
RUN --mount=type=cache,target=/root/.cache \
curl -sSL https://install.python-poetry.org | python3 -

# Switch to the directory with our poetry files
WORKDIR $PYSETUP_PATH

# Copy project requirement files here to ensure they will be cached.
COPY poetry.lock pyproject.toml ./

# Install runtime deps - uses $POETRY_VIRTUALENVS_IN_PROJECT internally
RUN --mount=type=cache,target=/root/.cache \
poetry install --without dev,test --no-root


################################
# DEVELOPMENT
# Image used during development / testing
################################
FROM python-base as development
LABEL development=true

ENV FASTAPI_ENV=development
ENV PYTHONPATH="/app/src:$PYTHONPATH"

# Switch to the directory with our poetry files
WORKDIR $PYSETUP_PATH

# It's important to note that the development stage does not
# include the project source code. (i.e. you're responsible
# for volume mounting the code when you run the container as
# development source shouldn't be part of the image)

# Copy in our built poetry + venv
COPY --from=builder-base $POETRY_HOME $POETRY_HOME
COPY --from=builder-base $PYSETUP_PATH $PYSETUP_PATH

# Quicker install as runtime deps are already installed
RUN --mount=type=cache,target=/root/.cache \
poetry install --with dev,test

WORKDIR /app
Loading

0 comments on commit 80d7c93

Please sign in to comment.