Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 84c579e01e | |||
| 2d02e50451 | |||
| 267108eda8 |
+32
-41
@@ -1,17 +1,8 @@
|
|||||||
name: cabinet-ci-cd
|
name: cabinet-ci-cd
|
||||||
|
|
||||||
|
# Pre-deploy PHPUnit on test|stage. Prod — без автотестов.
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
branch:
|
|
||||||
description: 'Ветка для прогона тестов'
|
|
||||||
required: true
|
|
||||||
default: test
|
|
||||||
type: choice
|
|
||||||
options:
|
|
||||||
- prod
|
|
||||||
- test
|
|
||||||
- stage
|
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'cabinet-v*'
|
- 'cabinet-v*'
|
||||||
@@ -22,28 +13,7 @@ env:
|
|||||||
IMAGE_DEPLOY: git.sova.local/sova/cabinet
|
IMAGE_DEPLOY: git.sova.local/sova/cabinet
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
|
||||||
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/cabinet-v')
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.branch || github.ref }}
|
|
||||||
- name: Setup PHP
|
|
||||||
uses: shivammathur/setup-php@v2
|
|
||||||
with:
|
|
||||||
php-version: '8.4'
|
|
||||||
extensions: pdo_pgsql, pdo_mysql, redis, intl, zip, gd
|
|
||||||
- name: Prepare CI environment
|
|
||||||
run: |
|
|
||||||
cp .env.ci .env.local
|
|
||||||
mkdir -p var
|
|
||||||
- run: composer install --prefer-dist --no-interaction
|
|
||||||
- run: composer phpunit || true
|
|
||||||
- run: composer audit || true
|
|
||||||
|
|
||||||
parse-tag:
|
parse-tag:
|
||||||
if: startsWith(github.ref, 'refs/tags/cabinet-v')
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
full_tag: ${{ steps.meta.outputs.full_tag }}
|
full_tag: ${{ steps.meta.outputs.full_tag }}
|
||||||
@@ -58,9 +28,36 @@ jobs:
|
|||||||
echo "env=$(echo "$TAG" | sed -E 's/cabinet-v([0-9.]+)-([a-z]+)/\2/')" >> "$GITHUB_OUTPUT"
|
echo "env=$(echo "$TAG" | sed -E 's/cabinet-v([0-9.]+)-([a-z]+)/\2/')" >> "$GITHUB_OUTPUT"
|
||||||
echo "version=$(echo "$TAG" | sed -E 's/cabinet-v([0-9.]+).*/\1/')" >> "$GITHUB_OUTPUT"
|
echo "version=$(echo "$TAG" | sed -E 's/cabinet-v([0-9.]+).*/\1/')" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
test:
|
||||||
|
needs: [parse-tag]
|
||||||
|
if: needs.parse-tag.outputs.env != 'prod'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: '8.4'
|
||||||
|
extensions: pdo_pgsql, pdo_mysql, redis, intl, zip, gd
|
||||||
|
- name: Prepare CI environment
|
||||||
|
run: |
|
||||||
|
cp .env.ci .env.local
|
||||||
|
mkdir -p var
|
||||||
|
- run: composer install --prefer-dist --no-interaction
|
||||||
|
- name: PHPUnit
|
||||||
|
run: composer phpunit
|
||||||
|
- run: composer audit || true
|
||||||
|
|
||||||
|
test-prod-skip:
|
||||||
|
needs: [parse-tag]
|
||||||
|
if: needs.parse-tag.outputs.env == 'prod'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: echo "Prod tag — automated tests skipped."
|
||||||
|
|
||||||
build-and-push:
|
build-and-push:
|
||||||
needs: [test, parse-tag]
|
needs: [parse-tag, test, test-prod-skip]
|
||||||
if: startsWith(github.ref, 'refs/tags/cabinet-v')
|
if: always() && (needs.test.result == 'success' || needs.test.result == 'skipped') && (needs.test-prod-skip.result == 'success' || needs.test-prod-skip.result == 'skipped')
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -79,7 +76,6 @@ jobs:
|
|||||||
|
|
||||||
deploy-gitops:
|
deploy-gitops:
|
||||||
needs: [build-and-push, parse-tag]
|
needs: [build-and-push, parse-tag]
|
||||||
if: startsWith(github.ref, 'refs/tags/cabinet-v')
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Bump image tag in sova-deploy
|
- name: Bump image tag in sova-deploy
|
||||||
@@ -115,13 +111,8 @@ jobs:
|
|||||||
git add "apps/cabinet/values-${ENV}.yaml"
|
git add "apps/cabinet/values-${ENV}.yaml"
|
||||||
git diff --cached --quiet && { echo "No changes"; exit 0; }
|
git diff --cached --quiet && { echo "No changes"; exit 0; }
|
||||||
git commit -m "chore(cabinet): bump ${ENV} to ${TAG}"
|
git commit -m "chore(cabinet): bump ${ENV} to ${TAG}"
|
||||||
if git push origin "${ENV}"; then
|
if git push origin "${ENV}"; then exit 0; fi
|
||||||
echo "Push OK on attempt ${attempt}"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
echo "Push failed, retry ${attempt}/${MAX_RETRIES}..."
|
|
||||||
git reset --hard HEAD~1
|
git reset --hard HEAD~1
|
||||||
sleep $((attempt * 2))
|
sleep $((attempt * 2))
|
||||||
done
|
done
|
||||||
echo "Failed to push after ${MAX_RETRIES} attempts"
|
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
-10
@@ -1,14 +1,5 @@
|
|||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
FROM node:24-alpine AS assets
|
|
||||||
WORKDIR /app
|
|
||||||
COPY package.json yarn.lock* ./
|
|
||||||
RUN corepack enable && if [ -f yarn.lock ]; then yarn install --frozen-lockfile; else yarn install; fi
|
|
||||||
COPY webpack.config.js ./
|
|
||||||
COPY assets ./assets
|
|
||||||
COPY public ./public
|
|
||||||
RUN yarn build
|
|
||||||
|
|
||||||
FROM composer:2 AS vendor
|
FROM composer:2 AS vendor
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY composer.json composer.lock* ./
|
COPY composer.json composer.lock* ./
|
||||||
@@ -38,7 +29,6 @@ RUN cp /usr/share/zoneinfo/$TZ /etc/localtime && echo "$TZ" > /etc/timezone
|
|||||||
|
|
||||||
COPY docker/fpm-pool.conf /usr/local/etc/php-fpm.d/zz-docker.conf
|
COPY docker/fpm-pool.conf /usr/local/etc/php-fpm.d/zz-docker.conf
|
||||||
COPY --from=vendor /app /app
|
COPY --from=vendor /app /app
|
||||||
COPY --from=assets /app/public/build /app/public/build
|
|
||||||
|
|
||||||
RUN mkdir -p var/cache var/log public/uploads public/banners \
|
RUN mkdir -p var/cache var/log public/uploads public/banners \
|
||||||
&& chown -R www-data:www-data var public/uploads public/banners \
|
&& chown -R www-data:www-data var public/uploads public/banners \
|
||||||
|
|||||||
@@ -207,15 +207,7 @@ function countDown(options) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function isTestContour() {
|
|
||||||
return /\.sova\.local$/i.test(location.hostname);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getApiHostname() {
|
function getApiHostname() {
|
||||||
if (isTestContour()) {
|
|
||||||
return 'http://api.test.sova.local';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (/sovamed\.ru/m.test(location.hostname)) {
|
if (/sovamed\.ru/m.test(location.hostname)) {
|
||||||
return 'https://api.sovamed.ru';
|
return 'https://api.sovamed.ru';
|
||||||
}
|
}
|
||||||
@@ -224,10 +216,6 @@ function getApiHostname() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getHostname() {
|
function getHostname() {
|
||||||
if (isTestContour()) {
|
|
||||||
return location.origin;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (/sovamed\.ru/m.test(location.hostname)) {
|
if (/sovamed\.ru/m.test(location.hostname)) {
|
||||||
return 'https://cabinet.sovamed.ru';
|
return 'https://cabinet.sovamed.ru';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
const helper = require("./helper.js");
|
const helper = require("./helper.js");
|
||||||
const testSdk = require("./testSdk.js");
|
|
||||||
|
|
||||||
function esia() {
|
function esia() {
|
||||||
if (document.location.search == '?esia=true') {
|
if (document.location.search == '?esia=true') {
|
||||||
@@ -40,14 +39,6 @@ function esia() {
|
|||||||
|
|
||||||
function loadSDK(controller) {
|
function loadSDK(controller) {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
if (testSdk.install()) {
|
|
||||||
console.log(controller + ' - test sdk (sova.local)');
|
|
||||||
window.webSDK = new WrSDK();
|
|
||||||
esia();
|
|
||||||
resolve(window.webSDK);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var script = document.getElementById('sdk-infoclinica');
|
var script = document.getElementById('sdk-infoclinica');
|
||||||
|
|
||||||
if (script == null) {
|
if (script == null) {
|
||||||
|
|||||||
@@ -1,115 +0,0 @@
|
|||||||
/**
|
|
||||||
* Test-contour shim for the MIS webSDK (WrSDK) and Yandex SmartCaptcha.
|
|
||||||
*
|
|
||||||
* Production keeps loading the real SDK from widget.sovamed.ru / widget.wmtmed.ru
|
|
||||||
* and the real captcha from smartcaptcha.yandexcloud.net. Those hosts are not
|
|
||||||
* reachable from the isolated *.sova.local test contour and their captcha sitekey
|
|
||||||
* is bound to production domains, so patient registration cannot complete there.
|
|
||||||
*
|
|
||||||
* This module is a no-op unless the page is served from a *.sova.local host.
|
|
||||||
*/
|
|
||||||
|
|
||||||
function isTestContour() {
|
|
||||||
return typeof location !== 'undefined' && /\.sova\.local$/i.test(location.hostname);
|
|
||||||
}
|
|
||||||
|
|
||||||
function resolveLater(value, ms) {
|
|
||||||
return new Promise(function(resolve) {
|
|
||||||
setTimeout(function() { resolve(value); }, ms || 150);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function rejectLater(value, ms) {
|
|
||||||
return new Promise(function(_, reject) {
|
|
||||||
setTimeout(function() { reject(value); }, ms || 150);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function TestWrSDK() {
|
|
||||||
this.data = { user: { authenticated: false } };
|
|
||||||
this.sdkOrigin = location.origin;
|
|
||||||
}
|
|
||||||
|
|
||||||
TestWrSDK.prototype.on = function(event, callback) {
|
|
||||||
if (typeof callback === 'function') {
|
|
||||||
setTimeout(callback, 0);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
TestWrSDK.prototype.isLoggedIn = function() {
|
|
||||||
return resolveLater({ authenticated: false });
|
|
||||||
};
|
|
||||||
|
|
||||||
// New patient: report "not found" so the UI switches to the registration form.
|
|
||||||
TestWrSDK.prototype.recoveryInit = function() {
|
|
||||||
return rejectLater({ data: { message: 'Пользователь не найден в базе данных (тестовый контур)' } });
|
|
||||||
};
|
|
||||||
|
|
||||||
TestWrSDK.prototype.registerInit = function() {
|
|
||||||
return resolveLater({ data: { rToken: 'test-rtoken-' + Date.now(), email: 'false' } });
|
|
||||||
};
|
|
||||||
|
|
||||||
TestWrSDK.prototype.registerComplete = function() {
|
|
||||||
return resolveLater({ data: { text: 'Тестовый контур: аккаунт создан. Код подтверждения — любой.' } });
|
|
||||||
};
|
|
||||||
|
|
||||||
TestWrSDK.prototype.recoveryComplete = function() {
|
|
||||||
return resolveLater({ data: { message: 'Тестовый контур: пароль установлен.' } });
|
|
||||||
};
|
|
||||||
|
|
||||||
TestWrSDK.prototype.changeTempPassword = function() {
|
|
||||||
return resolveLater({ data: { success: 'Тестовый контур: пароль изменён.' } });
|
|
||||||
};
|
|
||||||
|
|
||||||
TestWrSDK.prototype.loadLoginView = function() {};
|
|
||||||
|
|
||||||
TestWrSDK.prototype.loginClient = function() {
|
|
||||||
return rejectLater({ data: { message: 'Вход в тестовом контуре недоступен: МИС замокана.' } });
|
|
||||||
};
|
|
||||||
|
|
||||||
function installSmartCaptcha() {
|
|
||||||
if (window.smartCaptcha && window.smartCaptcha.__test) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
window.smartCaptcha = {
|
|
||||||
__test: true,
|
|
||||||
render: function(container) {
|
|
||||||
if (container) {
|
|
||||||
container.innerHTML =
|
|
||||||
'<div class="alert alert-info py-1 mb-0" style="font-size:12px">' +
|
|
||||||
'Тестовый контур: проверка капчи отключена</div>';
|
|
||||||
}
|
|
||||||
return 'test-captcha-widget';
|
|
||||||
},
|
|
||||||
getResponse: function() { return 'test-captcha-token'; },
|
|
||||||
subscribe: function(widgetId, event, callback) {
|
|
||||||
if (event === 'success' && typeof callback === 'function') {
|
|
||||||
setTimeout(callback, 0);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
reset: function() {},
|
|
||||||
execute: function() {}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function install() {
|
|
||||||
if (!isTestContour()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
window.WrSDK = TestWrSDK;
|
|
||||||
installSmartCaptcha();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isTestContour()) {
|
|
||||||
installSmartCaptcha();
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
isTestContour: isTestContour,
|
|
||||||
install: install
|
|
||||||
};
|
|
||||||
@@ -3,9 +3,7 @@
|
|||||||
{% block title %}Регистрация пациента{% endblock %}
|
{% block title %}Регистрация пациента{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
{% if 'sova.local' not in app.request.host %}
|
|
||||||
<script id="smartCaptcha" src="https://smartcaptcha.yandexcloud.net/captcha.js"></script>
|
<script id="smartCaptcha" src="https://smartcaptcha.yandexcloud.net/captcha.js"></script>
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block top %}
|
{% block top %}
|
||||||
|
|||||||
Reference in New Issue
Block a user