Skip to content

Commit 6ae2ab8

Browse files
authored
Merge pull request #18 from optiop/feature/linter
Add yaml linter to the CI pipeline
2 parents 6a012a8 + 3edfae9 commit 6ae2ab8

File tree

6 files changed

+74
-57
lines changed

6 files changed

+74
-57
lines changed
Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
---
12
name: Docker build images
23

3-
on:
4+
on: # yamllint disable-line rule:truthy
45
push:
5-
branches: [ "main" ]
6+
branches: ["main"]
67
pull_request:
7-
branches: [ "main" ]
8+
branches: ["main"]
89

910
env:
1011
AWS_REGION: eu-central-1
12+
AWS_ROLE: arn:aws:iam::615677714887:role/postgres-grafana-on-ecs-role
1113

1214
permissions:
1315
id-token: write
@@ -18,28 +20,30 @@ jobs:
1820
runs-on: ubuntu-latest
1921
strategy:
2022
matrix:
21-
image: [ 'grafana', 'postgres' ]
23+
image: ['grafana', 'postgres']
2224
steps:
23-
- uses: actions/checkout@v4
24-
25-
- name: Set AWS credentials
26-
uses: aws-actions/configure-aws-credentials@v4
27-
with:
28-
role-to-assume: arn:aws:iam::615677714887:role/postgres-grafana-on-ecs-role
29-
aws-region: ${{ env.AWS_REGION }}
30-
31-
- name: Set up Docker Buildx
32-
uses: docker/setup-buildx-action@v3
33-
34-
- name: Login to Amazon ECR
35-
id: login-ecr
36-
uses: aws-actions/amazon-ecr-login@v2
37-
38-
- name: Build, tag, and push docker image to Amazon ECR
39-
uses: docker/build-push-action@v5
40-
with:
41-
context: ./src/${{ matrix.image }}
42-
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
43-
tags: 615677714887.dkr.ecr.eu-central-1.amazonaws.com/postgres-grafana-on-ecs-${{ matrix.image }}-repo
44-
cache-from: type=gha
45-
cache-to: type=gha,mode=max
25+
- uses: actions/checkout@v4
26+
27+
- name: Set AWS credentials
28+
uses: aws-actions/configure-aws-credentials@v4
29+
with:
30+
role-to-assume: ${{ env.AWS_ROLE }}
31+
aws-region: ${{ env.AWS_REGION }}
32+
33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v3
35+
36+
- name: Login to Amazon ECR
37+
id: login-ecr
38+
uses: aws-actions/amazon-ecr-login@v2
39+
40+
- name: Build, tag, and push docker image to Amazon ECR
41+
uses: docker/build-push-action@v5
42+
with:
43+
context: ./src/${{ matrix.image }}
44+
push: ${{ github.event_name == 'push' &&
45+
github.ref == 'refs/heads/main' }}
46+
tags: "615677714887.dkr.ecr.eu-central-1.amazonaws.com/\
47+
postgres-grafana-on-ecs-${{ matrix.image }}-repo"
48+
cache-from: type=gha
49+
cache-to: type=gha,mode=max

.github/workflows/linter.yaml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
---
12
name: Linters and formatters
23

3-
on:
4+
on: # yamllint disable-line rule:truthy
45
push:
56
branches:
67
- '**'
@@ -12,15 +13,22 @@ jobs:
1213
build:
1314
runs-on: ubuntu-latest
1415
steps:
15-
- name: Checkout repository
16-
uses: actions/checkout@v4
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
1718

18-
- name: Terraform linter
19-
run: |
20-
terraform version
21-
results=$(find . -type f -name "*.tf" ! -path "*/.terraform/*" -exec terraform fmt -check {} \;)
22-
if [ -n "$results" ]; then
23-
echo "Terraform files must be formatted with 'terraform fmt'. Please run 'terraform fmt' and commit the changes."
24-
echo "$results"
25-
exit 1
26-
fi
19+
- name: Terraform linter
20+
run: |
21+
terraform version
22+
terraform fmt -check -recursive
23+
24+
- name: Set up Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: '3.9'
28+
29+
- name: Install yamllint
30+
run: pip install yamllint
31+
32+
- name: YAML linter
33+
run: |
34+
yamllint --strict .

ops/repository/terraform.tfvars

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
name = "postgres-grafana-on-ecs"
22
github_owner = "optiop"
33
github_repo = "postgres-grafana-on-ecs"
4-
github_oidc_provider_arn =
5-
region =
4+
github_oidc_provider_arn = ""
5+
region = "eu-central-1"
66
tags = {
77
"project" = "Visualize Postgres data on Grafana running on ECS"
8+
"owner" = "Optiop Consulting Group"
9+
"directory" = "optiop/blog"
810
}

src/docker-compose.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1+
---
12
version: "3.8"
23

34
services:
45
grafana:
56
build: ./grafana
67
ports:
7-
- 3000:3000
8+
- 3000:3000
89
environment:
910
- POSTGRES_HOST=postgres
1011
- POSTGRES_PORT=5432
1112
- POSTGRES_USER=postgres
1213
- POSTGRES_PASSWORD=postgres
1314
- POSTGRES_DB=postgres
14-
15+
1516
postgres:
1617
build: ./postgres
1718
environment:
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
---
12
apiVersion: 1
23

34
providers:
4-
- name: 'default'
5-
orgId: 1
6-
folder: ''
7-
type: file
8-
disableDeletion: false
9-
updateIntervalSeconds: 10
10-
options:
11-
path: /etc/grafana/provisioning/dashboards
5+
- name: 'default'
6+
orgId: 1
7+
folder: ''
8+
type: file
9+
disableDeletion: false
10+
updateIntervalSeconds: 10
11+
options:
12+
path: /etc/grafana/provisioning/dashboards
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
apiVersion: 1
23

34
datasources:
@@ -9,10 +10,10 @@ datasources:
910
password: ${POSTGRES_PASSWORD}
1011
jsonData:
1112
database: ${POSTGRES_DB}
12-
sslmode: 'disable' # disable/require/verify-ca/verify-full
13-
maxOpenConns: 100 # Grafana v5.4+
14-
maxIdleConns: 100 # Grafana v5.4+
15-
maxIdleConnsAuto: true # Grafana v9.5.1+
16-
connMaxLifetime: 14400 # Grafana v5.4+
17-
postgresVersion: 903 # 903=9.3, 904=9.4, 905=9.5, 906=9.6, 1000=10
13+
sslmode: 'disable'
14+
maxOpenConns: 100
15+
maxIdleConns: 100
16+
maxIdleConnsAuto: true
17+
connMaxLifetime: 14400
18+
postgresVersion: 903
1819
timescaledb: false

0 commit comments

Comments
 (0)