Skip to content

Commit

Permalink
better github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Ledoux committed Oct 22, 2024
1 parent 0207722 commit c0e54af
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 102 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/build_and_push_on_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build And Push On Release

on:
release:
types: [published]

jobs:
build-and-push:
runs-on: ubuntu-latest
env:
CPU_IMAGE_NAME: ghcr.io/${{ github.repository }}/cpu
CUDA_IMAGE_NAME: ghcr.io/${{ github.repository }}/cuda
IMAGE_TAG: ${{ github.sha }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

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

- name: Build and push cpu
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.cpu
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.CPU_IMAGE_NAME }}:${{ env.IMAGE_TAG }},${{ env.CPU_IMAGE_NAME }}:latest
cache-from: type=registry,ref=${{ env.CPU_IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.CPU_IMAGE_NAME }}:buildcache,mode=max

- name: Build and push cuda
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.cuda
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.CUDA_IMAGE_NAME }}:${{ env.IMAGE_TAG }},${{ env.CUDA_IMAGE_NAME }}:latest
cache-from: type=registry,ref=${{ env.CUDA_IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.CUDA_IMAGE_NAME }}:buildcache,mode=max
26 changes: 26 additions & 0 deletions .github/workflows/deploy_on_dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Deploy On Dispatch

on:
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Trigger prod deployment
run: |
RESPONSE="$(curl --request POST \
--form token=${{ secrets.GITLAB_CI_TOKEN }} \
--form ref=main \
--form 'variables[pipeline_name]=${{ github.event.repository.name }} - ${{ github.event.head_commit.message }}' \
--form 'variables[docker_image_tag]=latest' \
--form 'variables[application_to_deploy]=models' \
--form 'variables[deployment_environment]=prod' \
'https://gitlab.com/api/v4/projects/58117805/trigger/pipeline')"
if echo "$RESPONSE" | grep -q '"status":"created"'; then
echo $RESPONSE
else
echo $RESPONSE
exit 1
fi
20 changes: 20 additions & 0 deletions .github/workflows/lint_on_master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Lint On Master

on:
push:
branches:
- master

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v2
with:
version: "0.4.11"
enable-cache: true
- run: uv python install 3.12
- run: uv sync --extra dev
- run: uv run ruff check .
- run: uv run ruff format --check --diff .
102 changes: 0 additions & 102 deletions .github/workflows/lint_test_build_and_deploy.yml

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/test_on_tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Test On Tag

on:
push:
tags:
- 'v*'

jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v2
with:
version: "0.4.11"
enable-cache: true
- run: uv python install 3.12
- run: uv sync --all-extras
# TODO: figure out why `pytest` doesn't discover tests in `faster_whisper_server` directory by itself
- run: uv run pytest -m "not requires_openai" src/faster_whisper_server/* test

0 comments on commit c0e54af

Please sign in to comment.