Skip to content

Commit 46ce153

Browse files
shnizzedygsch-cmiengfranco
committed
♻️ Use REDCap Data Entry Triggers
Co-authored-by: Gabriel Schubiner <gabriel.schubiner@childmind.org> Co-authored-by: Alex Franco <eng.franco@gmail.com>
1 parent b382f77 commit 46ce153

33 files changed

Lines changed: 2692 additions & 1947 deletions
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Terraform Tests
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'infrastructure/**'
7+
push:
8+
branches:
9+
- main
10+
- fix-alerts-more
11+
paths:
12+
- 'infrastructure/**'
13+
14+
jobs:
15+
terraform-tests:
16+
runs-on: ubuntu-latest
17+
defaults:
18+
run:
19+
working-directory: infrastructure
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Terraform
26+
uses: hashicorp/setup-terraform@v3
27+
with:
28+
terraform_version: 1.6.0
29+
30+
- name: Setup Python
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: '3.11'
34+
35+
- name: Install testing tools
36+
run: |
37+
pip install checkov
38+
curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash
39+
40+
- name: Make test script executable
41+
run: chmod +x tests/test-terraform.sh
42+
43+
- name: Run tests
44+
run: ./tests/test-terraform.sh
45+
46+
- name: Terraform Plan
47+
run: |
48+
terraform init -backend=false
49+
terraform plan -no-color
50+
continue-on-error: true

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ terraform.rc
2626
# Generated files
2727
generated_*
2828
**/generated_*
29+
.generated_*
30+
**/.generated_*
2931

3032
# Keep backups in git (they're important!)
3133
!backups/

.pre-commit-config.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ repos:
2828
- id: terraform_tflint
2929
args:
3030
- --init
31-
- --config=__GIT_WORKING_DIR__/.tflint.hcl
31+
- --config=__GIT_WORKING_DIR__/infrastructure/tests/.tflint.hcl
3232
files: ^infrastructure/
3333
- id: terraform_validate
3434
files: ^infrastructure/
3535
- id: terraform_checkov
36+
args:
37+
- --args=--config-file __GIT_WORKING_DIR__/infrastructure/tests/.checkov.yaml
3638
files: ^infrastructure/
3739
- repo: https://github.com/DavidAnson/markdownlint-cli2
3840
rev: v0.22.0

infrastructure/.terraform.lock.hcl

Lines changed: 23 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infrastructure/Makefile

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
.PHONY: help test init plan apply destroy fmt validate lint security clean install-tools
2+
3+
help:
4+
@echo "Available targets:"
5+
@echo " test - Run all tests"
6+
@echo " install-tools - Install testing dependencies"
7+
@echo " init - Initialize Terraform"
8+
@echo " plan - Show execution plan"
9+
@echo " apply - Apply infrastructure changes"
10+
@echo " destroy - Destroy infrastructure"
11+
@echo " fmt - Format Terraform files"
12+
@echo " validate - Validate configuration"
13+
@echo " lint - Run tflint"
14+
@echo " security - Run security scan"
15+
@echo " clean - Clean up generated files"
16+
17+
test:
18+
@./tests/test-terraform.sh
19+
20+
install-tools:
21+
@chmod +x tests/install-tools.sh
22+
@./tests/install-tools.sh
23+
24+
init:
25+
terraform init
26+
27+
plan: init
28+
terraform plan
29+
30+
apply: test
31+
./safe-apply.sh
32+
33+
destroy:
34+
terraform destroy
35+
36+
fmt:
37+
terraform fmt -recursive
38+
39+
validate: init
40+
terraform validate
41+
42+
lint:
43+
@if command -v tflint >/dev/null 2>&1; then \
44+
tflint --config tests/.tflint.hcl --init; \
45+
tflint --config tests/.tflint.hcl; \
46+
else \
47+
echo "tflint not installed. Run: make install-tools"; \
48+
exit 1; \
49+
fi
50+
51+
security:
52+
@if command -v checkov >/dev/null 2>&1; then \
53+
checkov -d . --config-file tests/.checkov.yaml; \
54+
else \
55+
echo "checkov not installed. Run: make install-tools"; \
56+
exit 1; \
57+
fi
58+
59+
clean:
60+
rm -rf .terraform
61+
rm -f .terraform.lock.hcl
62+
rm -f terraform.tfstate
63+
rm -f terraform.tfstate.backup
64+
rm -f plan.tfplan
65+
rm -rf generated/

0 commit comments

Comments
 (0)