-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from blooop/feature/add_template
Feature/add template
- Loading branch information
Showing
44 changed files
with
1,130 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
] | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: | ||
- "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/home/ags/deps_rocker/test/test_basic.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "set <cfg> 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 <cfg>", | ||
"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" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Changelog | ||
|
||
## python_tempate | ||
|
||
## [0.0.0] | ||
|
||
|
Oops, something went wrong.