Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev container setup #113

Merged
merged 5 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "Ubuntu",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/base:jammy",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/rocker-org/devcontainer-features/apt-packages:1": {
"packages": [
"mono-complete"
]
},
"ghcr.io/devcontainers-extra/features/gh-release:1": {
"repo": "oscript-library/ovm",
"version": "latest",
"binaryNames": "ovm.exe",
"additionalFlags": [
"--no-filter-assets-by-platform"
]
}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "bash .devcontainer/postCreateCommand.sh",

"postAttachCommand": "source /home/vscode/.profile",

// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions":[
"1c-syntax.language-1c-bsl",
"EvilBeaver.oscript-debug",
"zhuangtongfa.material-theme",
"yzhang.markdown-all-in-one",
"GitHub.copilot",
"GitHub.copilot-chat"
],

"settings": {
"language-1c-bsl.languageServerReleaseChannel": "prerelease"
}
}
},

"containerEnv": {
"LC_ALL": "en_US.UTF-8"
}

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
15 changes: 15 additions & 0 deletions .devcontainer/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -eux

mkdir -p /home/vscode/.local/bin
echo "mono /usr/local/bin/ovm.exe \"\$@\"" > /home/vscode/.local/bin/ovm
chmod +x /home/vscode/.local/bin/ovm
Comment on lines +5 to +7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Добавьте проверки предусловий и используйте переменные окружения

Текущая реализация имеет несколько потенциальных проблем:

  1. Жёстко закодированный путь /home/vscode предполагает конкретного пользователя
  2. Отсутствует проверка наличия установленного mono
  3. Нет обработки ошибок при операциях с файлами

Предлагаю следующие улучшения:

-mkdir -p /home/vscode/.local/bin
-echo "mono /usr/local/bin/ovm.exe \"\$@\"" > /home/vscode/.local/bin/ovm
-chmod +x /home/vscode/.local/bin/ovm
+# Проверка наличия mono
+if ! command -v mono &> /dev/null; then
+    echo "Ошибка: mono не установлен" >&2
+    exit 1
+fi
+
+# Использование переменных окружения
+USER_HOME="${HOME:-/home/vscode}"
+BIN_DIR="${USER_HOME}/.local/bin"
+
+mkdir -p "${BIN_DIR}"
+echo "mono /usr/local/bin/ovm.exe \"\$@\"" > "${BIN_DIR}/ovm"
+chmod +x "${BIN_DIR}/ovm"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
mkdir -p /home/vscode/.local/bin
echo "mono /usr/local/bin/ovm.exe \"\$@\"" > /home/vscode/.local/bin/ovm
chmod +x /home/vscode/.local/bin/ovm
# Проверка наличия mono
if ! command -v mono &> /dev/null; then
echo "Ошибка: mono не установлен" >&2
exit 1
fi
# Использование переменных окружения
USER_HOME="${HOME:-/home/vscode}"
BIN_DIR="${USER_HOME}/.local/bin"
mkdir -p "${BIN_DIR}"
echo "mono /usr/local/bin/ovm.exe \"\$@\"" > "${BIN_DIR}/ovm"
chmod +x "${BIN_DIR}/ovm"


ovm use --install dev

source /home/vscode/.profile
Comment on lines +9 to +11
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Добавьте проверки результатов выполнения команд

Необходимо добавить проверки успешности выполнения критических операций:

  1. Проверка успешности установки dev версии
  2. Проверка существования файла профиля перед его подключением
-ovm use --install dev
-
-source /home/vscode/.profile
+if ! ovm use --install dev; then
+    echo "Ошибка: не удалось установить dev версию" >&2
+    exit 1
+fi
+
+PROFILE_FILE="${HOME:-/home/vscode}/.profile"
+if [[ -f "${PROFILE_FILE}" ]]; then
+    source "${PROFILE_FILE}"
+else
+    echo "Предупреждение: файл профиля ${PROFILE_FILE} не найден" >&2
+fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ovm use --install dev
source /home/vscode/.profile
if ! ovm use --install dev; then
echo "Ошибка: не удалось установить dev версию" >&2
exit 1
fi
PROFILE_FILE="${HOME:-/home/vscode}/.profile"
if [[ -f "${PROFILE_FILE}" ]]; then
source "${PROFILE_FILE}"
else
echo "Предупреждение: файл профиля ${PROFILE_FILE} не найден" >&2
fi


opm install opm
opm install oscript-config
opm install -l
Comment on lines +13 to +15
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Улучшите процесс установки пакетов

Текущая реализация установки пакетов требует улучшений:

  1. Отсутствует обработка ошибок установки
  2. Не зафиксированы версии пакетов
  3. Флаг -l используется без пояснений
  4. Отсутствует проверка успешности установки каждого пакета
-opm install opm
-opm install oscript-config
-opm install -l
+# Функция для установки пакета с проверкой результата
+install_package() {
+    local package="$1"
+    local version="${2:-}"
+    
+    echo "Установка пакета ${package}${version:+ версии ${version}}..."
+    if ! opm install ${version:+--version ${version}} "$package"; then
+        echo "Ошибка: не удалось установить пакет $package" >&2
+        return 1
+    fi
+}
+
+# Установка пакетов с фиксированными версиями
+install_package "opm" "1.0.0" || exit 1
+install_package "oscript-config" "1.0.0" || exit 1
+
+# Локальная установка пакетов из текущей директории
+echo "Установка локальных пакетов..."
+if ! opm install -l; then
+    echo "Ошибка: не удалось установить локальные пакеты" >&2
+    exit 1
+fi

Также рекомендуется добавить комментарий, поясняющий назначение флага -l в команде opm install -l.

Committable suggestion skipped: line range outside the PR's diff.

Loading