First MVP
This commit is contained in:
107
.gitea/workflows/ci.yml
Normal file
107
.gitea/workflows/ci.yml
Normal file
@@ -0,0 +1,107 @@
|
||||
name: ci
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
tags: [ 'v*' ]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
mariadb:
|
||||
image: mariadb:11
|
||||
env:
|
||||
MARIADB_DATABASE: gitea_codex
|
||||
MARIADB_USER: gitea_codex
|
||||
MARIADB_PASSWORD: gitea_codex
|
||||
MARIADB_ROOT_PASSWORD: rootpass
|
||||
ports:
|
||||
- 3306:3306
|
||||
options: >-
|
||||
--health-cmd "mariadb-admin ping -h localhost -uroot -prootpass"
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 10
|
||||
|
||||
env:
|
||||
GITEA_BASE_URL: https://gitea.reversed.dev
|
||||
GITEA_TOKEN: test
|
||||
GITEA_BOT_USERNAME: codex-bot
|
||||
GITEA_WEBHOOK_SECRET: testsecret
|
||||
OPENAI_API_KEY: test-openai
|
||||
ALLOWED_REPOS: org/repo
|
||||
COOLDOWN_SECONDS: 60
|
||||
WEBHOOK_MODE: repo
|
||||
DB_HOST: 127.0.0.1
|
||||
DB_PORT: 3306
|
||||
DB_NAME: gitea_codex
|
||||
DB_USER: gitea_codex
|
||||
DB_PASSWORD: gitea_codex
|
||||
TEST_DATABASE_URL: mysql+pymysql://gitea_codex:gitea_codex@127.0.0.1:3306/gitea_codex?charset=utf8mb4
|
||||
WORKDIR: /tmp/work
|
||||
MAX_DIFF_BYTES: 200000
|
||||
MAX_REVIEW_MINUTES: 10
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
- name: Install deps
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -e .[dev]
|
||||
- name: Run Alembic migrations
|
||||
run: alembic upgrade head
|
||||
- name: Run tests
|
||||
run: pytest
|
||||
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
if: gitea.event_name == 'push'
|
||||
env:
|
||||
REGISTRY: gitea.reversed.dev
|
||||
IMAGE_NAME: space/gitea-codex
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
- name: Login to Gitea container registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
- name: Build and push tags
|
||||
shell: bash
|
||||
env:
|
||||
CI_SHA: ${{ gitea.sha }}
|
||||
CI_REF_NAME: ${{ gitea.ref_name }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
IMAGE="${REGISTRY}/${IMAGE_NAME}"
|
||||
SHA_TAG="sha-${CI_SHA::12}"
|
||||
REF_TAG="${CI_REF_NAME}"
|
||||
docker buildx build --push \
|
||||
-t "${IMAGE}:${SHA_TAG}" \
|
||||
-t "${IMAGE}:${REF_TAG}" \
|
||||
.
|
||||
if [ "${CI_REF_NAME}" = "main" ]; then
|
||||
docker buildx build --push -t "${IMAGE}:latest" .
|
||||
fi
|
||||
- name: Publish image summary
|
||||
shell: bash
|
||||
env:
|
||||
CI_SHA: ${{ gitea.sha }}
|
||||
CI_REF_NAME: ${{ gitea.ref_name }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
IMAGE="${REGISTRY}/${IMAGE_NAME}"
|
||||
echo "Published image tags:" >> "${GITHUB_STEP_SUMMARY}"
|
||||
echo "- ${IMAGE}:${CI_REF_NAME}" >> "${GITHUB_STEP_SUMMARY}"
|
||||
echo "- ${IMAGE}:sha-${CI_SHA::12}" >> "${GITHUB_STEP_SUMMARY}"
|
||||
if [ "${CI_REF_NAME}" = "main" ]; then
|
||||
echo "- ${IMAGE}:latest" >> "${GITHUB_STEP_SUMMARY}"
|
||||
fi
|
||||
Reference in New Issue
Block a user