Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add codespell support (config, workflow to detect/not fix) and make it fix few typos #138

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Codespell configuration is within pyproject.toml
---
name: Codespell

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Annotate locations with typos
uses: codespell-project/codespell-problem-matcher@v1
- name: Codespell
uses: codespell-project/actions-codespell@v2
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ The order of precedence from lowest to highest is:
1. configuration file template (if a template is allowed)
1. environment variable template (if a template is allowed)
1. configuration file
1. enviornment variables
1. environment variables

The enviornment variable override is the configuration parameter in upper case prefixed
The environment variable override is the configuration parameter in upper case prefixed
with PODMANHPC_ (e.g. podman_bin becomes PODMANHPC_PODMAN_BIN).

The list of configurable values is:
Expand All @@ -40,7 +40,7 @@ The list of configurable values is:
Some parameters can be set using a template. The template is set by the parameter with `_template` appended to the parameter to
be templated (e.g. graph_root_template would be used to generate the value for the graph_root parameter).

The template replaces strings with `{{ variable }}` with the approriate value. The following variables are supported.
The template replaces strings with `{{ variable }}` with the appropriate value. The following variables are supported.
* uid: replaced with the user id of the calling user
* user: replaced with the user name of the calling user
* env.VARIABLE: replaced with the value of the environment `VARIABLE`. For example, env.HOME would be replaced with the value of `HOME`.
Expand Down
2 changes: 1 addition & 1 deletion extra/squash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This directory contains a Dockerfile that
can be used to generate a static mksquashfs.
This utility is required during the migration.
It needs to be statically compiled so that the
binary can work on any architectually compatible
binary can work on any architecturally compatible
image.

## Instructions
Expand Down
2 changes: 1 addition & 1 deletion podman_hpc/click_passthrough.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def filterValidOptions(options, subcmd, option_regex=None):
if (opt == uk and idx not in uk_safe_index.get(uk, []))
]
uk = unknowns.pop(0)
# find and remove an invalid occurence of uk
# find and remove an invalid occurrence of uk
while True:
valid_options_tmp = valid_options.copy()
valid_options_tmp.pop(ukd[uk][0])
Expand Down
12 changes: 6 additions & 6 deletions podman_hpc/migrate2scratch.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def get_img_info(self, img_name):

def get_manifest(self, imgid):
"""
Retruns the contents of the manifest for the given image ID
Returns the contents of the manifest for the given image ID

Inputs:
imgid: image id
Expand All @@ -98,7 +98,7 @@ def init_storage(self):
the minimum directories and JSON files.
"""
if self.read_only:
raise ValueError("Cannot init read-only stroage")
raise ValueError("Cannot init read-only storage")

if not os.path.exists(self.base):
os.mkdir(self.base)
Expand Down Expand Up @@ -138,7 +138,7 @@ def del_rec(self, otype, id, key="id"):
key: key name for the ID
"""
if self.read_only:
raise ValueError("Cannot init read-only stroage")
raise ValueError("Cannot init read-only storage")

fn = os.path.join(self.base, f"overlay-{otype}", f"{otype}.json")
data = json.load(open(fn))
Expand All @@ -163,7 +163,7 @@ def drop_tag(self, tags):
tags: list of tags
"""
if self.read_only:
raise ValueError("Cannot init read-only stroage")
raise ValueError("Cannot init read-only storage")

data = self.images

Expand All @@ -186,7 +186,7 @@ def add_recs(self, otype, recs):
for duplicate IDs.
"""
if self.read_only:
raise ValueError("Cannot init read-only stroage")
raise ValueError("Cannot init read-only storage")

fn = os.path.join(self.base, f"overlay-{otype}", f"{otype}.json")
data = json.load(open(fn))
Expand Down Expand Up @@ -287,7 +287,7 @@ def _get_img_layers(self, store, top_layer):

def _add_parent(layer, layer_map, layers=None, layer_ids=None):
"""
Recrusive function to walk up parent graph.
Recursive function to walk up parent graph.

Inputs:
layer: layer to walk
Expand Down
4 changes: 2 additions & 2 deletions podman_hpc/podman_hpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,15 @@ def _shared_run(conf, run_args, **site_opts):
# We need to filter out any run args in the run_args
cmd = [conf.podman_bin, "run", "--help"]
valid_params = cpt.filterValidOptions(list(run_args), cmd)
# Find the first occurence not in the valid list
# Find the first occurrence not in the valid list
idx = 0
for idx, item in enumerate(run_args):
if item in valid_params:
continue
break
image = run_args[idx]
container_cmd = run_args[idx+1:]
# TODO: maybe do some validation on the iamge and container_cmd
# TODO: maybe do some validation on the image and container_cmd

options = sys.argv[
sys.argv.index("shared-run") + 1: sys.argv.index(image)
Expand Down
2 changes: 1 addition & 1 deletion podman_hpc/siteconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def _check_and_set(self, attr: str, envname=None, parname=None):

if setval:
# Expand to a list if the type should be a list
# Assumes a common seperated string
# Assumes a common separated string
if isinstance(getattr(self, attr), list) and \
isinstance(newval, str):
newval = newval.split(',')
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ build-backend = "setuptools.build_meta"

[tool.black]
line-length = 79

[tool.codespell]
# Ref: https://github.com/codespell-project/codespell#using-a-config-file
skip = '.git*,*.lock'
check-hidden = true
# ignore-regex = ''
# ignore-words-list = ''
2 changes: 1 addition & 1 deletion test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_conf_file(fix_paths, conf_file, monkeypatch):
assert str(uid) in conf.run_root
assert f"/imagedir/{user}/storage" == conf.graph_root
assert f"/tmp/{uid}/run" == conf.run_root
# This test environment variable substition and
# This test environment variable substitution and
# environment variables precedence
monkeypatch.setenv("FOO", "BAR")
tmpl = "/tmp/{{ env.FOO }}"
Expand Down