Skip to content

Commit c12ec99

Browse files
authored
Enable linting (#732)
* Add Github Actions for running code linters * Fix linting issues. The super-linter.env currently has the following additions that are to be addressed in the future: VALIDATE_GITHUB_ACTIONS=false VALIDATE_SHELL_SHFMT=false VALIDATE_YAML=false Most of the linting for the above has been addressed with just a single issue remaining that blocks the linter from being enabled. * Update GH workflow so linting always runs befor any other jobs * Update GH workflow so linting always runs befor any other jobs * Fix linting issues on the merge of origin/main * Fix linting issues on the merge of origin/main * Use the head ref for workflow concurrency * Output the path filter result of the workflow * Tweak github action used to detect changed paths on push/pull request * Tweak github action used to detect changed paths on push/pull request * Tweak github action used to detect changed paths on push/pull request * Tweak github action used to detect changed paths on push/pull request * Tweak github action used to detect changed paths on push/pull request * Tweak github action used to detect changed paths on push/pull request * Tweak github action used to detect changed paths on push/pull request * Tweak github action used to detect changed paths on push/pull request * Tweak github action used to detect changed paths on push/pull request * Tweak github action used to detect changed paths on push/pull request * Tweak github action used to detect changed paths on push/pull request * Tweak github action used to detect changed paths on push/pull request * Tweak github action used to detect changed paths on push/pull request * Tweak github action used to detect changed paths on push/pull request * Tweak github action used to detect changed paths on push/pull request * Tweak github action used to detect changed paths on push/pull request * Tweak github action used to detect changed paths on push/pull request * Tweak github action used to detect changed paths on push/pull request * Tweak github action used to detect changed paths on push/pull request * Tweak github action used to detect changed paths on push/pull request * Troubleshooting: ansible.builtin.user * Troubleshooting: debugging temporarily added * Shift pylint invalid-name linting behond python bang line * Temporarily disable the ansible galaxy requirements validation * Reverting changes made to ansible.builtin.user and ansible.builtin.group where the name parameter was added. Reverting to ansible.builtin.group: <args> becasue args aren't an expected label: groupadd: '{'name': 'grafana', 'gid': 979}' is not a valid group name * Arguments are dicts not labels * Preserve file permissions on .ssh directory contents * Wherever we use become_user set become: true, keeps the linter happy and maintains functionality * Fix linting on merge of origin/main * Fix linting on merge of origin/main * Update cluster image - using fatimage built from ci/linting branch * Add comments to workflow files detailing the CI workflow and enable these workflows * Fix workflow execution: 1. change trivvy to trivy 2. extra, stackhpc, and trivyscan workflows should trigger on workflow_call and workflow_dispatch * Fix linting issues from merge of origin/main * Exclude 'ansible/roles/compute_init/files/compute-init.yml' from ansible lint. The parser can't load the 'tasks/tuned.yml' ansible so fails with: load-failure[filenotfounderror]: [Errno 2] No such file or directory: 'ansible-slurm-appliance/tasks/main.yml' tasks/main.yml:1 This failure can't be skipped beause it's the output of the parser that's fed to the linter where such exceptions are made. * Temporarily disable Rocky 8 to speed up testing and reduce CI resources Temporarily disable ansible-lint: Run ansible/[email protected] Run if [[ -n "" ]]; then Run action_ref="${GH_ACTION_REF_INPUT:-${GITHUB_ACTION_REF:-main}}" Using ansible-lint ref: main Run reqs_file=$(git rev-parse --show-toplevel)/.git/ansible-lint-requirements.txt --2025-09-09 14:51:58-- https://raw.githubusercontent.com/ansible/ansible-lint/main/.config/requirements-lock.txt Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.133, 185.199.110.133, 185.199.108.133, ... Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|:443... connected. HTTP request sent, awaiting response... 404 Not Found 2025-09-09 14:51:58 ERROR 404: Not Found. * Fix some bad ansible-lint line-length markup * Fix ansible-lint markup for line-length * Bump CI image - FOR RL9 ONLY TO CONSERVE CI RESOURCES * Revert ansible.builtin.command to ansible.builtin.shell due to missed comment "need login shell for module command" and mask ansible-lint error * Disable extra-build.yml workflow which has previously passed so we can focus on the stackhpc.yml workflow * Disable concurrency to see if this is killing stackhpc.yml * Remove concurrency from extr.yml, stackhpc.yml, and trivyscan.yml as they're all being triggered from main.yml which has its own concurrency check - the trivscan concurrency was also killing stackhpc * Enable ansible-lint * Enable triggering of all workflows from the main CI workflow * Bump CI image - FOR RL9 ONLY TO CONSERVE CI RESOURCES * Fix bad ansible-lint markup affecting the bang line * Reduce workflow CI resources whilst fixing test deploy and reimage workflow * Bump CI image - FOR RL9 ONLY TO CONSERVE CI RESOURCES * Enable Rocky Linux 8 - disabled to speed up testing * Enable all CI workflows * Bump CI image - FOR RL9 ONLY TO CONSERVE CI RESOURCES * Remove empty line between ansible "when" and "block" added by ansible-lint --fix, it's not required by the linter. * Enable check for ansible galaxy requirements * Revert the ansible collections path to ansible/collections so we don't inadvertently break any existing checkouts. Direct ansible-lint to use .ansible/collections so downloads are excluded from linting by our .ansible-lint.yml * Bump CI image
1 parent 919a7e2 commit c12ec99

File tree

389 files changed

+5025
-4013
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

389 files changed

+5025
-4013
lines changed

.ansible-lint.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
skip_list:
3+
- role-name
4+
# Unresolved issues with parsing jinja in multiline strings
5+
# https://github.com/ansible/ansible-lint/issues/3935
6+
- jinja[spacing]
7+
- galaxy[no-changelog]
8+
- meta-runtime[unsupported-version]
9+
10+
warn_list:
11+
- name[missing]
12+
- name[play]
13+
- var-naming
14+
15+
exclude_paths:
16+
- actionlint.yml
17+
- .ansible/
18+
- .github/
19+
# Rule 'syntax-check' is unskippable, you cannot use it in 'skip_list' or 'warn_list'.
20+
# It breaks the parser which takes place before the linter, the only option is to exclude the file.
21+
- ansible/roles/filebeat/tasks/runtime.yml
22+
- environments/common/files/filebeat/filebeat.yml
23+
# Rule 'load-failure[filenotfounderror]' is also unskippable
24+
- ansible/roles/compute_init/files/compute-init.yml

.checkov.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
skip-check:
3+
# Requires all blocks to have rescue: - not considered appropriate
4+
- CKV2_ANSIBLE_3

.editorconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# The is primarily used to alter the behaviour of linters executed by super-linter.
2+
# See https://editorconfig.org/
3+
4+
# shfmt will default to indenting shell scripts with tabs,
5+
# define the indent as 2 spaces
6+
[{.github/bin,dev}/*.sh]
7+
indent_style = space
8+
indent_size = 2

.github/bin/create-merge-branch.sh

100644100755
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ if git show-branch "remotes/origin/$BRANCH_NAME" >/dev/null 2>&1; then
4444
fi
4545

4646
echo "[INFO] Merging release tag - $RELEASE_TAG"
47-
git merge --strategy recursive -X theirs --no-commit $RELEASE_TAG
47+
git merge --strategy recursive -X theirs --no-commit "$RELEASE_TAG"
4848

4949
# Check if the merge resulted in any changes being staged
5050
if [ -n "$(git status --short)" ]; then
@@ -54,7 +54,7 @@ if [ -n "$(git status --short)" ]; then
5454
# NOTE(scott): The GitHub create-pull-request action does
5555
# the commiting for us, so we only need to make branches
5656
# and commits if running outside of GitHub actions.
57-
if [ ! $GITHUB_ACTIONS ]; then
57+
if [ ! "$GITHUB_ACTIONS" ]; then
5858
echo "[INFO] Checking out temporary branch '$BRANCH_NAME'..."
5959
git checkout -b "$BRANCH_NAME"
6060

@@ -74,8 +74,8 @@ if [ -n "$(git status --short)" ]; then
7474

7575
# Write a file containing the branch name and tag
7676
# for automatic PR or MR creation that follows
77-
echo "BRANCH_NAME=\"$BRANCH_NAME\"" > .mergeenv
78-
echo "RELEASE_TAG=\"$RELEASE_TAG\"" >> .mergeenv
77+
echo "BRANCH_NAME=\"$BRANCH_NAME\"" >.mergeenv
78+
echo "RELEASE_TAG=\"$RELEASE_TAG\"" >>.mergeenv
7979
else
8080
echo "[INFO] Merge resulted in no changes"
81-
fi
81+
fi

.github/bin/get-s3-image.sh

100644100755
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ echo "Checking if image $image_name exists in OpenStack"
1313
image_exists=$(openstack image list --name "$image_name" -f value -c Name)
1414

1515
if [ -n "$image_exists" ]; then
16-
echo "Image $image_name already exists in OpenStack."
16+
echo "Image $image_name already exists in OpenStack."
1717
else
18-
echo "Image $image_name not found in OpenStack. Getting it from S3."
18+
echo "Image $image_name not found in OpenStack. Getting it from S3."
1919

20-
wget https://leafcloud.store/swift/v1/AUTH_f39848421b2747148400ad8eeae8d536/$bucket_name/$image_name --progress=dot:giga
20+
wget "https://leafcloud.store/swift/v1/AUTH_f39848421b2747148400ad8eeae8d536/$bucket_name/$image_name" --progress=dot:giga
2121

22-
echo "Uploading image $image_name to OpenStack..."
23-
openstack image create --file $image_name --disk-format qcow2 $image_name --progress
22+
echo "Uploading image $image_name to OpenStack..."
23+
openstack image create --file "$image_name" --disk-format qcow2 "$image_name" --progress
2424

25-
echo "Image $image_name has been uploaded to OpenStack."
26-
fi
25+
echo "Image $image_name has been uploaded to OpenStack."
26+
fi

.github/linters/.checkov.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../.checkov.yaml

.github/linters/.python-lint

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../.python-lint

.github/linters/.shellcheckrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../.shellcheckrc

.github/linters/.yamllint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../.yamllint.yml

.github/linters/actionlint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../actionlint.yml

0 commit comments

Comments
 (0)