Skip to content

Add additional linting rules #377

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

Merged
merged 6 commits into from
Mar 23, 2025
Merged
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
1 change: 0 additions & 1 deletion .config/.markdownlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ no-inline-html:
allowed_elements: ['p', 'img']
ul-style:
style: sublist

15 changes: 15 additions & 0 deletions .config/.v8rrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
customCatalog:
schemas:
- name: Example Workflow
fileMatch: ["example_workflows/*.yaml"]
location: https://json.schemastore.org/github-workflow.json

- name: Markdown Lint
fileMatch: ["changelog.markdownlint.yaml"]
location: "https://raw.githubusercontent.com/DavidAnson/markdownlint/main/schema/markdownlint-config-schema.json"

- name: GitHub Issue Template configuration
fileMatch: [".github/ISSUE_TEMPLATE/config.yml"]
location: "https://json.schemastore.org/github-issue-config.json"

patterns: ['**/*.yaml', '**/*.yml']
14 changes: 14 additions & 0 deletions .config/.yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
extends: default

rules:
document-start: disable
line-length:
max: 255
truthy:
check-keys: false
comments:
min-spaces-from-content: 1
octal-values:
forbid-implicit-octal: true
forbid-explicit-octal: true
29 changes: 29 additions & 0 deletions .config/ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
line-length = 120

target-version = "py39"

src = ["docs-gen", "image/src"]

include = [
"docs-gen/*.py",
"image/src/*.py",
"image/src/setup.py",
"tools/*.py",
]

[lint]
# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[lint.flake8-quotes]
inline-quotes = "single"
multiline-quotes = "single"
docstring-quotes = "double"

[format]
quote-style = "single"
docstring-code-format = true
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/problem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ body:
id: debugging-enabled
attributes:
label: Has debug logging been enabled?
options:
- label: Yes, the `ACTIONS_STEP_DEBUG` secret was set to `true` when capturing the workflow log above. I understand that if I have not done this, I may not recieve a response.
options:
- label: Yes, the `ACTIONS_STEP_DEBUG` secret was set to `true` when capturing the workflow log above. I understand that if I have not done this, I may not receive a response.
required: true
10 changes: 5 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ jobs:
run: |
BASE_TAG=$(docker buildx imagetools inspect danielflook/terraform-github-actions-base:latest --format '{{json .}}' | jq -r '.manifest.annotations."ref.tag"')
BASE_DIGEST=$(docker buildx imagetools inspect "danielflook/terraform-github-actions-base:$BASE_TAG" --format '{{json .}}' | jq -r '.manifest.digest')

gh attestation verify --repo dflook/terraform-github-actions "oci://index.docker.io/danielflook/terraform-github-actions-base@$BASE_DIGEST"

sed -i "s|FROM danielflook/terraform-github-actions-base:latest|FROM danielflook/terraform-github-actions-base@$BASE_DIGEST|" "image/Dockerfile"

docker buildx build \
--build-arg FETCH_CHECKSUMS=yes \
--build-arg VERSION="${RELEASE_TAG:1}" \
Expand Down Expand Up @@ -156,12 +156,12 @@ jobs:
git -C "$HOME/$action" tag --force -a -m"$RELEASE_TAG" "$major.$minor-dockerhub"
git -C "$HOME/$action" push --force
git -C "$HOME/$action" push --force --tags

# git tags that use GitHub Container Registry for the image
git -C "$HOME/$action" checkout ghcr || git -C "$HOME/$action" checkout -b ghcr
prepare_release
sed -i "s| image:.*| image: docker://ghcr.io/dflook/terraform-github-actions@$IMAGE_DIGEST|" "$HOME/$action/action.yaml"

git -C "$HOME/$action" add -A
git -C "$HOME/$action" commit -m "$RELEASE_TAG-ghcr"
git -C "$HOME/$action" tag --force -a -m"$RELEASE_TAG" "$RELEASE_TAG-ghcr"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-apply.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ jobs:
contents: read
pull-requests: write
env:
GITHUB_TOKEN: No
GITHUB_TOKEN: "No"
TERRAFORM_ACTIONS_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
Expand Down Expand Up @@ -1029,7 +1029,7 @@ jobs:
echo "::error:: output changes not set correctly"
exit 1
fi

if [[ "$TO_ADD" -ne 1 ]]; then
echo "::error:: to_add not set correctly"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-binary-plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,4 @@ jobs:
if [[ "$FAILURE_REASON" != "plan-changed" ]]; then
echo "::error:: failure-reason not set correctly"
exit 1
fi
fi
1 change: 0 additions & 1 deletion .github/workflows/test-changes-only.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,3 @@ jobs:
echo "::error:: failure-reason not set correctly"
exit 1
fi

24 changes: 12 additions & 12 deletions .github/workflows/test-cloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ jobs:
echo "::error:: Variables not set correctly"
exit 1
fi

if ! grep -q "Terraform will perform the following actions" "$TEXT_PLAN_PATH"; then
echo "::error:: text_plan_path not set correctly"
exit 1
Expand All @@ -275,7 +275,7 @@ jobs:
echo "::error:: json_plan_path should not be set"
exit 1
fi

if [[ "$RUN_ID" != "run-"* ]]; then
echo "::error:: output run_id not set correctly"
exit 1
Expand Down Expand Up @@ -358,7 +358,7 @@ jobs:
echo "::error:: output not set correctly"
exit 1
fi

