Skip to content

Commit

Permalink
delete 2 files, create 10 files and update 23 files delete 2 files an…
Browse files Browse the repository at this point in the history
…d update 11 files
  • Loading branch information
MartinBernstorff committed Feb 25, 2024
1 parent e143395 commit 941af47
Show file tree
Hide file tree
Showing 37 changed files with 971 additions and 432 deletions.
15 changes: 0 additions & 15 deletions .cookiecutter.json

This file was deleted.

11 changes: 11 additions & 0 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 981c40d
_src_path: https://github.com/MartinBernstorff/nimble-python-template
email: [email protected]
full_name: Martin Bernstorff
github_username: MartinBernstorff
package_name: memorymarker
project_name: memorymarker
project_slug: memorymarker
python_version: '3.12'
release_to_pypi: true
23 changes: 0 additions & 23 deletions .cruft.json

This file was deleted.

35 changes: 7 additions & 28 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,22 @@
// 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",
"cacheFrom": "ghcr.io/martinbernstorff/memorymarker-devcontainer:latest"
"dockerfile": "../Dockerfile"
},
"postCreateCommand": ".devcontainer/post_create.sh",
"customizations": {
"vscode": {
"extensions": [
"GitHub.copilot",
"charliermarsh.ruff",
"ms-python.python",
"ms-python.vscode-pylance",
"GitHub.copilot",
"GitHub.vscode-pull-request-github",
"github.vscode-github-actions",
"SeeLog.python-init-generator",
"tamasfe.even-better-toml",
"MichaelCurrin.auto-commit-msg",
"tamasfe.even-better-toml"
"SeeLog.python-init-generator",
"charliermarsh.ruff",
]
}
},
"mounts": [
"source=${localEnv:HOME}/.config/gh/hosts.yml,target=/root/.config/gh/hosts.yml,type=bind,consistency=cache" // GitHub CLI authentication login
],
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {}
},
"postStartCommand": "gt user pager --disable"
// 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"
}
}
33 changes: 33 additions & 0 deletions .devcontainer/post_create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
set -e

# Zsh as default terminal
chsh -s $(which zsh)

# Github CLI
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& apt update \
&& apt install gh -y

# Node
export NVM_DIR="$HOME/.nvm"
mkdir -p $NVM_DIR
export NODE_VERSION="18.2.0"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default

export NODE_PATH=$NVM_DIR/v$NODE_VERSION/lib/node_modules
export PATH=$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
echo 'export PATH="$PATH:$HOME/.nvm/versions/node/v18.2.0/bin:PATH"' >> ~/.zshrc

# Graphite
npm install -g @withgraphite/graphite-cli@stable

# Lefthook
curl -1sLf 'https://dl.cloudsmith.io/public/evilmartians/lefthook/setup.deb.sh' | bash
apt install lefthook
lefthook install
5 changes: 2 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Configuration: https://dependabot.com/docs/config-file/
# Docs: https://docs.github.com/en/github/administering-a-repository/keeping-your-dependencies-updated-automatically
# Docs: https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
Expand All @@ -13,4 +12,4 @@ updates:
open-pull-requests-limit: 20
commit-message:
prefix: "deps:"
include: "scope"
include: "scope"
27 changes: 2 additions & 25 deletions .github/recommended_repo_setup.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
## Recommened setup for the repository
### Github personal access token
For pre-commit actions to be able to commit changes to a PR, or for the Cruft update to be able to create a PR with updates from the upstream repo, you need a personal access token (PAT) with the following settings:

**Expiration**: No expiration
**scopes:**
* `repo`
* `workflow`

#### Creating the PAT
You can create a personal access token following [this guide](https://docs.github.com/en/[email protected]/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token).

#### Adding as a secret in the repo
By default, the actions expect the repository secret to be called `PAT`. Add the PAT as a secret by following [this guide](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository).

### Github Repository Settings
These are all GitHub settings we recommend enabling, e.g. go to the repository's `Settings > General > Allow auto-merge`.

* General
* Pull Requests
* Disallow squash commits
* Disallow rebase commits
* Always suggest updating pull request branches
* Allow auto-merge
* Automatically delete head branches
Expand All @@ -29,12 +13,5 @@
* Require a pull request before merging
* Require status checks to pass before merging
* Require branches to be up to date before merging
* Status checks that are required:
* static_type_checks (type hinting)
* pre-commit (formatting)
* pytest (tests)
* check_for_rej (check for residual cruft updates)
* Require conversation resolution before merging

### Publishing to PyPI
If do not wish to pypi, you can just delete the `release.yml` file. If you do wish to publish, you need to setup trusted publishing [here](https://blog.pypi.org/posts/2023-04-20-introducing-trusted-publishers/).
* Status checks that are required
* Require conversation resolution before merging
27 changes: 27 additions & 0 deletions .github/workflows/dependabot_automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: automerge-bot-prs

on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
dependabot-automerge:
runs-on: ubuntu-latest
# if actor is dependabot or pre-commit-ci[bot] then run
if: ${{ github.actor == 'dependabot[bot]' }}

steps:
# Checkout action is required for token to persist
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --merge "$PR_URL" # Use Github CLI to merge automatically the PR
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Auto approve dependabot PRs
if: ${{ github.actor == 'dependabot[bot]' }}
uses: hmarr/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
18 changes: 4 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
# This workflow will
# - Find the latest version tag based on the commit history
# - Create a git tag for the new version
# - Update the version number in pyproject.toml based on the commit history
# - Upload the package to PyPI
# - Create a release on GitHub

name: Release
on:
workflow_run:
workflows: ["build-and-test"]
workflows: ["test"]
types:
- completed
# Manual trigger
Expand All @@ -21,8 +14,8 @@ jobs:
concurrency: release
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing using PyPI
# a guide on how to set it up is available here: https://blog.pypi.org/posts/2023-04-20-introducing-trusted-publishers/

# A guide on how to set it up is available here: https://blog.pypi.org/posts/2023-04-20-introducing-trusted-publishers/
# You can add a new publisher here: https://pypi.org/manage/account/publishing/

if: ${{ github.ref == 'refs/heads/main' && github.event.workflow_run.conclusion == 'success'}}
steps:
Expand All @@ -33,13 +26,10 @@ jobs:

- name: Python Semantic Release
id: release
uses: python-semantic-release/python-semantic-release@v8.7.2
uses: python-semantic-release/python-semantic-release@v9.1.0
with:
github_token: ${{ secrets.RELEASE }}

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: steps.release.outputs.released == 'true'
# This action supports PyPI's trusted publishing implementation, which allows authentication to PyPI without a manually
# configured API token or username/password combination. To perform trusted publishing with this action, your project's
# publisher must already be configured on PyPI.
17 changes: 17 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: test
on:
push:
branches: [main]
pull_request:

jobs:
test:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout (GitHub)
uses: actions/checkout@v3

- name: Build CI container
run: |
make docker_ci
Loading

0 comments on commit 941af47

Please sign in to comment.