Skip to content

Commit

Permalink
Keep Python linting container up to date (#8607)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-czernek authored Apr 17, 2024
1 parent 654a963 commit 45cc8e3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-checkstyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
jobs:
checkstyle:
runs-on: ubuntu-latest
container: registry.opensuse.org/home/mczernek/containers/opensuse_factory_containerfile/uyuni-lint:latest
container: registry.opensuse.org/systemsmanagement/uyuni/master/docker/containers_tw/uyuni-master-python:latest

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ linting/lint.sh -a
Alternatively, you can use the provided container to run `pylint` and `black` manually:

```
podman run --rm -it -v $UYUNI_ROOT:/mgr registry.opensuse.org/home/mczernek/containers/opensuse_factory_containerfile/uyuni-lint:latest bash
podman run --rm -it -v $UYUNI_ROOT:/mgr registry.opensuse.org/systemsmanagement/uyuni/master/docker/containers_tw/uyuni-master-python:latest bash
black -t py36 path/to/file.py
pylint --rcfile=/root/.pylintrc /path/to/file.py
```
Expand Down
11 changes: 8 additions & 3 deletions python/linting/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if ! git rev-parse 2>/dev/null; then
fi

ENGINE="${CONTAINER_ENGINE:-podman}"
IMAGE='registry.opensuse.org/home/mczernek/containers/opensuse_factory_containerfile/uyuni-lint'
IMAGE='registry.opensuse.org/systemsmanagement/uyuni/master/docker/containers_tw/uyuni-master-python'
TAG='latest'
GITROOT="$(git rev-parse --show-toplevel)"
MOUNT="/mgr"
Expand Down Expand Up @@ -43,12 +43,16 @@ function help() {
echo " $(basename ${0}) python"
}

function ensure_latest_container_image() {
$ENGINE pull --quiet $IMAGE
}

function execute_black() {
"$ENGINE" run --rm -v ${GITROOT}:${MOUNT} ${IMAGE}:${TAG} black -t py36 "$@"
$ENGINE run --rm -v ${GITROOT}:${MOUNT} ${IMAGE}:${TAG} black -t py36 "$@"
}

function execute_lint() {
"$ENGINE" run --rm -v ${GITROOT}:${MOUNT} ${IMAGE}:${TAG} pylint --rcfile /root/.pylintrc "$@"
$ENGINE run --rm -v ${GITROOT}:${MOUNT} ${IMAGE}:${TAG} pylint --rcfile /root/.pylintrc "$@"
}

function get_all_py_files() {
Expand All @@ -57,6 +61,7 @@ function get_all_py_files() {
}

function main() {
ensure_latest_container_image
if [[ "${CHECK_ALL_FILES}" == "true" ]]; then
files="$(get_all_py_files)"
echo "Linting and formatting: $files"
Expand Down

0 comments on commit 45cc8e3

Please sign in to comment.