Skip to content

Commit

Permalink
[#181] Validate generated project
Browse files Browse the repository at this point in the history
  • Loading branch information
nvminhtue committed Jan 8, 2024
1 parent a21d811 commit b3b96e2
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 1 deletion.
61 changes: 61 additions & 0 deletions .github/workflows/test-generated-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Test Generated Project

on:
pull_request:
types: [opened, synchronize]

env:
TERRAFORM_VERSION: "1.5.5"
TFSEC_VERSION: "v1.28.1"

jobs:
test:
name: Run Tests Generated Project
strategy:
matrix:
node-version: [16.x, 18.x]
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Cache Node npm
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-infrastructure-templates-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-infrastructure-templates
- name: Install modules
run: npm ci

- name: Generate project
run: . ./scripts/generateAdvancedAWS.sh

- name: Checkout the repository
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}

- name: Install Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ env.TERRAFORM_VERSION }}

- name: Run Terraform format
run: terraform fmt -recursive -check

- name: Run tfsec linter
id: tfsec
uses: aquasecurity/[email protected]
with:
version: ${{ env.TFSEC_VERSION }}

1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
nodejs 18.12.1
terraform 1.5.5
trivy 0.47.0
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"topics": {}
},
"scripts": {
"build": "shx rm -rf dist && ttsc -b",
"build": "shx rm -rf dist tsconfig.tsbuildinfo && ttsc -b",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"postpack": "shx rm -f oclif.manifest.json",
Expand Down
19 changes: 19 additions & 0 deletions scripts/generateAdvancedAWS.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const {
applyTerraformAwsProvider,
applyAwsIamUserAndGroup,
applyAwsRegion,
applyAwsSecurityGroup,
applyAwsVpc,
} = require('../dist/generators/addons/aws/modules/index.js');
const { applyAdvancedTemplate } = require('../dist/generators/addons/aws/advanced.js');

(async () => {
const options = { projectName: 'aws-advanced-test'}

await applyTerraformAwsProvider(options);
await applyAwsRegion(options);
await applyAwsVpc(options);
await applyAwsSecurityGroup(options);
await applyAwsIamUserAndGroup(options);
await applyAdvancedTemplate(options);
})();
3 changes: 3 additions & 0 deletions scripts/generateAdvancedAWS.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
yarn build
node ./scripts/generateAdvancedAWS.js
cd aws-advanced-test

0 comments on commit b3b96e2

Please sign in to comment.