Skip to content

Commit 36cb967

Browse files
author
Yoan Moscatelli
committed
✨ add pre-commit and pyenv
1 parent e1254a0 commit 36cb967

File tree

7 files changed

+78
-21
lines changed

7 files changed

+78
-21
lines changed

.devcontainer/Dockerfile

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/devcontainers/base:jammy
1+
FROM mcr.microsoft.com/devcontainers/base:noble
22

33
RUN export DEBIAN_FRONTEND=noninteractive && \
44
apt-get update && \
@@ -8,14 +8,33 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
88
bash-completion \
99
curl \
1010
git \
11+
libsqlite3-dev \
1112
python3-pip \
1213
p7zip-full \
1314
skopeo \
1415
tmux \
1516
vim \
1617
&& \
1718
apt-get clean
19+
20+
USER vscode
21+
22+
ENV LANG=C.UTF-8
23+
ENV LC_ALL=C.UTF-8
24+
25+
ENV PYENV_ROOT="/usr/local/pyenv"
26+
ENV PATH="$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH"
27+
1828
COPY requirements.txt /tmp/requirements.txt
19-
RUN python3 -m pip install --no-cache-dir --upgrade pip && \
20-
python3 -m pip install --no-cache-dir -r /tmp/requirements.txt
21-
USER vscode
29+
30+
# Install pyenv
31+
RUN sudo git clone https://github.com/pyenv/pyenv.git $PYENV_ROOT && \
32+
sudo chown $(id -u):$(id -g) -R $PYENV_ROOT && \
33+
printf 'export PYENV_ROOT=%s\nexport PATH="$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH"\nif command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi\n' $PYENV_ROOT | sudo tee -a /etc/bash.bashrc -a /etc/zsh/zshrc
34+
35+
# Install pythons
36+
RUN pyenv install 3.13.2 && \
37+
pyenv global 3.13.2
38+
39+
# Install python libs
40+
RUN pyenv exec pip install -r /tmp/requirements.txt

.devcontainer/requirements.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
requests==2.32.0
2-
GitPython==3.1.43
1+
requests==2.32.3
2+
GitPython==3.1.44
33
pyunpack==0.3
4-
patool==2.2.0
4+
patool==4.0.0
5+
pre-commit==4.1.0

.devcontainer/setup.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -xe
44

5-
if [ "$CODESPACES" = "true" ]; then
5+
if [[ ${CODESPACES} = "true" ]]; then
66
# NOTE: This is the only way I managed to have the right
77
# permissions files for git sources files
88
# (Some salt pylint test check file permissions and expected 644
@@ -25,4 +25,8 @@ gh extension install https://github.com/nektos/gh-act
2525
# Install dependencies
2626
echo "Installing dependencies"
2727
python3 src/main.py install
28+
29+
echo "Install pre-commit hooks"
30+
pre-commit install --install-hooks
31+
2832
echo "End of setup"

.github/dependabot.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ updates:
1212
schedule:
1313
interval: "daily"
1414
rebase-strategy: "auto"
15-
ignore:
16-
- dependency-name: "requests"
17-
versions: ["<2.25.1"]
1815
reviewers:
1916
- "scality/metalk8s"
2017

.github/scripts/update_scanners.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env python3
2+
13
import re
24
import requests
35

.github/workflows/nightly.yaml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,23 @@ jobs:
3838
- name: Update scanner versions
3939
run: python .github/scripts/update_scanners.py
4040

41-
- name: Create Pull Request
42-
uses: peter-evans/create-pull-request@v7
43-
id: pr
44-
with:
45-
title: Dependency update
46-
branch: feature/deps-update
47-
delete-branch: true
48-
commit-message: ":arrow_up: Update scanner versions"
49-
token: ${{ steps.app-token.outputs.token }}
41+
- name: Create pull request
42+
uses: actions/github-script@v7
43+
with:
44+
script: |
45+
const pr = await github.rest.pulls.create({
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
head: "feature/deps-update",
49+
base: "main",
50+
title: ":arrow_up: Update scanner versions"
51+
});
52+
53+
await github.rest.issues.createComment({
54+
issue_number: pr.data.number,
55+
owner: context.repo.owner,
56+
repo: context.repo.repo
57+
})
5058
5159
vuln-scan:
5260
permissions:
@@ -58,7 +66,6 @@ jobs:
5866
- name: Checkout
5967
uses: actions/checkout@v4
6068
with:
61-
path: ./
6269
fetch-depth: 0
6370
fetch-tags: true
6471

.pre-commit-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
default_language_version:
2+
python: python3.12
3+
4+
repos:
5+
- repo: https://github.com/psf/black
6+
rev: 25.1.0
7+
hooks:
8+
- id: black
9+
files: src/.*\.py
10+
name: Formatting Python
11+
- id: black
12+
files: src/.*\.py
13+
# We want this hook to be part of "lint" so that if we run
14+
# `pre-commit run lint` we include this hook
15+
alias: lint
16+
name: Checking Python formatting
17+
args:
18+
- --check
19+
- --diff
20+
21+
- repo: https://github.com/pycqa/pylint
22+
rev: v3.3.5
23+
hooks:
24+
- id: pylint
25+
alias: lint
26+
name: Lint Python (CLI)
27+
files: src/.*\.py

0 commit comments

Comments
 (0)