Skip to content

Commit 0f16ee5

Browse files
Update reqs
1 parent 68256fc commit 0f16ee5

File tree

9 files changed

+1868
-1373
lines changed

9 files changed

+1868
-1373
lines changed

.github/workflows/auto_merge.yml

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,58 @@
11
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#approve-a-pull-request
2+
# https://nicolasiensen.github.io/2022-07-23-automating-dependency-updates-with-dependabot-github-auto-merge-and-github-actions/
23

34
name: auto_merge
4-
on: [pull_request, workflow_dispatch] # pull_request, push, workflow_dispatch
5+
6+
on: # pull_request, pull_request_target, push, workflow_dispatch
7+
pull_request_target:
8+
workflow_dispatch:
59

610
permissions:
711
pull-requests: write
12+
contents: write
813

914
jobs:
10-
dependabot:
15+
review-dependabot-pr:
1116
runs-on: ubuntu-latest
12-
if: ${{ github.actor == 'dependabot[bot]' }}
17+
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
1318
steps:
19+
- name: Check rate limit
20+
id: rate-limit
21+
shell: bash
22+
run: |
23+
RATE_LIMIT=$(gh api /rate_limit | jq -r '.resources.core.remaining')
24+
echo "::set-output name=remaining::$RATE_LIMIT"
25+
if [[ "$RATE_LIMIT" -lt 10 ]]; then
26+
RESET_TIME=$(gh api /rate_limit | jq -r '.resources.core.reset')
27+
echo "::set-output name=reset_time::$RESET_TIME"
28+
echo "Rate limit is low ($RATE_LIMIT). Waiting until $RESET_TIME"
29+
sleep $((RESET_TIME - $(date +%s)))
30+
fi
1431
- name: Dependabot metadata
15-
id: metadata
16-
uses: dependabot/fetch-metadata@v1.1.1
17-
with:
18-
github-token: "${{ secrets.GITHUB_TOKEN }}"
19-
- name: Approve a PR
20-
run: gh pr review --approve "$PR_URL"
32+
id: dependabot-metadata
33+
uses: dependabot/fetch-metadata@v1.3.1
34+
- name: Enable auto-merge for Dependabot PRs
35+
run: gh pr merge --auto --merge "$PR_URL"
36+
env:
37+
PR_URL: ${{github.event.pull_request.html_url}}
38+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
39+
- name: Approve patch and minor updates
40+
if: ${{steps.dependabot-metadata.outputs.update-type == 'version-update:semver-patch' || steps.dependabot-metadata.outputs.update-type == 'version-update:semver-minor'}}
41+
run: gh pr review $PR_URL --approve -b "I'm **approving** this pull request because **it includes a patch or minor update**"
2142
env:
2243
PR_URL: ${{github.event.pull_request.html_url}}
2344
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
24-
- name: Merge a PR
25-
run: gh pr merge "$PR_URL" --auto --squash
45+
- name: Approve major updates of development dependencies
46+
if: ${{steps.dependabot-metadata.outputs.update-type == 'version-update:semver-major' && steps.dependabot-metadata.outputs.dependency-type == 'direct:development'}}
47+
run: gh pr review $PR_URL --approve -b "I'm **approving** this pull request because **it includes a major update of a dependency used only in development**"
2648
env:
2749
PR_URL: ${{github.event.pull_request.html_url}}
50+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
51+
- name: Comment on major updates of non-development dependencies
52+
if: ${{steps.dependabot-metadata.outputs.update-type == 'version-update:semver-major' && steps.dependabot-metadata.outputs.dependency-type == 'direct:production'}}
53+
run: |
54+
gh pr comment $PR_URL --body "I'm **not approving** this PR because **it includes a major update of a dependency used in production**"
55+
gh pr edit $PR_URL --add-label "requires-manual-qa"
56+
env:
57+
PR_URL: ${{github.event.pull_request.html_url}}
58+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.pre-commit-config.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
fail_fast: true
2-
verbose: true
32

43
repos:
54
# checks for secrets via rules (gitleaks.toml)
65
- repo: https://github.com/zricethezav/gitleaks
7-
rev: v8.9.0
6+
rev: v8.15.3
87
hooks:
98
- id: gitleaks
109
- repo: https://github.com/ambv/black
11-
rev: 22.6.0
10+
rev: 23.1.0
1211
hooks:
1312
- id: black
14-
- repo: https://gitlab.com/pycqa/flake8
15-
rev: 3.9.2
13+
- repo: https://github.com/PyCQA/flake8
14+
rev: 6.0.0
1615
hooks:
1716
- id: flake8
18-
# - repo: https://github.com/timothycrosley/isort
19-
# rev: 5.10.1
20-
# hooks:
21-
# - id: isort
2217
- repo: https://github.com/pre-commit/pre-commit-hooks
23-
rev: v4.3.0
18+
rev: v4.4.0
2419
hooks:
2520
- id: check-yaml
2621
- id: check-added-large-files
2722
args: ['--maxkb=1024']
2823
- id: check-docstring-first
24+
exclude: |
25+
(?x)^(
26+
hello.py
27+
)$
2928
- id: check-executables-have-shebangs
3029
- id: check-merge-conflict
3130
- id: check-shebang-scripts-are-executable
@@ -41,9 +40,10 @@ repos:
4140
- id: mixed-line-ending
4241
- id: name-tests-test
4342
- id: pretty-format-json
44-
# https://pre-commit.com/#regular-expressions
4543
exclude: |
46-
^settings.json$
44+
(?x)^(
45+
.vscode/launch.json|
46+
.vscode/settings.json
47+
)$
4748
args: ['--autofix', '--indent=2', '--no-sort-keys']
4849
- id: requirements-txt-fixer
49-
# - id: trailing-whitespace

