Skip to content

Commit

Permalink
Merge pull request #84 from collinmutembei/update-gh-action
Browse files Browse the repository at this point in the history
WIP: Fix CI/CD
  • Loading branch information
collinmutembei committed Oct 20, 2023
2 parents 31174ea + 3b677fb commit 1594560
Show file tree
Hide file tree
Showing 12 changed files with 1,157 additions and 864 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# [Choice] Python version: 3, 3.8, 3.7, 3.6
ARG VARIANT=3.10
ARG VARIANT=3.12
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}

ENV PYTHONUNBUFFERED 1
Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
8000, // api
5432, // postgres
6379, // redis
1025, // mailhog
8025, // mailhog-ui
1025, // mailpit
8025, // mailpit-ui
9000, // minio
9001 // minio-console
],
Expand Down
12 changes: 6 additions & 6 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
# [Choice] Python version: 3, 3.8, 3.7, 3.6
VARIANT: 3
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
NODE_VERSION: "lts/*"
NODE_VERSION: "none"
# On Linux, you may need to update USER_UID and USER_GID below if not your local UID is not 1000.
USER_UID: 1000
USER_GID: 1000
Expand Down Expand Up @@ -56,7 +56,7 @@ services:
# (Adding the "ports" property to this file will not forward from a Codespace.)

redis:
image: redis:latest
image: redis/redis-stack:latest
container_name: redis
restart: unless-stopped
volumes:
Expand All @@ -68,9 +68,9 @@ services:
timeout: 5s
retries: 5

mailhog:
image: mailhog/mailhog:latest
container_name: mailhog
mail:
image: axllent/mailpit:latest
container_name: mailpit
restart: unless-stopped
network_mode: service:db

Expand All @@ -79,7 +79,7 @@ services:
container_name: minio
restart: unless-stopped
network_mode: service:db
command: minio --compat server /data --console-address ":9001"
command: -c 'minio --compat server /data --console-address ":9001"'
environment:
MINIO_ROOT_USER: minio
MINIO_ROOT_PASSWORD: password
Expand Down
44 changes: 25 additions & 19 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Continuos Integration + Delivery Action
name: CI/CD

on:
pull_request:
Expand All @@ -16,11 +16,21 @@ env:
LINKEIN_CLIENT_SECRET: test
MINIO_ACCESS_KEY: test
MINIO_SECRET_KEY: test
PIPENV_VENV_IN_PROJECT: 1

jobs:
checks:
runs-on: ubuntu-latest
container: python:3.10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.12
- uses: pre-commit/action@v3.0.0

tests:
runs-on: ubuntu-latest
needs: [checks]

services:
postgres:
Expand All @@ -36,47 +46,43 @@ jobs:
--health-retries 5
steps:
- uses: actions/checkout@v2

- name: Install system dependencies
run: apt-get install -y libpq-dev
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.12

- name: Install pipenv
run: |
python -m pip install --upgrade pipenv wheel
python -m pip install --upgrade pip pipenv wheel
- id: cache-pipenv
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
path: .venv
key: pipenv-${{ hashFiles('**/Pipfile.lock') }}

- name: Install dependencies
if: steps.cache-pipenv.outputs.cache-hit != 'true'
run: |
pipenv install --deploy --dev
- name: Run Linters and Checks
run: |
pipenv run pre-commit run --all
- name: Run tests
run: |
pipenv run pytest --cov=src
build_and_publish:
runs-on: ubuntu-latest
needs: [checks]
needs: [tests]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Build and publish app
uses: openzim/docker-publish-action@v6
uses: openzim/docker-publish-action@v10
with:
image-name: collinmutembei/api-people
image-name: collinmutembei/people
on-master: latest
latest-on-tag: true
restrict-to: collinmutembei/api-people
restrict-to: collinmutembei/people
registries: |
ghcr.io
credentials: |
Expand Down
16 changes: 8 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@ exclude: ^src/migrations/
default_stages: [commit, push]
repos:
- repo: https://github.com/asottile/blacken-docs
rev: v1.10.0
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies: [black]

- repo: https://github.com/ambv/black
rev: 20.8b1
rev: 23.10.0
hooks:
- id: black
language_version: python3.9
language_version: python3.12

- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.1
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
args: [--max-line-length=131]

- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.8.0
rev: v5.10.1
hooks:
- id: isort
args: ["--profile", "black"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.812
rev: v1.6.1
hooks:
- id: mypy

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude_types: [svg]
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# pull official base image
FROM python:3.10-slim-buster
FROM python:3.12-slim-buster

LABEL org.opencontainers.image.title="collinmutembei/api-people" \
LABEL org.opencontainers.image.title="collinmutembei/people" \
org.opencontainers.image.description="API service for people information" \
org.opencontainers.image.url="https://collinmutembei.dev/projects/api-service-template" \
org.opencontainers.image.source="https://github.com/collinmutembei/api-people" \
org.opencontainers.image.url="=ghcr.io/collinmutembei/people" \
org.opencontainers.image.source="https://github.com/collinmutembei/people" \
org.opencontainers.image.revision="$COMMIT_ID" \
org.opencontainers.image.version="$PROJECT_VERSION" \
org.opencontainers.image.authors="Collin Mutembei (https://collinmutembei.dev)" \
Expand Down
34 changes: 17 additions & 17 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ verify_ssl = true
name = "pypi"

[packages]
fastapi = "==0.68.2"
uvicorn = "==0.20.0"
tortoise-orm = {version = "==0.17.8", extras = ["asyncpg"]}
fastapi-users = {version = "==8.1.1", extras = ["oauth", "tortoise-orm"]}
aerich = "==0.6.3"
python-decouple = "==3.6"
fastapi-crudrouter = "==0.8.5"
pydantic = "==1.9.1"
loguru = "==0.6.0"
httpx-oauth = "==0.3.8"
fastapi-mail = "==1.1.5"
python-rapidjson = "==1.9"
minio = "==7.1.12"
python-magic = "==0.4.27"
pandas = "==1.5.2"
phonenumbers = "==8.12.50"
fastapi = "*"
uvicorn = "*"
tortoise-orm = {version = "*", extras = ["asyncpg"]}
fastapi-users = {version = "==8.1.5", extras = ["oauth", "tortoise-orm"]}
aerich = "*"
python-decouple = "*"
fastapi-crudrouter = "*"
pydantic = "*"
loguru = "*"
httpx-oauth = "*"
fastapi-mail = "*"
python-rapidjson = "*"
minio = "*"
python-magic = "*"
pandas = "*"
phonenumbers = "*"

[dev-packages]
ipdb = "*"
Expand All @@ -32,4 +32,4 @@ asynctest = "*"
jsf = "*"

[requires]
python_version = "3.10"
python_version = "3.12"
Loading

0 comments on commit 1594560

Please sign in to comment.