Skip to content

Commit ba1477e

Browse files
anujhydrabadiclaude
andcommitted
Install terraform and trivy for raptor module validation
ubuntu-latest runners ship neither terraform nor trivy, so raptor's --dry-run validation hard-failed ("terraform is not installed") and the security scan silently degraded. Added an install step (after mode resolution, gated to skip cleanup mode, which needs neither): - terraform: pinned via new input terraform-version (default 1.5.7 to match module-preview-action), unzipped from releases.hashicorp.com to /usr/local/bin. - trivy: pinned via new input trivy-version (default 0.72.0), tarball from aquasecurity/trivy releases to /usr/local/bin. No third-party setup actions. README inputs table + requirements note updated. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent fd0e231 commit ba1477e

2 files changed

Lines changed: 44 additions & 1 deletion

File tree

module-ci-action/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ modules live at `infra/modules/...`).
4040

4141
## Requirements
4242

43-
- **Runner:** Ubuntu (the action installs a Linux amd64 `raptor` binary).
43+
- **Runner:** Ubuntu (the action installs Linux amd64 `raptor`, and — for preview/publish
44+
`terraform` and `trivy`, which raptor's module validation and security scan require;
45+
ubuntu-latest ships none of them). Versions are pinnable via the inputs below.
4446
- **raptor version:** preview and cleanup depend on newer `raptor` capabilities:
4547
- **preview** uses `raptor create iac-module --feature-branch`, a flag that marks a
4648
preview as **unpublishable**.
@@ -65,6 +67,8 @@ modules live at `infra/modules/...`).
6567
| `github_token` | no | `""` | GitHub token. Enables the PR **preview comment** and, in **cleanup**, reading the PR's commit SHAs for the ownership check. When absent, those are skipped (cleanup does nothing, safely). |
6668
| `raptor_version` | no | `latest` | `latest`, or an exact release tag such as `v1.2.3`. Ignored when `raptor-download-url` is set. |
6769
| `raptor-download-url` | no | `""` | Exact URL to download the raptor `linux-amd64` binary from, bypassing the default `Facets-cloud/raptor-releases` location. When set, `raptor_version` is ignored. An escape hatch for testing / pre-release raptor builds and enterprise mirrors. |
70+
| `terraform-version` | no | `1.5.7` | Terraform version installed (from `releases.hashicorp.com`) for raptor's module validation. Not installed in **cleanup** mode. |
71+
| `trivy-version` | no | `0.72.0` | Trivy version installed (from `aquasecurity/trivy` releases, no `v` prefix) for raptor's module security scan. Not installed in **cleanup** mode. |
6872
| `all-modules` | no | `false` | When `true`, operate on **every** module under `<path-prefix>modules/` instead of only the ones the event changed. |
6973
| `mode` | no | `auto` | `auto` \| `preview` \| `publish` \| `cleanup`. `auto` derives the mode from the event (see the table above). Set explicitly to override. |
7074
| `path-prefix` | no | `""` | Sub-path to the `modules/` tree relative to the repo root (e.g. `infra/`). Empty means `modules/` is at the root. |

module-ci-action/action.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ inputs:
2424
description: "Exact URL to download the raptor linux-amd64 binary from, bypassing the default Facets-cloud/raptor-releases location. When set, raptor_version is ignored. Escape hatch for testing/pre-release builds and enterprise mirrors."
2525
required: false
2626
default: ""
27+
terraform-version:
28+
description: "Terraform version to install for raptor's module validation (terraform fmt/validate). Downloaded from releases.hashicorp.com. Not installed in cleanup mode."
29+
required: false
30+
default: "1.5.7"
31+
trivy-version:
32+
description: "Trivy version to install for raptor's module security scan. Downloaded from github.com/aquasecurity/trivy releases (no 'v' prefix). Not installed in cleanup mode."
33+
required: false
34+
default: "0.72.0"
2735
all-modules:
2836
description: "When 'true', operate on every module under <path-prefix>modules/ instead of only the ones changed by the triggering event."
2937
required: false
@@ -106,6 +114,37 @@ runs:
106114
echo "Resolved mode: ${MODE} (event=${EVENT_NAME}, action=${EVENT_ACTION:-none})"
107115
echo "MODE=${MODE}" >> "$GITHUB_ENV"
108116
117+
- name: Install Terraform and Trivy
118+
# Only preview/publish run raptor's module validation, which shells out to
119+
# terraform and trivy. Cleanup deletes previews and needs neither.
120+
if: env.MODE != 'cleanup'
121+
shell: bash
122+
env:
123+
TERRAFORM_VERSION: ${{ inputs.terraform-version }}
124+
TRIVY_VERSION: ${{ inputs.trivy-version }}
125+
run: |
126+
set -euo pipefail
127+
128+
# Terraform — raptor's module validation runs `terraform fmt`/`validate`,
129+
# and ubuntu-latest runners ship no terraform (raptor hard-fails without it).
130+
echo "Installing Terraform ${TERRAFORM_VERSION}..."
131+
TF_ZIP="terraform_${TERRAFORM_VERSION}_linux_amd64.zip"
132+
curl -fsSL -o "$TF_ZIP" "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/${TF_ZIP}"
133+
unzip -o "$TF_ZIP" terraform
134+
sudo mv terraform /usr/local/bin/terraform
135+
rm -f "$TF_ZIP"
136+
terraform version
137+
138+
# Trivy — raptor's security scan uses it. Without it raptor only warns, but
139+
# we want the scan enforced in CI.
140+
echo "Installing Trivy ${TRIVY_VERSION}..."
141+
TRIVY_TGZ="trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz"
142+
curl -fsSL -o "$TRIVY_TGZ" "https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/${TRIVY_TGZ}"
143+
tar -xzf "$TRIVY_TGZ" trivy
144+
sudo mv trivy /usr/local/bin/trivy
145+
rm -f "$TRIVY_TGZ"
146+
trivy --version
147+
109148
- name: Detect target module directories
110149
shell: bash
111150
env:

0 commit comments

Comments
 (0)