Skip to content

Enable linting #732

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

Draft
wants to merge 35 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b8a502f
Add Github Actions for running code linters
maxstack Jun 16, 2025
9939b23
Fix linting issues.
maxstack Jul 3, 2025
1c298e9
Update GH workflow so linting always runs befor any other jobs
maxstack Jul 18, 2025
572bdd0
Update GH workflow so linting always runs befor any other jobs
maxstack Jul 18, 2025
47c9ffe
Merge remote-tracking branch 'origin/main' into ci/enable-linting
maxstack Jul 18, 2025
f6477c7
Fix linting issues on the merge of origin/main
maxstack Jul 29, 2025
684123f
Merge remote-tracking branch 'origin/main' into ci/enable-linting
maxstack Jul 29, 2025
dedef28
Fix linting issues on the merge of origin/main
maxstack Jul 29, 2025
db6fca4
Use the head ref for workflow concurrency
maxstack Jul 29, 2025
86215ab
Output the path filter result of the workflow
maxstack Jul 30, 2025
87bf78b
Tweak github action used to detect changed paths on push/pull request
maxstack Jul 30, 2025
20d0874
Tweak github action used to detect changed paths on push/pull request
maxstack Jul 30, 2025
dbebb2a
Tweak github action used to detect changed paths on push/pull request
maxstack Jul 30, 2025
0457142
Tweak github action used to detect changed paths on push/pull request
maxstack Jul 30, 2025
5ce0b00
Tweak github action used to detect changed paths on push/pull request
maxstack Jul 30, 2025
2b53a02
Tweak github action used to detect changed paths on push/pull request
maxstack Jul 30, 2025
df0bb62
Tweak github action used to detect changed paths on push/pull request
maxstack Jul 30, 2025
55d26e2
Tweak github action used to detect changed paths on push/pull request
maxstack Jul 30, 2025
59e2c38
Tweak github action used to detect changed paths on push/pull request
maxstack Jul 30, 2025
b965ecb
Tweak github action used to detect changed paths on push/pull request
maxstack Jul 30, 2025
5b02436
Tweak github action used to detect changed paths on push/pull request
maxstack Jul 30, 2025
8131025
Merge remote-tracking branch 'origin/main' into ci/enable-linting
maxstack Jul 30, 2025
2f698a3
Tweak github action used to detect changed paths on push/pull request
maxstack Jul 30, 2025
e17401d
Tweak github action used to detect changed paths on push/pull request
maxstack Jul 30, 2025
642888a
Tweak github action used to detect changed paths on push/pull request
maxstack Jul 30, 2025
c35c930
Tweak github action used to detect changed paths on push/pull request
maxstack Jul 30, 2025
1e165bb
Tweak github action used to detect changed paths on push/pull request
maxstack Jul 30, 2025
c046991
Tweak github action used to detect changed paths on push/pull request
maxstack Jul 30, 2025
b29f846
Tweak github action used to detect changed paths on push/pull request
maxstack Jul 30, 2025
4531d42
Tweak github action used to detect changed paths on push/pull request
maxstack Jul 30, 2025
fc6e6e7
Tweak github action used to detect changed paths on push/pull request
maxstack Jul 31, 2025
8d3261f
Merge remote-tracking branch 'origin/main' into ci/enable-linting
maxstack Aug 1, 2025
7ed8866
Troubleshooting: ansible.builtin.user
maxstack Aug 1, 2025
bdb0bbf
Troubleshooting: debugging temporarily added
maxstack Aug 4, 2025
7f8e61a
Shift pylint invalid-name linting behond python bang line
maxstack Aug 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 22 additions & 0 deletions .ansible-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
skip_list:
- role-name
# Unresolved issues with parsing jinja in multiline strings
# https://github.com/ansible/ansible-lint/issues/3935
- jinja[spacing]
- galaxy[no-changelog]
- meta-runtime[unsupported-version]

warn_list:
- name[missing]
- name[play]
- var-naming

exclude_paths:
- actionlint.yml
- .ansible/
- .github/
# The following are files with syntax errors.
# Rule 'syntax-check' is unskippable, you cannot use it in 'skip_list' or 'warn_list'. Still, you could exclude the file.
- ansible/roles/filebeat/tasks/runtime.yml
- environments/common/files/filebeat/filebeat.yml
4 changes: 4 additions & 0 deletions .checkov.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
skip-check:
# Requires all blocks to have rescue: - not considered appropriate
- CKV2_ANSIBLE_3
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# The is primarily used to alter the behaviour of linters executed by super-linter.
# See https://editorconfig.org/

