Repository: chanzuckerberg/fogg
Pull request #586 (2021-07-23 19:55:58)

feat[terraform-docs]: installing terraform-docs
### Summary
I noticed that a lot of the PRs for fogg related repos were throwing this error: 

~~~
Run cd terraform/modules/aws-iam-eks-pod-role
Terraform v0.13.5 is already installed
fmt: 
/home/runner/work/shared-infra/shared-infra/scripts/update-readme.sh: line 12: terraform-docs: command not found
Docs are out of date, run `make docs`
~~~

[Here](https://github.com/chanzuckerberg/shared-infra/runs/3146638646?check_suite_focus=true#step:195:1) is an example.

This PR should fix this by installing `terraform-docs` in the Github Action template and add the binary to the `$GITHUB_PATH` variable.

### Test Plan

* Pull new version of fogg
* Create a fogg repo or use an existing fogg repo
* Make README that needs formatting
* Push a PR for that README
* Verify the error is no longer there.


codecov[bot]: # [Codecov](https://codecov.io/gh/chanzuckerberg/fogg/pull/586?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=chanzuckerberg) Report
> :exclamation: No coverage uploaded for pull request base (`main@8b58425`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=chanzuckerberg#section-missing-base-commit).
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/chanzuckerberg/fogg/pull/586/graphs/tree.svg?width=650&height=150&src=pr&token=57DhtZ7g2A&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=chanzuckerberg)](https://codecov.io/gh/chanzuckerberg/fogg/pull/586?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=chanzuckerberg)

```diff
@@           Coverage Diff           @@
##             main     #586   +/-   ##
=======================================
  Coverage        ?   56.66%           
=======================================
  Files           ?       22           
  Lines           ?     2407           
  Branches        ?        0           
=======================================
  Hits            ?     1364           
  Misses          ?      879           
  Partials        ?      164           
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/chanzuckerberg/fogg/pull/586?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=chanzuckerberg).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=chanzuckerberg)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/chanzuckerberg/fogg/pull/586?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=chanzuckerberg). Last update [8b58425...b0f53fa](https://codecov.io/gh/chanzuckerberg/fogg/pull/586?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=chanzuckerberg). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=chanzuckerberg).


Patch:
diff --git a/templates/templates/.github/workflows/fogg_ci.yml.tmpl b/templates/templates/.github/workflows/fogg_ci.yml.tmpl
index d0651e38..056c6746 100644
--- a/templates/templates/.github/workflows/fogg_ci.yml.tmpl
+++ b/templates/templates/.github/workflows/fogg_ci.yml.tmpl
@@ -21,6 +21,12 @@ jobs:
         uses: actions/setup-python@v1
         with:
           python-version: '3.6'
+      - run: |
+          # https://terraform-docs.io/user-guide/installation/#pre-compiled-binary
+          curl -sSLo ./terraform-docs.tar.gz https://terraform-docs.io/dl/v0.14.1/terraform-docs-v0.14.1-$(uname)-amd64.tar.gz
+          tar -xzf terraform-docs.tar.gz
+          chmod +x terraform-docs
+          echo "$PWD" >> $GITHUB_PATH
       - run: python3 -m venv venv
       - run: . venv/bin/activate
       - run: pip install awscli --upgrade --user


Test patch:
diff --git a/testdata/github_actions/.github/workflows/fogg_ci.yml b/testdata/github_actions/.github/workflows/fogg_ci.yml
index 8f7aef6e..5c21195d 100644
--- a/testdata/github_actions/.github/workflows/fogg_ci.yml
+++ b/testdata/github_actions/.github/workflows/fogg_ci.yml
@@ -12,6 +12,12 @@ jobs:
         uses: actions/setup-python@v1
         with:
           python-version: '3.6'
+      - run: |
+          # https://terraform-docs.io/user-guide/installation/#pre-compiled-binary
+          curl -sSLo ./terraform-docs.tar.gz https://terraform-docs.io/dl/v0.14.1/terraform-docs-v0.14.1-$(uname)-amd64.tar.gz
+          tar -xzf terraform-docs.tar.gz
+          chmod +x terraform-docs
+          echo "$PWD" >> $GITHUB_PATH
       - run: python3 -m venv venv
       - run: . venv/bin/activate
       - run: pip install awscli --upgrade --user
@@ -36,6 +42,12 @@ jobs:
         uses: actions/setup-python@v1
         with:
           python-version: '3.6'
+      - run: |
+          # https://terraform-docs.io/user-guide/installation/#pre-compiled-binary
+          curl -sSLo ./terraform-docs.tar.gz https://terraform-docs.io/dl/v0.14.1/terraform-docs-v0.14.1-$(uname)-amd64.tar.gz
+          tar -xzf terraform-docs.tar.gz
+          chmod +x terraform-docs
+          echo "$PWD" >> $GITHUB_PATH
       - run: python3 -m venv venv
       - run: . venv/bin/activate
       - run: pip install awscli --upgrade --user
@@ -57,6 +69,12 @@ jobs:
         uses: actions/setup-python@v1
         with:
           python-version: '3.6'
+      - run: |
+          # https://terraform-docs.io/user-guide/installation/#pre-compiled-binary
+          curl -sSLo ./terraform-docs.tar.gz https://terraform-docs.io/dl/v0.14.1/terraform-docs-v0.14.1-$(uname)-amd64.tar.gz
+          tar -xzf terraform-docs.tar.gz
+          chmod +x terraform-docs
+          echo "$PWD" >> $GITHUB_PATH
       - run: python3 -m venv venv
       - run: . venv/bin/activate
       - run: pip install awscli --upgrade --user
@@ -78,6 +96,12 @@ jobs:
         uses: actions/setup-python@v1
         with:
           python-version: '3.6'
+      - run: |
+          # https://terraform-docs.io/user-guide/installation/#pre-compiled-binary
+          curl -sSLo ./terraform-docs.tar.gz https://terraform-docs.io/dl/v0.14.1/terraform-docs-v0.14.1-$(uname)-amd64.tar.gz
+          tar -xzf terraform-docs.tar.gz
+          chmod +x terraform-docs
+          echo "$PWD" >> $GITHUB_PATH
       - run: python3 -m venv venv
       - run: . venv/bin/activate
       - run: pip install awscli --upgrade --user
@@ -99,6 +123,12 @@ jobs:
         uses: actions/setup-python@v1
         with:
           python-version: '3.6'
+      - run: |
+          # https://terraform-docs.io/user-guide/installation/#pre-compiled-binary
+          curl -sSLo ./terraform-docs.tar.gz https://terraform-docs.io/dl/v0.14.1/terraform-docs-v0.14.1-$(uname)-amd64.tar.gz
+          tar -xzf terraform-docs.tar.gz
+          chmod +x terraform-docs
+          echo "$PWD" >> $GITHUB_PATH
       - run: python3 -m venv venv
       - run: . venv/bin/activate
       - run: pip install awscli --upgrade --user
@@ -120,6 +150,12 @@ jobs:
         uses: actions/setup-python@v1
         with:
           python-version: '3.6'
+      - run: |
+          # https://terraform-docs.io/user-guide/installation/#pre-compiled-binary
+          curl -sSLo ./terraform-docs.tar.gz https://terraform-docs.io/dl/v0.14.1/terraform-docs-v0.14.1-$(uname)-amd64.tar.gz
+          tar -xzf terraform-docs.tar.gz
+          chmod +x terraform-docs
+          echo "$PWD" >> $GITHUB_PATH
       - run: python3 -m venv venv
       - run: . venv/bin/activate
       - run: pip install awscli --upgrade --user
@@ -141,6 +177,12 @@ jobs:
         uses: actions/setup-python@v1
         with:
           python-version: '3.6'
+      - run: |
+          # https://terraform-docs.io/user-guide/installation/#pre-compiled-binary
+          curl -sSLo ./terraform-docs.tar.gz https://terraform-docs.io/dl/v0.14.1/terraform-docs-v0.14.1-$(uname)-amd64.tar.gz
+          tar -xzf terraform-docs.tar.gz
+          chmod +x terraform-docs
+          echo "$PWD" >> $GITHUB_PATH
       - run: python3 -m venv venv
       - run: . venv/bin/activate
       - run: pip install awscli --upgrade --user
diff --git a/testdata/v2_full_yaml/.github/workflows/fogg_ci.yml b/testdata/v2_full_yaml/.github/workflows/fogg_ci.yml
index 1f4ce182..d872adf7 100644
--- a/testdata/v2_full_yaml/.github/workflows/fogg_ci.yml
+++ b/testdata/v2_full_yaml/.github/workflows/fogg_ci.yml
@@ -14,6 +14,12 @@ jobs:
         uses: actions/setup-python@v1
         with:
           python-version: '3.6'
+      - run: |
+          # https://terraform-docs.io/user-guide/installation/#pre-compiled-binary
+          curl -sSLo ./terraform-docs.tar.gz https://terraform-docs.io/dl/v0.14.1/terraform-docs-v0.14.1-$(uname)-amd64.tar.gz
+          tar -xzf terraform-docs.tar.gz
+          chmod +x terraform-docs
+          echo "$PWD" >> $GITHUB_PATH
       - run: python3 -m venv venv
       - run: . venv/bin/activate
       - run: pip install awscli --upgrade --user