.tool-versions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
python 3.10.7
2-
poetry 1.2.0
1+
python 3.10.9
2+
poetry 1.3.2

.vscode/launch.json

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
6+
// pytest: https://stackoverflow.com/questions/70259564/how-to-debug-the-current-python-test-file-with-pytest-in-vs-code
7+
8+
"version": "0.2.0",
9+
"configurations": [
10+
{
11+
"name": "Python: Current File",
12+
"type": "python",
13+
"request": "launch",
14+
"program": "${file}",
15+
"console": "integratedTerminal",
16+
"cwd": "${fileDirname}",
17+
// "args": ["-i", "response.xml", "-o", "response.csv"],
18+
// "args": ["-d", "/Volumes/Data"],
19+
// "args": ["-f", "menubar.dmg"],
20+
// "args": ["-h"],
21+
// "env": {
22+
// "CREDS": "",
23+
// }
24+
},
25+
{
26+
"name": "Python: Django",
27+
"type": "python",
28+
"request": "launch",
29+
"program": "${workspaceFolder}/app/project/wiki/manage.py",
30+
"console": "integratedTerminal",
31+
"args": ["runserver"],
32+
"django": true,
33+
"justMyCode": true
34+
},
35+
{
36+
"name": "Python: Debug Tests",
37+
"type": "python",
38+
"request": "launch",
39+
"module": "pytest",
40+
"args": [
41+
"${file}"
42+
],
43+
"console": "integratedTerminal"
44+
},
45+
{
46+
"name": "Node: Current File",
47+
"type": "node",
48+
"request": "launch",
49+
"program": "${file}",
50+
"console": "integratedTerminal",
51+
"skipFiles": [
52+
"<node_internals>/**"
53+
],
54+
// "runtimeExecutable": "${env:HOME}/.n/bin/node"
55+
}
56+
]
57+
}

.vscode/settings.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

justfile

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,58 @@
11
# See https://just.systems/man/en
22

3-
dotenv-load := "true"
4-
host := `uname -a`
3+
# positional args
4+
# * NOTE: unable to reuse recipe name (e.g., start/stop); prefix recipes with `@`
5+
# set positional-arguments := true
56

6-
default:
7-
just --list
7+
# load .env
8+
set dotenv-load
89

9-
build-clean:
10-
docker-compose build --pull --no-cache
10+
# set env var
11+
# export APP := `echo ${APP}`
12+
# export SCRIPT := "harden"
13+
# export VERSION := "latest"
1114

12-
build:
13-
docker-compose build --pull
15+
# x86_64/arm64
16+
arch := `uname -m`
1417

15-
start:
16-
docker-compose up -d
18+
# hostname
19+
host := `uname -n`
1720

18-
exec:
19-
docker-compose exec app bash
21+
# docker-compose / docker compose
22+
# * https://docs.docker.com/compose/install/linux/#install-using-the-repository
23+
# docker-compose := if `command -v docker-compose; echo $?` == "0" {
24+
# "docker-compose"
25+
# } else {
26+
# "docker compose"
27+
# }
2028

21-
stop:
22-
docker-compose stop
29+
# [halp] list available commands
30+
default:
31+
just --list
2332

24-
down:
25-
docker-compose stop && docker-compose down --remove-orphans
33+
# [deps] update dependencies
34+
update-deps:
35+
#!/usr/bin/env bash
36+
# set -euxo pipefail
37+
find . -maxdepth 3 -name "pyproject.toml" -exec \
38+
echo "[{}]" \; -exec \
39+
echo "Clearring pypi cache..." \; -exec \
40+
poetry cache clear --all pypi --no-ansi \; -exec \
41+
poetry update --lock --no-ansi \;
42+
43+
# [deps] export requirements.txt
44+
export-reqs: update-deps
45+
#!/usr/bin/env bash
46+
# set -euxo pipefail
47+
find . -maxdepth 3 -name "pyproject.toml" -exec \
48+
echo "[{}]" \; -exec \
49+
echo "Exporting requirements.txt..." \; -exec \
50+
poetry export --no-ansi --without-hashes --output requirements.txt \;
51+
52+
# [git] update git submodules
53+
sub:
54+
git submodule update --init --recursive && git pull --recurse-submodules
55+
56+
# [git] update pre-commit hooks
57+
pre-commit:
58+
pre-commit autoupdate

0 commit comments

Comments
 (0)