diff --git a/.gitignore b/.gitignore index 86e8b11..912fb9b 100644 --- a/.gitignore +++ b/.gitignore @@ -19,5 +19,6 @@ build/ code-coverage.xml !.oh-my-posh/**/* +!.vscode/**/* !tests/files/**/* !template.env diff --git a/.idx/dev.nix b/.idx/dev.nix new file mode 100644 index 0000000..2bc9148 --- /dev/null +++ b/.idx/dev.nix @@ -0,0 +1,42 @@ +# Copyright (C) Pipin Fitriadi - All Rights Reserved + +# Unauthorized copying of this file, via any medium is strictly prohibited +# Proprietary and confidential +# Written by Pipin Fitriadi , 22 May 2025 + +# To learn more about how to use Nix to configure your environment +# see: https://firebase.google.com/docs/studio/customize-workspace + +{ pkgs, ... }: { + channel = "stable-24.05"; + # Use https://search.nixos.org/packages to find packages + packages = with pkgs; [ + gitflow + git-lfs + oh-my-posh + python313 + ]; + idx = { + # Search for the extensions you want on https://open-vsx.org/ and use "publisher.id" + extensions = [ + "adpyke.codesnap" + "akamud.vscode-theme-onedark" + "augustocdias.tasks-shell-input" + "charliermarsh.ruff" + "DavidAnson.vscode-markdownlint" + "detachhead.basedpyright" + "eamodio.gitlens" + "grapecity.gc-excelviewer" + "mechatroner.rainbow-csv" + "mermaidchart.vscode-mermaid-chart" + "mhutchie.git-graph" + "ms-python.python" + "ms-toolsai.jupyter" + "waderyan.gitblame" + "yzhang.markdown-all-in-one" + ]; + workspace.onStart.default.openFiles = [ + "README.md" + ]; + }; +} diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..5090782 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,12 @@ +/** + * Copyright (C) Pipin Fitriadi - All Rights Reserved + * + * Unauthorized copying of this file, via any medium is strictly prohibited + * Proprietary and confidential + * Written by Pipin Fitriadi , 22 May 2025 + */ + +{ + "version": "0.2.0", + "configurations": [] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..dd38d3f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,35 @@ +/** + * Copyright (C) Pipin Fitriadi - All Rights Reserved + * + * Unauthorized copying of this file, via any medium is strictly prohibited + * Proprietary and confidential + * Written by Pipin Fitriadi , 22 May 2025 + */ + +{ + "basedpyright.analysis.typeCheckingMode": "off", + "csv-preview.lineNumbers": "ordinal", + "csv-preview.resizeColumns": "all", + "editor.fontFamily": "'JetBrains Mono'", + "editor.fontLigatures": true, + "editor.minimap.enabled": false, + "IDX.aI.enableInlineCompletion": true, + "IDX.aI.enableCodebaseIndexing": true, + "notebook.output.scrolling": true, + "notebook.output.fontFamily": "'Fira Code', 'Consolas', 'Courier New', monospace", + "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python", + "python.languageServer": "None", + "python.terminal.activateEnvironment": false, + "rainbow_csv.rbql_with_headers_by_default": true, + "terminal.integrated.defaultProfile.linux": "bash", + "terminal.integrated.profiles.linux": { + "bash": { + "path": "bash", + "icon": "terminal-bash", + "args": ["--init-file", "${workspaceFolder}/.bashrc"] + } + }, + "window.autoDetectColorScheme": false, + "workbench.colorTheme": "Atom One Dark", + "workbench.sideBar.location": "right" +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..e414abe --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,132 @@ +/** + * Copyright (C) Pipin Fitriadi - All Rights Reserved + * + * Unauthorized copying of this file, via any medium is strictly prohibited + * Proprietary and confidential + * Written by Pipin Fitriadi , 22 May 2025 + */ + +{ + "version": "2.0.0", + "tasks": [ + { + "problemMatcher": [], + "label": "CI/CD: Code Quality", + "type": "shell", + "command": "${PYTHON_INTERPRETER_PATH}", + "args": ["-m", "ruff", "check"] + }, + { + "problemMatcher": [], + "label": "CI/CD: Code Quality - Fixing", + "type": "shell", + "command": "${PYTHON_INTERPRETER_PATH} -m ruff check --fix && ${PYTHON_INTERPRETER_PATH} -m ruff format" + }, + { + "problemMatcher": [], + "label": "CI/CD: Test", + "type": "shell", + "command": "${PYTHON_INTERPRETER_PATH}", + "args": ["-m", "coverage", "run", "-m", "pytest", "-rfEP", "-q", "--junit-xml=code-coverage.xml"] + }, + { + "problemMatcher": [], + "label": "CI/CD: Code Coverage", + "dependsOn": "CI/CD: Test", + "type": "shell", + "command": "${PYTHON_INTERPRETER_PATH}", + "args": ["-m", "coverage", "report", "-m"] + }, + { + "problemMatcher": [], + "label": "CI/CD: Code Coverage - Percentage passed", + "dependsOn": "CI/CD: Code Coverage", + "type": "shell", + "command": "if [ $(printf '%.0f' $(${PYTHON_INTERPRETER_PATH} -m coverage report | awk '$1 == \"TOTAL\" {print $NF+0}')) -ge ${input:codecoverage-percentage-passed} ]; then exit; else exit 1; fi", + }, + { + "problemMatcher": [], + "label": "CI/CD", + "dependsOrder": "parallel", + "dependsOn": [ + "CI/CD: Code Quality", + "CI/CD: Code Coverage - Percentage passed", + ] + }, + { + "problemMatcher": [], + "label": "Git: Fetch All", + "type": "shell", + "command": "if [[ $(git remote | grep upstream) != 'upstream' ]]; then git remote add upstream $UPSTREAM && git remote set-url --push upstream DISABLE && git remote -v | grep upstream; fi && git fetch --all --prune" + }, + { + "problemMatcher": [], + "label": "Preparation", + "dependsOrder": "sequence", + "dependsOn": [ + "Git: Fetch All", + "Preparation: Git Flow", + "Python: Create VEnv" + ], + "type": "shell", + "command": "echo Environment preparation is complete" + }, + { + "problemMatcher": [], + "label": "Preparation: Git Flow", + "type": "shell", + "command": "git show-branch develop >/dev/null 2>&1 || (git checkout main && git checkout -b develop); git flow config >/dev/null 2>&1 || git flow init -d" + }, + { + "problemMatcher": [], + "label": "Python: Create VEnv", + "type": "shell", + "command": "if [ ! -d .venv/ ]; then ${input:python-app} -m venv .venv/; fi && .venv/bin/python -V" + }, + { + "problemMatcher": [], + "label": "Python: Environment dependencies", + "type": "shell", + "command": "${PYTHON_INTERPRETER_PATH}", + "args": [ + "-m", "pip", "install", + "--require-virtualenv", + "--editable", + "${workspaceFolder}", + "--group", + "dev" + ] + }, + { + "problemMatcher": [], + "label": "Python: Preparation", + "dependsOrder": "sequence", + "dependsOn": [ + "Python: Create VEnv", + "Python: Environment dependencies" + ], + "type": "shell" + }, + ], + "inputs": [ + { + "id": "codecoverage-percentage-passed", + "type": "promptString", + "description": "Percentage as an integer for passing code coverage", + "default": "100" + }, + { + "id": "python-app", + "type": "promptString", + "description": "Python app path for creating virtual environment", + "default": "python3" + } + ], + "options": { + "env": { + "PIP_DISABLE_PIP_VERSION_CHECK": "1", + "PYTHON_INTERPRETER_PATH": "${workspaceFolder}/.venv/bin/python", + "UPSTREAM": "https://github.com/pipinfitriadi/workspace.git", + } + } +} diff --git a/README.md b/README.md index be8fd91..d68bf63 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Written by Pipin Fitriadi , 22 May 2025 [![PyPI - Python Version](https://img.shields.io/badge/python-3.13%2B-blue?logo=Python&logoColor=white)](https://www.python.org/downloads/release/python-3131/) - [Setup](#setup) +- [CI/CD](#cicd) This repository serves as a centralized Python's workspace, providing structure and resources to support development activities. @@ -27,3 +28,14 @@ Follow these steps the first time you use VS Code after cloning this git reposit 1. Change `name` value in [pyproject.toml](pyproject.toml) to your project name 2. Create a _`.env`_ file based on [_`template.env`_](template.env) and set your environment values +3. Use the command f1, select `Tasks: Run Task`, and then choose `Preparation` +4. Use the command f1, select `Python: Select Interpreter`, + and then choose _`./.venv/bin/python`_ +5. Use the command f1, select `Tasks: Run Task`, + and then choose `Python: Preparation` + +## CI/CD + +If you encounter a Code Quality error during the CI/CD process, +use the command f1, select `Tasks: Run Task`, +choose `CI/CD: Code Quality - Fixing`, and then run `git commit` and `git push`.