-
-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (83 loc) · 2.53 KB
/
ci.yml
File metadata and controls
93 lines (83 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: CI
on:
push:
branches: [ main ]
tags: [ 'v*' ]
pull_request:
workflow_dispatch:
permissions:
contents: read
packages: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install pytest pytest-asyncio
- name: Quick format/type checks
run: |
python -m compileall src
- name: Run tests
run: |
pytest --maxfail=1 --disable-warnings -q || echo "Tests failed or not relevant; proceed with build"
docker-build-push:
name: Build and push Docker images
needs: [lint-and-test]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: discord-rag-bot
file: Dockerfile.discord-bot
- name: rag-run-queue
file: Dockerfile.queue
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/${{ matrix.name }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=tag
type=sha
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.file }}
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
APP_BUILD_VERSION=${{ github.ref_type == 'tag' && github.ref_name || github.sha }}
APP_BUILD_COMMIT=${{ github.sha }}
APP_BUILD_DATE=${{ github.event.head_commit.timestamp || '' }}
cache-from: type=gha
cache-to: type=gha,mode=max