# shfmt will default to indenting shell scripts with tabs,
# define the indent as 2 spaces
[{.github/bin,dev}/*.sh]
indent_style = space
indent_size = 2
10 changes: 5 additions & 5 deletions .github/bin/create-merge-branch.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ if git show-branch "remotes/origin/$BRANCH_NAME" >/dev/null 2>&1; then
fi

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

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

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

# Write a file containing the branch name and tag
# for automatic PR or MR creation that follows
echo "BRANCH_NAME=\"$BRANCH_NAME\"" > .mergeenv
echo "RELEASE_TAG=\"$RELEASE_TAG\"" >> .mergeenv
echo "BRANCH_NAME=\"$BRANCH_NAME\"" >.mergeenv
echo "RELEASE_TAG=\"$RELEASE_TAG\"" >>.mergeenv
else
echo "[INFO] Merge resulted in no changes"
fi
fi
14 changes: 7 additions & 7 deletions .github/bin/get-s3-image.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ echo "Checking if image $image_name exists in OpenStack"
image_exists=$(openstack image list --name "$image_name" -f value -c Name)

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

wget https://object.arcus.openstack.hpc.cam.ac.uk/swift/v1/AUTH_3a06571936a0424bb40bc5c672c4ccb1/$bucket_name/$image_name --progress=dot:giga
wget "https://object.arcus.openstack.hpc.cam.ac.uk/swift/v1/AUTH_3a06571936a0424bb40bc5c672c4ccb1/$bucket_name/$image_name --progress=dot:giga"

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

echo "Image $image_name has been uploaded to OpenStack."
fi
echo "Image $image_name has been uploaded to OpenStack."
fi
1 change: 1 addition & 0 deletions .github/linters/.checkov.yaml
1 change: 1 addition & 0 deletions .github/linters/.python-lint
1 change: 1 addition & 0 deletions .github/linters/.shellcheckrc
1 change: 1 addition & 0 deletions .github/linters/.yamllint.yml
1 change: 1 addition & 0 deletions .github/linters/actionlint.yml
38 changes: 14 additions & 24 deletions .github/workflows/extra.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
---
name: Test extra build
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'environments/.stackhpc/tofu/cluster_image.auto.tfvars.json'
- 'ansible/roles/doca/**'
- 'ansible/roles/cuda/**'
- 'ansible/roles/slurm_recompile/**' # runs on cuda group
- 'ansible/roles/lustre/**'
- '.github/workflows/extra.yml'
pull_request:
paths:
- 'environments/.stackhpc/tofu/cluster_image.auto.tfvars.json'
- 'ansible/roles/doca/**'
- 'ansible/roles/cuda/**'
- 'ansible/roles/lustre/**'
- '.github/workflows/extra.yml'

permissions:
contents: read
packages: write
# To report GitHub Actions status checks
statuses: write

jobs:
doca:
Expand Down Expand Up @@ -46,7 +36,7 @@ jobs:
PACKER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Load current fat images into GITHUB_ENV
# see https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#example-of-a-multiline-string
Expand All @@ -60,7 +50,7 @@ jobs:
- name: Record settings
run: |
echo CI_CLOUD: ${{ env.CI_CLOUD }}
echo FAT_IMAGES: ${FAT_IMAGES}
echo "FAT_IMAGES: ${FAT_IMAGES}"

- name: Setup ssh
run: |
Expand Down Expand Up @@ -99,7 +89,7 @@ jobs:

PACKER_LOG=1 packer build \
-on-error=${{ vars.PACKER_ON_ERROR }} \
-var-file=$PKR_VAR_environment_root/${{ env.CI_CLOUD }}.pkrvars.hcl \
-var-file="$PKR_VAR_environment_root/${{ env.CI_CLOUD }}.pkrvars.hcl" \
-var "source_image_name=${{ fromJSON(env.FAT_IMAGES)['cluster_image'][matrix.build.source_image_name_key] }}" \
-var "image_name=${{ matrix.build.image_name }}" \
-var "inventory_groups=${{ matrix.build.inventory_groups }}" \
Expand All @@ -111,14 +101,14 @@ jobs:
run: |
. venv/bin/activate
IMAGE_ID=$(jq --raw-output '.builds[-1].artifact_id' packer/packer-manifest.json)
while ! openstack image show -f value -c name $IMAGE_ID; do
while ! openstack image show -f value -c name "$IMAGE_ID"; do
sleep 5
done
IMAGE_NAME=$(openstack image show -f value -c name $IMAGE_ID)
IMAGE_NAME=$(openstack image show -f value -c name "$IMAGE_ID")
echo "image-name=${IMAGE_NAME}" >> "$GITHUB_OUTPUT"
echo "image-id=$IMAGE_ID" >> "$GITHUB_OUTPUT"
echo $IMAGE_ID > image-id.txt
echo $IMAGE_NAME > image-name.txt
echo "$IMAGE_ID" > image-id.txt
echo "$IMAGE_NAME" > image-name.txt

- name: Make image usable for further builds
run: |
Expand Down
19 changes: 13 additions & 6 deletions .github/workflows/fatimage.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build fat image
on:
workflow_dispatch:
# checkov:skip=CKV_GHA_7: "The build output cannot be affected by user parameters other than the build entry point and the top-level source location. GitHub Actions workflow_dispatch inputs MUST be empty. "
inputs:
ci_cloud:
description: 'Select the CI_CLOUD'
Expand All @@ -16,6 +17,12 @@ on:
required: true
default: true

permissions:
contents: read
packages: write
# To report GitHub Actions status checks
statuses: write

jobs:
openstack:
name: openstack-imagebuild
Expand All @@ -42,7 +49,7 @@ jobs:
PACKER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Record settings for CI cloud
run: |
Expand Down Expand Up @@ -85,7 +92,7 @@ jobs:

PACKER_LOG=1 packer build \
-on-error=${{ github.event.inputs.cleanup_on_failure && 'cleanup' || 'abort' }} \
-var-file=$PKR_VAR_environment_root/${{ env.CI_CLOUD }}.pkrvars.hcl \
-var-file="$PKR_VAR_environment_root/${{ env.CI_CLOUD }}.pkrvars.hcl" \
-var "source_image_name=${{ matrix.build.source_image_name }}" \
-var "image_name=${{ matrix.build.image_name }}" \
-var "inventory_groups=${{ matrix.build.inventory_groups }}" \
Expand All @@ -96,14 +103,14 @@ jobs:
run: |
. venv/bin/activate
IMAGE_ID=$(jq --raw-output '.builds[-1].artifact_id' packer/packer-manifest.json)
while ! openstack image show -f value -c name $IMAGE_ID; do
while ! openstack image show -f value -c name "$IMAGE_ID"; do
sleep 5
done
IMAGE_NAME=$(openstack image show -f value -c name $IMAGE_ID)
IMAGE_NAME=$(openstack image show -f value -c name "$IMAGE_ID")
echo "image-name=${IMAGE_NAME}" >> "$GITHUB_OUTPUT"
echo "image-id=$IMAGE_ID" >> "$GITHUB_OUTPUT"
echo $IMAGE_ID > image-id.txt
echo $IMAGE_NAME > image-name.txt
echo "$IMAGE_ID" > image-id.txt
echo "$IMAGE_NAME" > image-name.txt

- name: Make image usable for further builds
run: |
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: Lint

on: # yamllint disable-line rule:truthy
workflow_call:

permissions:
contents: read
packages: read
# To report GitHub Actions status checks
statuses: write

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
# To report GitHub Actions status checks
statuses: write

steps:
- uses: actions/checkout@v4
with:
# super-linter needs the full git history to get the
# list of files that changed across commits
fetch-depth: 0
submodules: true

- name: Run ansible-lint
uses: ansible/[email protected]

- name: Load super-linter configuration
# Use grep inverse matching to exclude eventual comments in the .env file
# because the GitHub Actions command to set environment variables doesn't
# support comments.
# yamllint disable-line rule:line-length
# Ref: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-environment-variable
run: grep -v '^#' super-linter.env >> "$GITHUB_ENV"
if: always()

- name: Run super-linter
uses: super-linter/[email protected]
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading