Skip to content

Commit 7020a18

Browse files
authored
Merge pull request #377 from dflook/more-linting
2 parents 2433674 + d9811db commit 7020a18

33 files changed

+204
-108
lines changed

.config/.markdownlint.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ no-inline-html:
55
allowed_elements: ['p', 'img']
66
ul-style:
77
style: sublist
8-

.config/.v8rrc.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
customCatalog:
2+
schemas:
3+
- name: Example Workflow
4+
fileMatch: ["example_workflows/*.yaml"]
5+
location: https://json.schemastore.org/github-workflow.json
6+
7+
- name: Markdown Lint
8+
fileMatch: ["changelog.markdownlint.yaml"]
9+
location: "https://raw.githubusercontent.com/DavidAnson/markdownlint/main/schema/markdownlint-config-schema.json"
10+
11+
- name: GitHub Issue Template configuration
12+
fileMatch: [".github/ISSUE_TEMPLATE/config.yml"]
13+
location: "https://json.schemastore.org/github-issue-config.json"
14+
15+
patterns: ['**/*.yaml', '**/*.yml']

.config/.yamllint.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
extends: default
3+
4+
rules:
5+
document-start: disable
6+
line-length:
7+
max: 255
8+
truthy:
9+
check-keys: false
10+
comments:
11+
min-spaces-from-content: 1
12+
octal-values:
13+
forbid-implicit-octal: true
14+
forbid-explicit-octal: true

.config/ruff.toml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
line-length = 120
2+
3+
target-version = "py39"
4+
5+
src = ["docs-gen", "image/src"]
6+
7+
include = [
8+
"docs-gen/*.py",
9+
"image/src/*.py",
10+
"image/src/setup.py",
11+
"tools/*.py",
12+
]
13+
14+
[lint]
15+
# Allow fix for all enabled rules (when `--fix`) is provided.
16+
fixable = ["ALL"]
17+
unfixable = []
18+
19+
# Allow unused variables when underscore-prefixed.
20+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
21+
22+
[lint.flake8-quotes]
23+
inline-quotes = "single"
24+
multiline-quotes = "single"
25+
docstring-quotes = "double"
26+
27+
[format]
28+
quote-style = "single"
29+
docstring-code-format = true

.github/ISSUE_TEMPLATE/problem.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ body:
4949
id: debugging-enabled
5050
attributes:
5151
label: Has debug logging been enabled?
52-
options:
53-
- 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.
52+
options:
53+
- 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.
5454
required: true

.github/workflows/release.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ jobs:
5252
run: |
5353
BASE_TAG=$(docker buildx imagetools inspect danielflook/terraform-github-actions-base:latest --format '{{json .}}' | jq -r '.manifest.annotations."ref.tag"')
5454
BASE_DIGEST=$(docker buildx imagetools inspect "danielflook/terraform-github-actions-base:$BASE_TAG" --format '{{json .}}' | jq -r '.manifest.digest')
55-
55+
5656
gh attestation verify --repo dflook/terraform-github-actions "oci://index.docker.io/danielflook/terraform-github-actions-base@$BASE_DIGEST"
57-
57+
5858
sed -i "s|FROM danielflook/terraform-github-actions-base:latest|FROM danielflook/terraform-github-actions-base@$BASE_DIGEST|" "image/Dockerfile"
59-
59+
6060
docker buildx build \
6161
--build-arg FETCH_CHECKSUMS=yes \
6262
--build-arg VERSION="${RELEASE_TAG:1}" \
@@ -156,12 +156,12 @@ jobs:
156156
git -C "$HOME/$action" tag --force -a -m"$RELEASE_TAG" "$major.$minor-dockerhub"
157157
git -C "$HOME/$action" push --force
158158
git -C "$HOME/$action" push --force --tags
159-
159+
160160
# git tags that use GitHub Container Registry for the image
161161
git -C "$HOME/$action" checkout ghcr || git -C "$HOME/$action" checkout -b ghcr
162162
prepare_release
163163
sed -i "s| image:.*| image: docker://ghcr.io/dflook/terraform-github-actions@$IMAGE_DIGEST|" "$HOME/$action/action.yaml"
164-
164+
165165
git -C "$HOME/$action" add -A
166166
git -C "$HOME/$action" commit -m "$RELEASE_TAG-ghcr"
167167
git -C "$HOME/$action" tag --force -a -m"$RELEASE_TAG" "$RELEASE_TAG-ghcr"

