Skip to content

chore: formatted python files #23

chore: formatted python files

chore: formatted python files #23

Workflow file for this run

name: CI
on: push
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Setup venv
run: |
python -m venv $PWD/venv
export PATH="$PWD/venv:$PATH"
pip install -r ./requirements.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
- name: Analysing the code with pylint
run: |
pylint --fail-under=9 *.py services tests
- name: Linting Dockerfile
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile
unittests:
runs-on: ubuntu-latest
needs: lint
strategy:
matrix:
python-version: ["3.12"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Setup venv
run: |
python -m venv $PWD/venv
echo $PWD/venv
export PATH="$PWD/venv:$PATH"
pip install -r ./requirements.txt
- name: Install pytest
run: |
pip install pytest
- name: Run pytest
run: |
pytest
build:
# https://docs.docker.com/build/ci/github-actions/share-image-jobs/
# https://github.com/nektos/act/issues/329#issuecomment-1187246629
runs-on: ubuntu-latest
needs: unittests
permissions:
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract version number
run: |
ver=$(grep -oP '"[\S]*"' version.py | cut -d'"' -f2)
echo "Version=$ver" >> "$GITHUB_ENV"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64
tags: ghcr.io/bourbonbourbon/ddp:${{ env.Version }}
target: prod
version-check:
# https://docs.docker.com/build/ci/github-actions/share-image-jobs/
# https://github.com/nektos/act/issues/329#issuecomment-1187246629
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract version number
run: |
ver=$(grep -oP '"[\S]*"' version.py | cut -d'"' -f2)
echo "Version=$ver" >> "$GITHUB_ENV"
- name: Run Docker Image
run: |
docker run -d -p 8080:8080 --name ddp ghcr.io/bourbonbourbon/ddp:${{ env.Version }}
- name: Version Check
run: |
sleep 2 && \
if [ $(curl -s http://localhost:8080/version | jq ".version") == $(grep -i version version.py | cut -d "=" -f 2) ]; then echo "Version Check Successful"; else echo "Version Check Failed"; fi
- name: Stop and Remove Docker Container
run: |
docker stop ddp
docker rm ddp