Skip to content

Commit

Permalink
Initial commit of new project
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeicor committed Nov 27, 2023
0 parents commit ac280cb
Show file tree
Hide file tree
Showing 9 changed files with 890 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
day: "saturday"
time: "09:00"
- package-ecosystem: "github-actions"
directory: "/.github/workflows/"
schedule:
interval: "weekly"
day: "saturday"
time: "09:00"
37 changes: 37 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "Dependabot Pull Request Approve and Merge"

on: "pull_request_target"

permissions:
pull-requests: "write"
contents: "write"

jobs:
dependabot:
runs-on: "ubuntu-latest"
# Checking the actor will prevent your Action run failing on non-Dependabot
# PRs but also ensures that it only does work for Dependabot PRs.
if: "${{ github.actor == 'dependabot[bot]' }}"
steps:
# This first step will fail if there's no metadata and so the approval
# will not occur.
- name: "Dependabot metadata"
id: "dependabot-metadata"
uses: "dependabot/fetch-metadata@v1"
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
# Here the PR gets approved.
- uses: actions/checkout@v4
- name: "Approve a PR"
run: "gh pr review --approve $PR_URL"
env:
PR_URL: "${{ github.event.pull_request.html_url }}"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# Finally, this sets the PR to allow auto-merging for patch and minor
# updates if all checks pass
- name: "Enable auto-merge for Dependabot PRs"
#if: "${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' }}"
run: "gh pr merge --auto --squash $PR_URL"
env:
PR_URL: "${{ github.event.pull_request.html_url }}"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
46 changes: 46 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "Main"

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch: { }

jobs:
build:

runs-on: "ubuntu-latest"

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
contents: "read" # to read the repository contents
pull-requests: "read" # to read pull requests
pages: "write" # to deploy to Pages
id-token: "write" # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: "github-pages"
# url: "${{ steps.deployment.outputs.page_url }}"

steps:
- uses: "actions/checkout@v4"

- uses: "actions/setup-python@v4"
with:
python-version: "3.11"
cache: "poetry"

- run: "poetry install"

- uses: "Yeicor/[email protected]"
with:
scripts: "main.py"
# formats: "STL|STEP|AMF|SVG|TJS|DXF|VRML|VTP|3MF|GLTF"
# website: "."
# website-screenshot: "true"




6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/venv/
/build/
/.idea/
/*.iml
/*.stl
/.ocp_vscode
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"emeraldwalk.runonsave": {
"commands": [
{
"match": "\\.py$",
"isAsync": false,
"cmd": "poetry run python ${file}"
}
]
}
}
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Boot protector

You can download the latest builds from the [workflow runs](https://github.com/Yeicor/boot-protector/actions/workflows/main.yml).

You can preview the model in an interactive demo by clicking the following render of the latest design:

[![boot-protector.png](https://yeicor.github.io/boot-protector/models/main/boot-protector.png)](https://yeicor.github.io/boot-protector/)

![boot-protector.svg](https://yeicor.github.io/boot-protector/models/main/boot-protector.svg)
39 changes: 39 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from build123d import *
from contextlib import suppress
with suppress(ImportError): import ocp_vscode # Optional, for visualizing the model in VSCode instead of CQ-editor or exporting to STL


# ================== PARAMETERS ==================
# 3D printing basics
tol = 0.1 * MM # Tolerance (tighter than usual)
wall_min = 0.4 * MM # Minimum wall width
wall = 3 * wall_min # Recommended width for most walls of this print
eps = 1e-5 * MM # A small number

# ...


# ================== MODELLING ==================

with BuildPart() as obj:
Box(100*MM, 100*MM, 20*MM)

# ================== SHOWING/EXPORTING ==================

export = True
try:
if 'ocp_vscode' in locals():
import socket
tmp_socket = socket.socket()
tmp_socket.connect(('localhost', ocp_vscode.get_port()))
tmp_socket.close()
ocp_vscode.reset_show()
ocp_vscode.show_all()
export = False # If the connection fails, export to STL instead
elif 'show_object' in locals():
show_object(obj, 'boot-protector') # type: ignore
except Exception as ex:
print("Cannot show model, exporting to STL instead (%s)" % ex)

if export:
obj.export_stl('boot-protector.stl')
Loading

0 comments on commit ac280cb

Please sign in to comment.