.github/workflows/test-apply.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ jobs:
878878
contents: read
879879
pull-requests: write
880880
env:
881-
GITHUB_TOKEN: No
881+
GITHUB_TOKEN: "No"
882882
TERRAFORM_ACTIONS_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
883883
steps:
884884
- name: Checkout
@@ -1029,7 +1029,7 @@ jobs:
10291029
echo "::error:: output changes not set correctly"
10301030
exit 1
10311031
fi
1032-
1032+
10331033
if [[ "$TO_ADD" -ne 1 ]]; then
10341034
echo "::error:: to_add not set correctly"
10351035
exit 1

.github/workflows/test-binary-plan.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,4 @@ jobs:
137137
if [[ "$FAILURE_REASON" != "plan-changed" ]]; then
138138
echo "::error:: failure-reason not set correctly"
139139
exit 1
140-
fi
140+
fi

.github/workflows/test-changes-only.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -229,4 +229,3 @@ jobs:
229229
echo "::error:: failure-reason not set correctly"
230230
exit 1
231231
fi
232-

.github/workflows/test-cloud.yaml

+12-12
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ jobs:
265265
echo "::error:: Variables not set correctly"
266266
exit 1
267267
fi
268-
268+
269269
if ! grep -q "Terraform will perform the following actions" "$TEXT_PLAN_PATH"; then
270270
echo "::error:: text_plan_path not set correctly"
271271
exit 1
@@ -275,7 +275,7 @@ jobs:
275275
echo "::error:: json_plan_path should not be set"
276276
exit 1
277277
fi
278-
278+
279279
if [[ "$RUN_ID" != "run-"* ]]; then
280280
echo "::error:: output run_id not set correctly"
281281
exit 1
@@ -358,7 +358,7 @@ jobs:
358358
echo "::error:: output not set correctly"
359359
exit 1
360360
fi
361-
361+
362362
if ! grep -q "Terraform will perform the following actions" "$TEXT_PLAN_PATH"; then
363363
echo "::error:: text_plan_path not set correctly"
364364
exit 1
@@ -448,7 +448,7 @@ jobs:
448448
echo "::error:: output changes not set correctly"
449449
exit 1
450450
fi
451-
451+
452452
if ! grep -q "Terraform will perform the following actions" "$TEXT_PLAN_PATH"; then
453453
echo "::error:: text_plan_path not set correctly"
454454
exit 1
@@ -458,7 +458,7 @@ jobs:
458458
echo "::error:: json_plan_path should be set"
459459
exit 1
460460
fi
461-
461+
462462
if [[ "$RUN_ID" != "run-"* ]]; then
463463
echo "::error:: output run_id not set correctly"
464464
exit 1
@@ -485,12 +485,12 @@ jobs:
485485
echo "::error:: Variables not set correctly"
486486
exit 1
487487
fi
488-
488+
489489
if ! grep -q "Terraform will perform the following actions" "$TEXT_PLAN_PATH"; then
490490
echo "::error:: text_plan_path not set correctly"
491491
exit 1
492492
fi
493-
493+
494494
if [[ ! -f "$JSON_PLAN_PATH" ]]; then
495495
echo "::error:: json_plan_path should be set"
496496
exit 1
@@ -536,7 +536,7 @@ jobs:
536536
echo "::error:: changes output not set correctly"
537537
exit 1
538538
fi
539-
539+
540540
if [[ "$APPLY_OUTPUT_LEN" != "5" ]]; then
541541
echo "::error:: Variables not set correctly"
542542
exit 1
@@ -610,7 +610,7 @@ jobs:
610610
echo "::error:: changes output not set correctly"
611611
exit 1
612612
fi
613-
613+
614614
if [[ "$SAVED_APPLY_OUTPUT_LEN" != "8" ]]; then
615615
echo "::error:: Variables not set correctly"
616616
exit 1
@@ -620,7 +620,7 @@ jobs:
620620
echo "::error:: text_plan_path not set correctly"
621621
exit 1
622622
fi
623-
623+
624624
if [[ ! -f "$SAVED_PLAN_JSON_PLAN_PATH" ]]; then
625625
echo "::error:: json_plan_path should be set"
626626
exit 1
@@ -630,7 +630,7 @@ jobs:
630630
echo "::error:: output run_id not set correctly"
631631
exit 1
632632
fi
633-
633+
634634
if [[ "$SAVED_APPLY_RUN_ID" != "run-"* ]]; then
635635
echo "::error:: output run_id not set correctly"
636636
exit 1
@@ -674,7 +674,7 @@ jobs:
674674
echo "::error:: changes output not set correctly"
675675
exit 1
676676
fi
677-
677+
678678
if [[ "$SAVED_APPLY_OUTPUT_LEN" != "8" ]]; then
679679
echo "::error:: Variables not set correctly"
680680
exit 1

