From e1e5c8a028d61cb8d781957359f699e8b1ee128e Mon Sep 17 00:00:00 2001 From: Egor Deev Date: Tue, 6 Oct 2026 17:06:43 +0300 Subject: [PATCH] =?UTF-8?q?CI:=20API=20=D0=B2=20Docker=20=D0=BE=D1=82?= =?UTF-8?q?=D0=B4=D0=B0=D1=91=D1=82=20=D1=82=D0=B5=D1=81=D1=82=D1=8B,=20?= =?UTF-8?q?=D0=BE=D0=B1=D1=80=D0=B0=D0=B7=D1=8B=20caddy/=20=D1=81=D0=BE?= =?UTF-8?q?=D0=B1=D0=B8=D1=80=D0=B0=D1=8E=D1=82=D1=81=D1=8F,=20Qt-=D0=BA?= =?UTF-8?q?=D0=BB=D0=B8=D0=B5=D0=BD=D1=82=20=D0=BD=D0=B0=20Linux=20=D0=B8?= =?UTF-8?q?=20Windows;=20=D1=80=D0=B5=D0=BB=D0=B8=D0=B7=20=E2=80=94=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=82=20=D0=B4=D0=BB=D1=8F=20Win?= =?UTF-8?q?dows=20=D0=B8=20AppImage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 65 ++++++++++++++++++++++++++++ .github/workflows/release.yml | 80 +++++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..de943ed --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,65 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +jobs: + api: + name: API в Docker (lab-2/local) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Сборка и запуск + working-directory: lab-2/local + run: | + cp .env.example .env + docker compose up -d --build --wait postgres_service + docker compose up -d --build + - name: API отдаёт сгенерированные тесты + run: | + for i in $(seq 1 30); do + curl -sf http://localhost/api/quiz/ -o quiz.json && break + sleep 3 + done + python3 -c " + import json + d = json.load(open('quiz.json')) + items = d['results'] if isinstance(d, dict) else d + assert items, 'список тестов пуст' + print('тестов:', d.get('count', len(items)) if isinstance(d, dict) else len(items))" + - name: Журнал при ошибке + if: failure() + working-directory: lab-2/local + run: docker compose logs --tail 50 + + images: + name: Образы caddy/ собираются + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - working-directory: lab-2/caddy + run: cp .env.example .env && docker compose build + + client: + name: Qt-клиент (${{ matrix.os }}) + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: jurplel/install-qt-action@v4 + with: + version: "6.8.*" + cache: true + - name: Зависимости сборки (Linux) + if: runner.os == 'Linux' + run: sudo apt-get update -qq && sudo apt-get install -y -qq libgl1-mesa-dev libxkbcommon-dev + - name: Сборка + working-directory: lab-3 + run: | + cmake -B build -DCMAKE_BUILD_TYPE=Release + cmake --build build --config Release diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ccb66c1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,80 @@ +name: Release + +on: + push: + tags: ["v*"] + workflow_dispatch: + +jobs: + windows: + name: Qt-клиент для Windows + runs-on: windows-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - uses: jurplel/install-qt-action@v4 + with: + version: "6.8.*" + cache: true + - name: Сборка + working-directory: lab-3 + run: | + cmake -B build + cmake --build build --config Release + - name: Программа с библиотеками Qt + run: | + New-Item -ItemType Directory dist/quizlab-client | Out-Null + Copy-Item lab-3/build/Release/lab-3.exe dist/quizlab-client/quizlab-client.exe + windeployqt --release --no-translations --no-system-d3d-compiler --no-opengl-sw dist/quizlab-client/quizlab-client.exe + Compress-Archive -Path dist/quizlab-client -DestinationPath quizlab-client-windows-x64.zip + - uses: actions/upload-artifact@v4 + with: + name: windows + path: quizlab-client-windows-x64.zip + - name: Файл в релиз + if: startsWith(github.ref, 'refs/tags/') + env: + GH_TOKEN: ${{ github.token }} + run: gh release upload "${{ github.ref_name }}" quizlab-client-windows-x64.zip --clobber + + linux: + name: Qt-клиент для Linux (AppImage) + runs-on: ubuntu-22.04 + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - uses: jurplel/install-qt-action@v4 + with: + version: "6.8.*" + cache: true + - run: sudo apt-get update -qq && sudo apt-get install -y -qq libgl1-mesa-dev libxkbcommon-dev libxcb-cursor0 + - name: Сборка + working-directory: lab-3 + run: | + cmake -B build -DCMAKE_BUILD_TYPE=Release + cmake --build build + - name: AppImage + env: + APPIMAGE_EXTRACT_AND_RUN: "1" + OUTPUT: quizlab-client-linux-x86_64.AppImage + run: | + wget -q https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage + wget -q https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage + chmod +x linuxdeploy*.AppImage + mkdir -p appdir + cp lab-3/build/lab-3 quizlab-client + cp lab-3/icons/app.svg quizlab-client.svg + printf '[Desktop Entry]\nType=Application\nName=Quiz Client\nExec=quizlab-client\nIcon=quizlab-client\nCategories=Education;\n' > quizlab-client.desktop + export QMAKE=$(which qmake) + ./linuxdeploy-x86_64.AppImage --appdir appdir -e quizlab-client -d quizlab-client.desktop -i quizlab-client.svg --plugin qt --output appimage + - uses: actions/upload-artifact@v4 + with: + name: linux + path: quizlab-client-linux-x86_64.AppImage + - name: Файл в релиз + if: startsWith(github.ref, 'refs/tags/') + env: + GH_TOKEN: ${{ github.token }} + run: gh release upload "${{ github.ref_name }}" quizlab-client-linux-x86_64.AppImage --clobber