Initial commit

This commit is contained in:
github-classroom[bot]
2025-01-16 17:29:37 +00:00
committed by Igor Baliuk
commit b76ad1afe8
7 changed files with 118 additions and 0 deletions
+79
View File
@@ -0,0 +1,79 @@
name: Run tests
on: deployment
permissions:
contents: read
packages: write
attestations: write
id-token: write
jobs:
build:
name: Build image
runs-on: ubuntu-latest
timeout-minutes: 10
if: github.action != 'github-classroom[bot]'
steps:
- uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Save image name (lowercased)
run: echo "IMAGE_NAME=$(echo 'ghcr.io/${{ github.repository }}:run-${{ github.run_id }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Build and push image
uses: docker/build-push-action@v4
with:
context: ./solution
file: ./solution/Dockerfile
tags: ${{ env.IMAGE_NAME }}
push: true
tests:
needs: build
name: Run tests
runs-on: ubuntu-latest
timeout-minutes: 20
if: github.action != 'github-classroom[bot]'
steps:
- name: Setup checker environment
uses: Central-University-IT/setup-test-2025-backend@v1
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run tests
run: |
export IMAGE_SOLUTION=$(echo 'ghcr.io/${{ github.repository }}:run-${{ github.run_id }}' | tr '[:upper:]' '[:lower:]')
export IMAGE_ANTIFRAUD=docker.io/lodthe/prod-backend-antifraud
/usr/local/bin/checker
continue-on-error: true
- uses: actions/upload-artifact@v4.0.0
with:
name: result
path: ./result.json
if-no-files-found: error
compression-level: 0
- uses: bots-house/ghcr-delete-image-action@v1.1.0
continue-on-error: true
with:
owner: ${{ github.repository_owner }}
name: ${{ github.event.repository.name }}
token: ${{ secrets.GITHUB_TOKEN }}
tag: run-${{ github.run_id }}
+6
View File
@@ -0,0 +1,6 @@
# PROMO v2: Promo Code Backend
Это ваш личный репозиторий для решения второго этапа в треке Backend.
Вы можете редактировать файлы **только в директории `solution`**.
Условие задания и публичные тесты доступны [в данном репозитории](https://github.com/Central-University-IT/FAQ-2025/tree/main/backend).
+5
View File
@@ -0,0 +1,5 @@
.dockerignore
Dockerfile
README.md
.venv/
__pycache__/
+2
View File
@@ -0,0 +1,2 @@
.venv/
__pycache__/
+10
View File
@@ -0,0 +1,10 @@
FROM python:3.12-alpine3.21
WORKDIR /usr/src/app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD [ "python", "./main.py" ]
+14
View File
@@ -0,0 +1,14 @@
import os
from fastapi import FastAPI
import uvicorn
app = FastAPI()
@app.get("/api/ping")
def send():
return {"status": "ok"}
if __name__ == "__main__":
server_address = os.getenv("SERVER_ADDRESS", "0.0.0.0:8080")
host, port = server_address.split(":")
uvicorn.run(app, host=host, port=int(port))
+2
View File
@@ -0,0 +1,2 @@
fastapi
uvicorn