.github/workflows/test-http.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ jobs:
162162
echo "::error:: output not set correctly"
163163
exit 1
164164
fi
165-
165+
166166
# Check the credential file is as before
167167
diff tests/workflows/test-http/http-module/netrc "$RUNNER_TEMP_D/_github_home/.netrc"
168168

.github/workflows/test-new-workspace.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
key = "terraform-new-workspace-${{ matrix.tf_version }}"
3333
region = "eu-west-2"
3434
}
35-
35+
3636
required_version = "${{ matrix.tf_version }}"
3737
}
3838
EOF

.github/workflows/test-plan.yaml

+7-7
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
echo "::error:: text_plan_path not set correctly"
5353
exit 1
5454
fi
55-
55+
5656
if ! [[ -f "$PLAN_PATH" ]]; then
5757
echo "::error:: plan_path not set correctly"
5858
exit 1
@@ -232,7 +232,7 @@ jobs:
232232
echo "::error:: text_plan_path not set correctly"
233233
exit 1
234234
fi
235-
235+
236236
if [[ "$TO_ADD" -ne 1 ]]; then
237237
echo "::error:: to_add not set correctly"
238238
exit 1
@@ -864,7 +864,7 @@ jobs:
864864
path: tests/workflows/test-plan/single_sensitive_variable
865865
variables: |
866866
my_sensitive_string = "password123"
867-
867+
868868
869869
plan_sensitive_variables:
870870
runs-on: ubuntu-24.04
@@ -904,7 +904,7 @@ jobs:
904904
protocol = "udp"
905905
fruits = ["apple", "banana"]
906906
}
907-
]
907+
]
908908
909909
plan_sensitive_var:
910910
runs-on: ubuntu-24.04
@@ -999,7 +999,7 @@ jobs:
999999
with:
10001000
path: tests/workflows/test-plan/plan
10011001
var_file: |
1002-
var_file/doesnt/exist.tfvars
1002+
var_file/doesnt/exist.tfvars
10031003
var_file/doesnt/exist2.tfvars
10041004
add_github_comment: false
10051005

@@ -1027,11 +1027,11 @@ jobs:
10271027
echo "Non existant var_file did not fail correctly"
10281028
exit 1
10291029
fi
1030-
1030+
10311031
if [[ "$BACKEND_CONFIG_FILE_OUTCOME" != "failure" ]]; then
10321032
echo "Non existant backend_config_file did not fail correctly"
10331033
exit 1
1034-
fi
1034+
fi
10351035
10361036
test_plan_1_4:
10371037
runs-on: ubuntu-24.04

.github/workflows/test-registry.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
echo "::error:: output not set correctly"
5757
exit 1
5858
fi
59-
59+
6060
# Check that terraformrc is as before
6161
diff tests/workflows/test-registry/terraformrc "$RUNNER_TEMP_D/_github_home/.terraformrc"
6262

.github/workflows/test-test.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
echo "::error:: failure-reason not set correctly"
3434
exit 1
3535
fi
36-
36+
3737
if [[ "$JUNIT_XML_PATH" != "" ]]; then
3838
echo "::error:: junit-xml-path should not be set"
3939
exit 1
@@ -65,7 +65,7 @@ jobs:
6565
echo "::error:: failure-reason not set correctly"
6666
exit 1
6767
fi
68-
68+
6969
if [[ "$JUNIT_XML_PATH" == "" ]]; then
7070
echo "::error:: junit-xml-path should be set"
7171
exit 1
@@ -76,7 +76,7 @@ jobs:
7676
echo "::error:: junit-xml-path does not point to a file"
7777
exit 1
7878
fi
79-
79+
8080
if [[ "$(grep -c '<testsuites' "$JUNIT_XML_PATH")" -ne 1 ]]; then
8181
echo "::error:: junit-xml-path does not contain a testsuites tag"
8282
exit 1
@@ -229,7 +229,7 @@ jobs:
229229
echo "Test did not fail correctly"
230230
exit 1
231231
fi
232-
232+
233233
if [[ "$FAILURE_REASON" != "tests-failed" ]]; then
234234
echo "::error:: failure-reason not set correctly"
235235
exit 1

0 commit comments

Comments
 (0)