diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..a458c95 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,14 @@ +FROM mcr.microsoft.com/devcontainers/python:0-3.10 + +RUN apt-get update && apt install git-lfs + +RUN python -m pip install --upgrade pip \ + && python -m pip install 'flit>=3.8.0' + +ENV FLIT_ROOT_INSTALL=1 + +COPY pyproject.toml . +RUN touch README.md \ + && mkdir -p src/deps_rocker \ + && python -m flit install --only-deps --deps develop \ + && rm -r pyproject.toml README.md src diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..1a6202a --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,27 @@ +{ + "name": "deps_rocker", + "build": { + "dockerfile": "Dockerfile", + "context": ".." + }, + // "onCreateCommand": "pre-commit install --hook-type commit-msg", + "postCreateCommand": "flit install --symlink;", + "customizations": { + "vscode": { + "extensions": [ + "ms-python.python", + "ms-python.vscode-pylance", + "ms-python.pylint", + "ms-python.black-formatter", + "njpwerner.autodocstring", + "charliermarsh.ruff", + "mhutchie.git-graph", + "eamodio.gitlens", + "tamasfe.even-better-toml", + "Codium.codium", + "ms-azuretools.vscode-docker", + "ryanluker.vscode-coverage-gutters" + ] + } + }, +} \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5c0c219 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,28 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "pip" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "monthly" + groups: + dev-dependencies: + #try to group all development dependencies updates into a single pr + patterns: + - "black" + - "check-manifest" + - "pre-commit" + - "pylint" + - "pytest" + - "pytest-cov" + - "hypothesis" + - "ruff" + - "coverage" + lib-dependencies: + #try to group all third party library updates into a single pr + patterns: + - "*" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b0d794d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,50 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + + black: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: psf/black@stable + ruff: + runs-on: ubuntu-latest + needs: [black] + steps: + - uses: actions/checkout@v3 + - uses: chartboost/ruff-action@v1 + build: + runs-on: ubuntu-latest + needs: [ruff] + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flit + flit install --extras test + - run: | + pylint $(git ls-files '*.py') + - name: Test with pytest + run: | + coverage run -m pytest + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..81e246d --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,19 @@ +name: Auto-publish + +on: [push, workflow_dispatch] + +jobs: + # Auto-publish when version is increased + publish-job: + # Only publish on `main` branch + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + permissions: # Don't forget permissions + contents: write + + steps: + - uses: etils-actions/pypi-auto-publish@v1 + with: + pypi-token: ${{ secrets.PYPI_API_TOKEN }} + gh-token: ${{ secrets.GITHUB_TOKEN }} + parse-changelog: true \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..75ab85e --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,16 @@ +{ + "recommendations": [ + "ms-python.python", + "ms-python.vscode-pylance", + "ms-python.pylint", + "ms-python.black-formatter", + "njpwerner.autodocstring", + "charliermarsh.ruff", + "mhutchie.git-graph", + "eamodio.gitlens", + "tamasfe.even-better-toml", + "Codium.codium", + "ms-azuretools.vscode-docker", + "ryanluker.vscode-coverage-gutters" + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..e777c16 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,14 @@ +{ + "python.testing.pytestArgs": [], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true, + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter", + "editor.formatOnSave": true, + }, + "files.exclude": { + "**/__pycache__/**": true, + "/home/vscode/.local/lib/python3.10/site-packages/deps_rocker/**": true + }, + "python.analysis.autoImportCompletions": false //vscode gets it wrong more than right and mostly gets in the way +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..2c2d167 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,200 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "set from active file; sa", + "type": "shell", + "command": "echo ${file} > ${workspaceFolder}/.vscode/active_file.cfg; echo Setting the current file: ${file} as the active file.", + "problemMatcher": [], + "group": { + "kind": "test", + "isDefault": "True" + } + }, + { + "label": "run ", + "type": "shell", + "command": "RUNFILE=$(cat ${workspaceFolder}/.vscode/active_file.cfg); echo Running file: $RUNFILE; python3 $RUNFILE", + "problemMatcher": [], + "group": { + "kind": "build", + "isDefault": "True" + } + }, + { + "label": "autoformat", + "detail": "Use ruff and black to automatically fix and format the code", + "type": "shell", + "command": "ruff check . --fix && black ." + }, + { + "label": "autoformat, commit and push", + "detail": "Use ruff and black to automatically fix and format the code and commit changes", + "type": "shell", + "dependsOn": [ + "autoformat" + ], + "command": "git commit -a -m 'fix: autoformatted and ruff --fix all code' || true && git push" + }, + { + "label": "pylint", + "detail": "Run pylint on files tracked by git", + "type": "shell", + "command": "pylint $(git ls-files '*.py') " + }, + { + "label": "code coverage", + "detail": "Run code coverage and print a coverage report, also update coverage.xml for in the in-editor coverage gutter", + "type": "shell", + "command": "coverage run -m pytest; coverage xml -o coverage.xml" + }, + { + "label": "code coverage report", + "detail": "Display the code coverage report. This assumes you have already have a coverage report generated. If not run the code ocverage task", + "type": "shell", + "dependsOn": [ + "code coverage" + ], + "command": "coverage report -m" + }, + { + "label": "pytest duration", + "detail": "Run pytest and track the duration of each test", + "type": "shell", + "command": "pytest --durations=0" + }, + { + "label": "check CI", + "detail": "Runs the basic formatting and linting checks performed by CI", + "type": "shell", + "dependsOn": [ + "autoformat", + "pylint", + "code coverage report" + ], + "dependsOrder": "sequence", + }, + { + "label": "check CI, commit and push", + "detail": "Pull,s from main, runs the basic formatting and linting checks performed by CI and pushes changes", + "type": "shell", + "dependsOn": [ + "git pull origin main", + "check CI", + "autoformat, commit and push", + ], + "dependsOrder": "sequence", + }, + { + "label": "git pull origin main", + "detail": "merge changes from master into the current branch and push", + "type": "shell", + "command": "git pull --commit --no-edit ; git pull origin main --commit --no-edit && git push" + }, + { + "label": "git push", + "detail": "merge changes from master into the current branch and push", + "type": "shell", + "command": "git push" + }, + { + "label": "git pull origin main and push", + "detail": "merge changes from master into the current branch and push", + "type": "shell", + "dependsOn": [ + "git pull origin main", + "git push" + ], + "dependsOrder": "sequence", + }, + { + "label": "update from template repo", + "detail": "Pull any changes from the template repo into this repo by adding it as a remote. The remote is removed at the end of the command. You may need to resolve merge conflicts", + "type": "shell", + "command": "scripts/update_from_template.sh" + }, + { + "label": "update from template repo keep ours", + "detail": "Pull any changes from the template repo into this repo by adding it as a remote. The remote is removed at the end of the command. You may need to resolve merge conflicts", + "type": "shell", + "command": "scripts/update_from_template_ours.sh" + }, + { + "label": "rename template project name and commit", + "detail": "Replaces all instances of the template project name with a new name. ", + "type": "shell", + "command": "scripts/rename_project.sh ${input:new_project_name}; git commit -a -m 'rename project'" + }, + { + "label": "first time setup of project", + "detail": "Pulls updates from the template repo and replaces all instances of the template project name with a new name.", + "type": "shell", + "dependsOn": [ + "update from template repo", + "rename template project name and commit", + "update from template repo keep ours" + ], + "dependsOrder": "sequence", + }, + { + "label": "flit install", + "type": "shell", + "command": "flit install --symlink" + }, + { + "label": "flit publish", + "type": "shell", + "command": "flit publish" + }, + { + "label": "setup: host", + "detail": "Sets up docker, nvidia docker git-lfs and rocker which are used to clone and setup docker containers", + "type": "shell", + "command": "./scripts/setup_host.sh", + "presentation": { + "reveal": "always", + "panel": "new" + } + }, + { + "label": "launch container", + "detail": "Uses rocker to launch a container and spawns a new vscode window attached to the container", + "type": "shell", + "command": "scripts/launch_vscode.sh" + }, + { + "label": "Install All Recommended Extensions", + "type": "shell", + "linux": { + "command": "cat .vscode/extensions.json | jq .recommendations[] | xargs -n 1 code . --install-extension" + }, + "runOptions": { + "runOn": "folderOpen" + }, + "presentation": { + "reveal": "always" + }, + }, + { + "label": "set git config recurse submodules", + "type": "shell", + "linux": { + "command": [" git config submodule.recurse true"], + }, + "runOptions": { + "runOn": "folderOpen" + }, + "presentation": { + "reveal": "silent" + }, + }, + ], + "inputs": [ + { + "type": "promptString", + "id": "new_project_name", + "description": "The new name of the project", + "default": "python_template" + } + ] +} \ No newline at end of file diff --git a/test/test_basic.py b/test/test_basic.py index 9835384..44dca32 100644 --- a/test/test_basic.py +++ b/test/test_basic.py @@ -1,9 +1,9 @@ from unittest import TestCase -from deps_rocker.basic_class import BasicClass +from deps_rocker.dependencies import Dependencies class TestBasicClass(TestCase): def test_init(self): - instance = BasicClass() + instance = Dependencies() - self.assertEqual(instance.int_var, 0) + # self.assertEqual(instance.int_var, 0)