Skip to content

Commit

Permalink
fix: Add error handling around directories (#16)
Browse files Browse the repository at this point in the history
Co-authored-by: Bryant Biggs <[email protected]>
  • Loading branch information
markandersontrocme and bryantbiggs committed Nov 15, 2022
1 parent f0a8fb0 commit b3bb2f7
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

- name: Terraform min/max versions
id: minMax
uses: clowdhaus/[email protected].3
uses: clowdhaus/[email protected].4
with:
directory: ${{ matrix.directory }}

Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:

- name: Terraform min/max versions
id: minMax
uses: clowdhaus/[email protected].3
uses: clowdhaus/[email protected].4

- name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}
uses: ./pre-commit
Expand Down
6 changes: 5 additions & 1 deletion directories/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,22 @@ runs:
import os
import re
import glob
from pathlib import Path
def get_directories():
"""
Return all Terraform (*.tf) files that contain the 'required_version'
string, but does not contain 'wrapper' in the path.
string, but does not contain 'wrapper' in the path.
"""
terraform_files = glob.glob('./**/*.tf', recursive=True)
directories = []
for file in terraform_files:
p = Path(file)
if p.is_dir():
continue
file_size = os.stat(file)
if file_size.st_size > 0:
Expand Down
4 changes: 4 additions & 0 deletions directories/directories.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import re
import glob
from pathlib import Path


def get_directories():
Expand All @@ -15,6 +16,9 @@ def get_directories():
directories = []

for file in terraform_files:
p = Path(file)
if p.is_dir():
continue
file_size = os.stat(file)

if file_size.st_size > 0:
Expand Down
1 change: 1 addition & 0 deletions examples/cost.modules.tf/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
locals {}
Empty file.
Empty file.
14 changes: 14 additions & 0 deletions examples/cost.modules.tf/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
provider "aws" {
region = "us-east-1"
}

terraform {
required_version = ">= 1.0.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.0"
}
}
}

0 comments on commit b3bb2f7

Please sign in to comment.