if ! grep -q "Terraform will perform the following actions" "$TEXT_PLAN_PATH"; then
echo "::error:: text_plan_path not set correctly"
exit 1
Expand Down Expand Up @@ -448,7 +448,7 @@ jobs:
echo "::error:: output changes not set correctly"
exit 1
fi

if ! grep -q "Terraform will perform the following actions" "$TEXT_PLAN_PATH"; then
echo "::error:: text_plan_path not set correctly"
exit 1
Expand All @@ -458,7 +458,7 @@ jobs:
echo "::error:: json_plan_path should be set"
exit 1
fi

if [[ "$RUN_ID" != "run-"* ]]; then
echo "::error:: output run_id not set correctly"
exit 1
Expand All @@ -485,12 +485,12 @@ jobs:
echo "::error:: Variables not set correctly"
exit 1
fi

if ! grep -q "Terraform will perform the following actions" "$TEXT_PLAN_PATH"; then
echo "::error:: text_plan_path not set correctly"
exit 1
fi

if [[ ! -f "$JSON_PLAN_PATH" ]]; then
echo "::error:: json_plan_path should be set"
exit 1
Expand Down Expand Up @@ -536,7 +536,7 @@ jobs:
echo "::error:: changes output not set correctly"
exit 1
fi

if [[ "$APPLY_OUTPUT_LEN" != "5" ]]; then
echo "::error:: Variables not set correctly"
exit 1
Expand Down Expand Up @@ -610,7 +610,7 @@ jobs:
echo "::error:: changes output not set correctly"
exit 1
fi

if [[ "$SAVED_APPLY_OUTPUT_LEN" != "8" ]]; then
echo "::error:: Variables not set correctly"
exit 1
Expand All @@ -620,7 +620,7 @@ jobs:
echo "::error:: text_plan_path not set correctly"
exit 1
fi

if [[ ! -f "$SAVED_PLAN_JSON_PLAN_PATH" ]]; then
echo "::error:: json_plan_path should be set"
exit 1
Expand All @@ -630,7 +630,7 @@ jobs:
echo "::error:: output run_id not set correctly"
exit 1
fi

if [[ "$SAVED_APPLY_RUN_ID" != "run-"* ]]; then
echo "::error:: output run_id not set correctly"
exit 1
Expand Down Expand Up @@ -674,7 +674,7 @@ jobs:
echo "::error:: changes output not set correctly"
exit 1
fi

if [[ "$SAVED_APPLY_OUTPUT_LEN" != "8" ]]; then
echo "::error:: Variables not set correctly"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-http.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ jobs:
echo "::error:: output not set correctly"
exit 1
fi

# Check the credential file is as before
diff tests/workflows/test-http/http-module/netrc "$RUNNER_TEMP_D/_github_home/.netrc"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-new-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
key = "terraform-new-workspace-${{ matrix.tf_version }}"
region = "eu-west-2"
}

required_version = "${{ matrix.tf_version }}"
}
EOF
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/test-plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
echo "::error:: text_plan_path not set correctly"
exit 1
fi

if ! [[ -f "$PLAN_PATH" ]]; then
echo "::error:: plan_path not set correctly"
exit 1
Expand Down Expand Up @@ -232,7 +232,7 @@ jobs:
echo "::error:: text_plan_path not set correctly"
exit 1
fi

if [[ "$TO_ADD" -ne 1 ]]; then
echo "::error:: to_add not set correctly"
exit 1
Expand Down Expand Up @@ -864,7 +864,7 @@ jobs:
path: tests/workflows/test-plan/single_sensitive_variable
variables: |
my_sensitive_string = "password123"


plan_sensitive_variables:
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -904,7 +904,7 @@ jobs:
protocol = "udp"
fruits = ["apple", "banana"]
}
]
]

plan_sensitive_var:
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -999,7 +999,7 @@ jobs:
with:
path: tests/workflows/test-plan/plan
var_file: |
var_file/doesnt/exist.tfvars
var_file/doesnt/exist.tfvars
var_file/doesnt/exist2.tfvars
add_github_comment: false

Expand Down Expand Up @@ -1027,11 +1027,11 @@ jobs:
echo "Non existant var_file did not fail correctly"
exit 1
fi

if [[ "$BACKEND_CONFIG_FILE_OUTCOME" != "failure" ]]; then
echo "Non existant backend_config_file did not fail correctly"
exit 1
fi
fi

test_plan_1_4:
runs-on: ubuntu-24.04
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
echo "::error:: output not set correctly"
exit 1
fi

# Check that terraformrc is as before
diff tests/workflows/test-registry/terraformrc "$RUNNER_TEMP_D/_github_home/.terraformrc"

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
echo "::error:: failure-reason not set correctly"
exit 1
fi

if [[ "$JUNIT_XML_PATH" != "" ]]; then
echo "::error:: junit-xml-path should not be set"
exit 1
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
echo "::error:: failure-reason not set correctly"
exit 1
fi

if [[ "$JUNIT_XML_PATH" == "" ]]; then
echo "::error:: junit-xml-path should be set"
exit 1
Expand All @@ -76,7 +76,7 @@ jobs:
echo "::error:: junit-xml-path does not point to a file"
exit 1
fi

if [[ "$(grep -c '<testsuites' "$JUNIT_XML_PATH")" -ne 1 ]]; then
echo "::error:: junit-xml-path does not contain a testsuites tag"
exit 1
Expand Down Expand Up @@ -229,7 +229,7 @@ jobs:
echo "Test did not fail correctly"
exit 1
fi

if [[ "$FAILURE_REASON" != "tests-failed" ]]; then
echo "::error:: failure-reason not set correctly"
exit 1
Expand Down
Loading
Loading