Skip to content

Commit

Permalink
ci: use nimble-python
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBernstorff committed Oct 27, 2023
1 parent 3217d85 commit 9da7e6c
Show file tree
Hide file tree
Showing 10 changed files with 192 additions and 186 deletions.
5 changes: 3 additions & 2 deletions .cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
"_copy_without_render": [
"*.github"
],
"_template": "https://github.com/MartinBernstorff/swift-python-cookiecutter",
"_template": "https://github.com/MartinBernstorff/nimble-python-cookiecutter",
"author": "Martin Bernstorff",
"copyright_year": "2023",
"email": "martinbernstorfff@gmail.com",
"email": "martinbernstorff@gmail.com",
"friendly_name": "Personal Mnemonic Medium",
"github_repo": "personal-mnemonic-medium",
"github_user": "MartinBernstorff",
"license": "MIT",
"package_name": "personal_mnemonic_medium",
Expand Down
9 changes: 5 additions & 4 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
{
"template": "https://github.com/MartinBernstorff/swift-python-cookiecutter",
"commit": "525b1f682621953d7ef9deb6ad6cf7359ebd43c8",
"template": "https://github.com/MartinBernstorff/nimble-python-cookiecutter",
"commit": "d65d50c7215714a4e6df85be23c5cd9066db9cc0",
"checkout": null,
"context": {
"cookiecutter": {
"project_name": "personal-mnemonic-medium",
"package_name": "personal_mnemonic_medium",
"friendly_name": "Personal Mnemonic Medium",
"author": "Martin Bernstorff",
"email": "martinbernstorfff@gmail.com",
"email": "martinbernstorff@gmail.com",
"github_user": "MartinBernstorff",
"github_repo": "personal-mnemonic-medium",
"version": "0.0.0",
"copyright_year": "2023",
"license": "MIT",
"_copy_without_render": [
"*.github"
],
"_template": "https://github.com/MartinBernstorff/swift-python-cookiecutter"
"_template": "https://github.com/MartinBernstorff/nimble-python-cookiecutter"
}
},
"directory": null
Expand Down
68 changes: 35 additions & 33 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
{
"name": "Existing Dockerfile",
"build": {
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerfile": "../Dockerfile"
},
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"charliermarsh.ruff",
"ms-python.black-formatter",
"ms-azuretools.vscode-docker",
"ms-vscode.makefile-tools",
"github.vscode-github-actions"
]
}
},
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {}
},
"postStartCommand": "pip install -e ."
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "cat /etc/os-release",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
"name": "Existing Dockerfile",
"build": {
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerfile": "../Dockerfile",
"cacheFrom": "ghcr.io/martinbernstorff/personal-mnemonic-medium:latest"
},
// "features": {},
"customizations": {
"vscode": {
"extensions": [
"GitHub.copilot",
"charliermarsh.ruff",
"ms-python.python",
"ms-python.vscode-pylance",
"GitHub.vscode-pull-request-github",
"ms-vscode.makefile-tools",
"github.vscode-github-actions",
]
}
},
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {}
},
"postStartCommand": "make install"
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Uncomment the next line to run commands after the container is created.
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
}
30 changes: 0 additions & 30 deletions .github/workflows/dependabot_automerge.yml

This file was deleted.

25 changes: 14 additions & 11 deletions .github/workflows/validate.yml → .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# GitHub action to check if pre-commit has been run. Runs from .pre-commit-config.yaml, where the pre-commit actions are.

name: validate
# This workflow will install Python dependencies, run pytests and run notebooks
# then it will in python 3.9 (ubuntu-latest) create a badge with the coverage
# and add it to the PR. This badge will be updated if the PR is updated.

name: Tests
on:
pull_request:
branches: [main]
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
build-and-test:
permissions: write-all
concurrency:
group: "${{ github.workflow }} @ ${{ github.ref }}"
cancel-in-progress: true
Expand All @@ -22,14 +24,15 @@ jobs:
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
username: MartinBernstorff
password: ${{ secrets.GITHUB_TOKEN }}

- name: Pre-build dev container image
uses: devcontainers/[email protected]
with:
imageName: ghcr.io/martinbernstorff/personal-mnemonic-medium
cacheFrom: ghcr.io/martinbernstorff/personal-mnemonic-medium
push: always
imageName: ghcr.io/martinbernstorff/personal-mnemonic-medium-devcontainer
cacheFrom: ghcr.io/martinbernstorff/personal-mnemonic-medium-devcontainer:latest
push: filter
refFilterForPush: refs/heads/main
runCmd:
make validate
make validate
19 changes: 0 additions & 19 deletions .vscode/launch.json

This file was deleted.

17 changes: 12 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
{
"python.analysis.typeCheckingMode": "strict",
"python.testing.pytestArgs": [
"tests"
"personal_mnemonic_medium"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.analysis.typeCheckingMode": "strict",
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
"explorer.excludeGitIgnore": false,
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/BUILD": true
},
"python.formatting.provider": "none"
"python.analysis.diagnosticMode": "workspace"
}
55 changes: 35 additions & 20 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
lint:
@echo Running black
black .
SRC_PATH = personal_mnemonic_medium

@echo Running ruff
install-dev:
pip install -r dev-requirements.txt

install-deps:
pip install -r requirements.txt

install:
make install-deps
make install-dev
pip install -e .

test: ## Run tests
pytest $(SRC_PATH)

lint: ## Format code
ruff check . --fix
ruff format .

test:
@echo ––– Testing –––
pytest -n auto -rfE --failed-first --disable-warnings -q
type-check: ## Type-check code
pyright $(SRC_PATH)

type-check:
@echo ––– Running static type checks –––
pyright .
validate: ## Run all checks
make lint
make type-check
make test

install:
pip install --upgrade -e .[dev,tests]
sync-pr:
git push --set-upstream origin HEAD
git push

validate:
@echo ––– Ensuring dependencies are up to date. This will take a few moments ---
@make install > /dev/null
@make lint && make type-check && make test
create-pr:
gh pr create -w || true

pr:
gh pr create -w
merge-pr:
gh pr merge --auto --merge --delete-branch

pr: ## Run relevant tests before PR
make sync-pr
make create-pr
make validate
git push
gh pr merge --auto --merge
make merge-pr
Loading

0 comments on commit 9da7e6c

Please sign in to comment.