Skip to content

Commit

Permalink
chore: add a CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ClemDoum committed Dec 4, 2024
1 parent cb89942 commit b104d01
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/actions/pylint/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
inputs:
path:
description: 'Path where linting test will be executed'
required: true

runs:
using: "composite"
steps:
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
pip install pylint==3.1.0
- name: Run linting test on $ {{ inputs.path }}
shell: bash
run: |
pylint_rc=$(pwd)/qa/python/pylintrc
cd ${{ inputs.path }}
pylint --rcfile $pylint_rc --load-plugins=pylint.extensions.bad_builtin -r y -j 0 -f colorized **/*.py
23 changes: 23 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Linting test

on:
push:
branches: [ 'main' ]
pull_request:
paths:
- 'ml_worker/**.py'
- '.github/workflows/linting.yml'

# TODO: leverage some caching here
jobs:
linting-worker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/pylint
with:
path: "."

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
54 changes: 54 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Publish release assets

on:
push:
tags:
- '*'

jobs:
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create GH release
run: gh release create "$tag" --generate-notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}

publish-to-dockerhub:
needs: [ create-release ]
runs-on: ubuntu-latest
steps:
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
# Replace this with your own docker hub image
with:
images: <org>/<image>

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
# You'll need to set these secrets
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push image
uses: docker/build-push-action@v6
with:
target: ml-worker
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
52 changes: 52 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Tests

on:
push:
branches: [ 'main' ]
pull_request:
paths:
- 'ml_worker/**.py'
- 'pyproject.toml'
- 'uv.lock'
- '.github/workflows/tests.yml'

jobs:
test-worker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: psf/black@stable
with:
options: "--check --verbose"
jupyter: true
src: "."
version: "~= 24.2.0"
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "0.5.5"
python-version: "3.11"
enable-cache: true
- name: Setup Python project
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Run tests
run: uv run --frozen pytest -vvv --cache-clear --show-capture=all -r A .
services:
elasticsearch:
image: elasticsearch:7.17.25
env:
discovery.type: single-node
options: >-
--health-cmd "curl http://localhost:9200"
--health-interval 3s
--health-timeout 1s
--health-retries 10
--health-start-period 5s
ports:
- "9200:9200"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

0 comments on commit b104d01

Please sign in to comment.