Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

chore: Updated README and Makefile #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"recommendations": [
"ms-python.isort",
"ms-python.mypy-type-checker",
"ms-python.vscode-pylance",
"ms-python.python",
"redhat.vscode-yaml",
"vivaxy.vscode-conventional-commits",
"ryanluker.vscode-coverage-gutters",
"ms-python.debugpy",
"charliermarsh.ruff"
]
}
24 changes: 24 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Remote Attach",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
}
],
"justMyCode": true
}
]
}
76 changes: 76 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"python.analysis.extraPaths": [
".",
"apps/artifactory-fetcher/src",
"apps/excel-tools/src",
"apps/filecheck/src",
"apps/papsr/src",
"apps/pdf-signature-evaluator/src",
"apps/pex-tool/src",
"apps/security-scanner/src",
"apps/sharepoint-evaluator/src",
"apps/sharepoint-fetcher/src",
"apps/sharepoint/src",
"apps/splunk-fetcher/src",
"packages/autopilot-utils/src",
"packages/autopilot-utils/tests/app_chained_multi_evaluator/src",
"packages/autopilot-utils/tests/app_multi_command/src",
"packages/autopilot-utils/tests/app_multi_evaluator/src",
"packages/autopilot-utils/tests/app_single_command/src",
"packages/autopilot-utils/tests/app_single_evaluator/src",
"packages/autopilot-utils/tests/app_subprocess_steps/src",
"packages/autopilot-utils/tests/app_super_simple_evaluator/src",
"packages/autopilot-utils/tests/demo_app/src"
],
"python.defaultInterpreterPath": "dist/export/python/virtualenvs/python-default/3.10.15/bin/python",
"python.testing.pytestArgs": [
"."
],
"python.testing.pytestEnabled": true,
"python.testing.pytestPath": "dist/export/python/virtualenvs/python-default/3.10.15/bin/pytest",
"python.testing.unittestEnabled": false,
"mypy-type-checker.interpreter": [
"dist/export/python/virtualenvs/python-default/3.10.15/bin/python"
],
"coverage-gutters.coverageBaseDir": "dist/coverage/**",
"coverage-gutters.coverageFileNames": [
"coverage.xml"
],
"editor.formatOnSave": true,
"cSpell.words": [
"capsys",
"commitlint",
"dateutil",
"distinfo",
"distinfos",
"distutils",
"dohq",
"itoa",
"LICENCE",
"lockfiles",
"loguru",
"loguru",
"maxsplit",
"mypy",
"ntlm",
"oneq",
"papsr",
"pydantic",
"pytz",
"rdparty",
"rdparty",
"reqs",
"SCIE",
"splunklib",
"subtargets",
"testcov",
"testint",
"urllib",
"virtualenv",
"Yaku"
],
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true
}
}
103 changes: 103 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
SHELL=bash

.PHONY: help
help:
@echo "Targets:"
@echo ""
@echo " install-fast-hooks Set up Git hooks (linting, formatting)"
@echo " install-slow-hooks Set up Git hooks (linting, formatting, tests)"
@echo " remove-hooks Uninstall Git hooks"
@echo ""
@echo " vscode-integration Set up VS Code so that it works nicely with Pants"
@echo " update-lockfiles Update Python lockfiles for Pants"
@echo ""
@echo " format Run formatters"
@echo " lint Run linters (e.g. in CI/CD pipeline)"
@echo " test Run tests (e.g. in CI/CD pipeline)"
@echo " testcov Run tests with coverage analysis"
@echo " testint Run integration tests only (for external systems)"
@echo " check Run checks (e.g. in CI/CD pipeline)"
@echo " package Package everything"
@echo ""
@echo " coverage-check Compare list of Python files with coverage analysis files"
@echo ""

FOLDER ?= '.'
.PHONY: install-slow-hooks install-fast-hooks remove-hooks
install-fast-hooks: remove-hooks install-std-hooks
ln -s ../../cicd/pre-commit-hook-fast .git/hooks/pre-commit
install-slow-hooks: remove-hooks install-std-hooks
ln -s ../../cicd/pre-commit-hook-slow .git/hooks/pre-commit
install-std-hooks: remove-hooks
ln -s ../../cicd/commit-msg-hook .git/hooks/commit-msg
remove-hooks:
rm -f .git/hooks/commit-msg
rm -f .git/hooks/pre-commit

.PHONY: vscode-integration
vscode-integration: vscode-python-paths vscode-virtualenvs

.PHONY: vscode-virtualenvs
vscode-virtualenvs:
pants export \
--py-resolve-format=symlinked_immutable_virtualenv \
--resolve=python-default
export LATEST_PYTHON_VERSION=$$(ls -1 dist/export/python/virtualenvs/python-default | sort | tail -n 1) ; \
export PYTHON_PREFIX=dist/export/python/virtualenvs/python-default/$${LATEST_PYTHON_VERSION}/ ; \
if yq -V > /dev/null; then \
yq -oj -i '."python.defaultInterpreterPath" = "'$${PYTHON_PREFIX}'bin/python"' .vscode/settings.json ; \
yq -oj -i '."python.testing.pytestPath" = "'$${PYTHON_PREFIX}'bin/pytest"' .vscode/settings.json ; \
yq -oj -i '."mypy-type-checker.interpreter" = ["'$${PYTHON_PREFIX}'bin/python"]' .vscode/settings.json ; \
echo "Successfully updated .vscode/settings.json" ; \
else \
echo "No 'yq' installed. Please adapt python.defaultInterpreterPath and python.testing.pytestPath" ; \
echo "manually in .vscode/settings.json." ; \
fi

.PHONY: vscode-python-paths
vscode-python-paths:
python3 cicd/check-vscode-python-paths.py

.PHONY: _generate_lockfiles
_generate_lockfiles:
pants generate-lockfiles

.PHONY: _convert_lockfile
_convert_lockfile:
grep -A1000000 -e '^[^/]' 3rdparty/python-lockfile.txt| jq -r '.locked_resolves[].locked_requirements[] | [ .project_name, .version ] | join("==") ' | LC_ALL=C sort -d -s > dependabot-requirements.txt

.PHONY: update-lockfiles
update-lockfiles: _generate_lockfiles _convert_lockfile

.PHONY: test
test:
pants --tag="-integration" test ${FOLDER}/::

.PHONY: testcov
testcov:
pants --tag="-integration" test --use-coverage --coverage-py-filter=${FOLDER} ${FOLDER}/::

.PHONY: testint
testint:
pants --tag="integration" test ${FOLDER}/::

.PHONY: lint
lint:
pants lint ::

.PHONY: check
check:
pants check ::

.PHONY: fmt format
fmt: format
format:
pants fmt ::

.PHONY: package
package:
pants package ${FOLDER}/::

.PHONY: coverage-check
coverage-check: testcov
cicd/coverage-check.sh
Loading