Skip to content

Commit 5fbdc92

Browse files
authored
Add E2E tests (#341)
1 parent b23cf9f commit 5fbdc92

File tree

23 files changed

+406
-1
lines changed

23 files changed

+406
-1
lines changed

.github/workflows/e2e.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: e2e
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
schedule:
11+
- cron: "0 0 * * *"
12+
13+
jobs:
14+
e2e:
15+
name: ${{ matrix.os }} (${{ matrix.version }})
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
matrix:
19+
os: [ubuntu-latest, windows-latest]
20+
version: [v0.35.0, latest]
21+
env:
22+
TFLINT_VERSION: ${{ matrix.version }}
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v3
26+
- name: Set up Go
27+
uses: actions/setup-go@v2
28+
with:
29+
go-version: 1.18
30+
- name: Install TFLint
31+
run: curl -sL https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash
32+
- name: Install plugin (Linux)
33+
if: runner.os == 'Linux'
34+
run: make install
35+
- name: Install plugin (Windows)
36+
if: runner.os == 'Windows'
37+
run: |
38+
mkdir -p ~/.tflint.d/plugins
39+
go build -o ~/.tflint.d/plugins/tflint-ruleset-aws.exe
40+
shell: bash
41+
- name: Run E2E tests
42+
run: make e2e

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
default: build
22

33
test:
4-
go test ./...
4+
go test $$(go list ./... | grep -v integration)
5+
6+
e2e:
7+
cd integration && go test && cd ../
58

69
build:
710
go build

integration/basic/.tflint.hcl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
plugin "aws" {
2+
enabled = true
3+
}

integration/basic/result.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"issues": [
3+
{
4+
"rule": {
5+
"name": "aws_instance_invalid_type",
6+
"severity": "error",
7+
"link": ""
8+
},
9+
"message": "\"x2.2xlarge\" is an invalid value as instance_type",
10+
"range": {
11+
"filename": "template.tf",
12+
"start": {
13+
"line": 2,
14+
"column": 19
15+
},
16+
"end": {
17+
"line": 2,
18+
"column": 31
19+
}
20+
},
21+
"callers": []
22+
}
23+
],
24+
"errors": []
25+
}

integration/basic/template.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
resource "aws_instance" "foo" {
2+
instance_type = "x2.2xlarge"
3+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
plugin "aws" {
2+
enabled = true
3+
}
4+
5+
rule "aws_resource_missing_tags" {
6+
enabled = true
7+
tags = ["Environment", "Name", "Type"]
8+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"issues": [
3+
{
4+
"rule": {
5+
"name": "aws_resource_missing_tags",
6+
"severity": "info",
7+
"link": "https://github.com/terraform-linters/tflint-ruleset-aws/blob/v0.13.3/docs/rules/aws_resource_missing_tags.md"
8+
},
9+
"message": "The resource is missing the following tags: \"Environment\", \"Name\", \"Type\".",
10+
"range": {
11+
"filename": "template.tf",
12+
"start": {
13+
"line": 5,
14+
"column": 1
15+
},
16+
"end": {
17+
"line": 5,
18+
"column": 41
19+
}
20+
},
21+
"callers": []
22+
}
23+
],
24+
"errors": []
25+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
variable "tags" {
2+
default = []
3+
}
4+
5+
resource "aws_autoscaling_group" "group" {
6+
tags = var.tags
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugin "aws" {
2+
enabled = true
3+
}
4+
5+
rule "aws_instance_invalid_ami" {
6+
enabled = false
7+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"issues": [],
3+
"errors": []
4+
}

0 commit comments

Comments
 (0)