Skip to content
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

Add terraform fmt check to CI #6

Merged
merged 1 commit into from
Nov 3, 2023
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
9 changes: 0 additions & 9 deletions .github/workflows/test-ghaf-infra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,3 @@ jobs:
- uses: cachix/install-nix-action@v22
- name: Run ghaf-infra CI tests
run: nix develop --command inv pre-push
- name: Run terraform fmt
run: |
TF_LOG="DEBUG" bash -c 'nix develop .#terraform --command terraform -chdir=terraform fmt'
TF_LOG="DEBUG" bash -c 'nix develop .#terraform --command terraform -chdir=terraform/azure-storage fmt'
# TODO: Enable the below check when 'terraform validate' passes:
# - name: Run terraform validate
# run: |
# TF_LOG="DEBUG" bash -c 'nix develop .#terraform --command terraform -chdir=terraform validate'
# TF_LOG="DEBUG" bash -c 'nix develop .#terraform --command terraform -chdir=terraform/azure-storage validate'
3 changes: 2 additions & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ pkgs.mkShell {
python3.pkgs.invoke
python3.pkgs.pycodestyle
python3.pkgs.pylint
reuse
sops
ssh-to-age
reuse
terraform
];
}
8 changes: 7 additions & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,19 @@ def pre_push(c: Any) -> None:
ret = exec_cmd(cmd, raise_on_error=False)
if not ret:
sys.exit(1)
LOG.info("Running terraform fmt")
cmd = "terraform fmt -check -recursive"
ret = exec_cmd(cmd, raise_on_error=False)
if not ret:
LOG.warning("Run `terraform fmt -recursive` locally to fix formatting")
sys.exit(1)
LOG.info("Running nix fmt")
cmd = "nix fmt"
ret = exec_cmd(cmd, raise_on_error=False)
if not ret:
sys.exit(1)
LOG.info("Running nix flake check")
cmd = "nix flake check"
cmd = "nix flake check -v --log-format raw"
ret = exec_cmd(cmd, raise_on_error=False)
if not ret:
sys.exit(1)
Expand Down
4 changes: 2 additions & 2 deletions terraform/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ provider "azurerm" {
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
source = "hashicorp/azurerm"
}
sops = {
source = "carlpett/sops"
source = "carlpett/sops"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ variable "resource_group_location" {

variable "resourcegroup" {
description = "The Azure Resource Group Name within your Subscription in which this resource will be created."
default = "ghaf-infra-swe"
default = "ghaf-infra-swe"
}

variable "resource_group_name_prefix" {
Expand Down