From 0b786d5329282239a014cc27e1b92918075adc55 Mon Sep 17 00:00:00 2001 From: Daniel Mohns Date: Thu, 23 May 2024 13:30:05 +0200 Subject: [PATCH 1/6] Add more linters --- .github/workflows/check-generic.yaml | 40 ++++++++++++++++++++++++++++ .markdownlint-cli2.yaml | 14 ++++++++++ .yamllint | 18 +++++++++++++ .yamllintignore | 1 + 4 files changed, 73 insertions(+) create mode 100644 .github/workflows/check-generic.yaml create mode 100644 .markdownlint-cli2.yaml create mode 100644 .yamllint create mode 100644 .yamllintignore diff --git a/.github/workflows/check-generic.yaml b/.github/workflows/check-generic.yaml new file mode 100644 index 0000000..1b2c8d0 --- /dev/null +++ b/.github/workflows/check-generic.yaml @@ -0,0 +1,40 @@ +# Generic checks to ease collaboration: +# - consistent file encoding in UNIX style +# - whitespaces in all purposes files like markdown, yaml, etc +name: Check Generic + +on: + push: + branches: + - develop + pull_request: + branches: + - develop + +jobs: + editorconfig-checker: + name: Run editorconfig-checker + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Run editorconfig-checker + run: docker run --rm --volume=$PWD:/check mstruebing/editorconfig-checker + + markdownlint: + name: Run markdownlint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Run markdownlint-cli2 + uses: DavidAnson/markdownlint-cli2-action@v13 + + yamllint: + name: Run yamllint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Run yamllint + run: yamllint . diff --git a/.markdownlint-cli2.yaml b/.markdownlint-cli2.yaml new file mode 100644 index 0000000..bf17a7f --- /dev/null +++ b/.markdownlint-cli2.yaml @@ -0,0 +1,14 @@ +# Disable some built-in rules +config: + line-length: false + no-inline-html: false + first-line-h1: false + code-fence-style: + style: backtick + +# Define glob expressions to use (only valid at root) +globs: + - "**/*.md" + +# Ignore files that are not part of version control +gitignore: true diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..a0a00a2 --- /dev/null +++ b/.yamllint @@ -0,0 +1,18 @@ +extends: default + +ignore-from-file: + - .gitignore + - .yamllintignore + +rules: + document-start: disable + indentation: + spaces: 2 + line-length: disable + quoted-strings: + quote-type: double + required: only-when-needed + allow-quoted-quotes: true + check-keys: true + truthy: + check-keys: false diff --git a/.yamllintignore b/.yamllintignore new file mode 100644 index 0000000..bd5535a --- /dev/null +++ b/.yamllintignore @@ -0,0 +1 @@ +pnpm-lock.yaml From d1a4db886eb729c973d2e74006a7c56f3080862a Mon Sep 17 00:00:00 2001 From: Daniel Mohns Date: Thu, 23 May 2024 13:32:43 +0200 Subject: [PATCH 2/6] Fix `yamllint` --- buildspec.yml | 70 ++++++++++++++++++++++----------------------- docker-compose.yaml | 26 +++++++++++++++++ drec-ui-dev.yaml | 18 ++++++------ drec-ui-prod.yaml | 16 +++++------ drec-ui-stage.yaml | 16 +++++------ 5 files changed, 86 insertions(+), 60 deletions(-) create mode 100644 docker-compose.yaml diff --git a/buildspec.yml b/buildspec.yml index 13684d7..d3c0e52 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -1,35 +1,35 @@ -version: 0.2 -env: - parameter-store: - docker_username: /powertrust/docker/username - docker_password: /powertrust/docker/password -phases: - install: - # runtime-versions: - # nodejs: 18 - # docker: 18 - commands: - - nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2 & - - timeout 15 sh -c "until docker info; do echo .; sleep 1; done" - - curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" - - chmod +x ./kubectl - - curl -Lo aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v0.5.9/aws-iam-authenticator_0.5.9_linux_amd64 - - chmod +x ./aws-iam-authenticator - - export PATH=$PWD/:$PATH - pre_build: - commands: - - IMAGE="drec-ui" - - BUILD_NUMBER=$(cat version) - - aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin 895706603967.dkr.ecr.eu-west-1.amazonaws.com - - export KUBECONFIG=$HOME/.kube/config - build: - commands: - - echo $docker_password | docker login --username $docker_username --password-stdin - - docker build -t $IMAGE:$BUILD_NUMBER -f Dockerfile --build-arg build_environment=$environment . - - docker tag $IMAGE:$BUILD_NUMBER 895706603967.dkr.ecr.eu-west-1.amazonaws.com/$IMAGE:$environment-$BUILD_NUMBER - post_build: - commands: - - docker push 895706603967.dkr.ecr.eu-west-1.amazonaws.com/$IMAGE:$environment-$BUILD_NUMBER - - aws eks update-kubeconfig --name drec - - template=`cat "$IMAGE-$environment.yaml" | sed "s/{{BUILD_NUMBER}}/$environment-$BUILD_NUMBER/g"` - - echo "$template" | kubectl apply -f - \ No newline at end of file +version: 0.2 +env: + parameter-store: + docker_username: /powertrust/docker/username + docker_password: /powertrust/docker/password +phases: + install: + # runtime-versions: + # nodejs: 18 + # docker: 18 + commands: + - nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2 & + - timeout 15 sh -c "until docker info; do echo .; sleep 1; done" + - curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" + - chmod +x ./kubectl + - curl -Lo aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v0.5.9/aws-iam-authenticator_0.5.9_linux_amd64 + - chmod +x ./aws-iam-authenticator + - export PATH=$PWD/:$PATH + pre_build: + commands: + - IMAGE="drec-ui" + - BUILD_NUMBER=$(cat version) + - aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin 895706603967.dkr.ecr.eu-west-1.amazonaws.com + - export KUBECONFIG=$HOME/.kube/config + build: + commands: + - echo $docker_password | docker login --username $docker_username --password-stdin + - docker build -t $IMAGE:$BUILD_NUMBER -f Dockerfile --build-arg build_environment=$environment . + - docker tag $IMAGE:$BUILD_NUMBER 895706603967.dkr.ecr.eu-west-1.amazonaws.com/$IMAGE:$environment-$BUILD_NUMBER + post_build: + commands: + - docker push 895706603967.dkr.ecr.eu-west-1.amazonaws.com/$IMAGE:$environment-$BUILD_NUMBER + - aws eks update-kubeconfig --name drec + - template=`cat "$IMAGE-$environment.yaml" | sed "s/{{BUILD_NUMBER}}/$environment-$BUILD_NUMBER/g"` + - echo "$template" | kubectl apply -f - diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..e554127 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,26 @@ +version: "3" +services: + drec-ui: + build: + context: . + dockerfile: Dockerfile + container_name: drec-ui + ports: + - 80:80 + # env_file: + # - .env + # environment: + # - DB_HOST=drec-postgres + # - INFLUXDB_URL=http://drec-influxdb:8086 + + # drec-ui: + # build: + # context: ./apps/drec-angular-ui + # dockerfile: Dockerfile + # container_name: drec-ui + # ports: + # - "80:80" + # depends_on: + # - fluxdb + # - postgres + # - redis diff --git a/drec-ui-dev.yaml b/drec-ui-dev.yaml index 4f3a1cd..162000f 100644 --- a/drec-ui-dev.yaml +++ b/drec-ui-dev.yaml @@ -14,14 +14,14 @@ spec: app.kubernetes.io/name: drec-ui spec: containers: - - image: 895706603967.dkr.ecr.eu-west-1.amazonaws.com/drec-ui:{{BUILD_NUMBER}} - imagePullPolicy: Always - name: drec-ui - envFrom: - - secretRef: - name: drec-dev-env - ports: - - containerPort: 80 + - image: 895706603967.dkr.ecr.eu-west-1.amazonaws.com/drec-ui:{{BUILD_NUMBER}} + imagePullPolicy: Always + name: drec-ui + envFrom: + - secretRef: + name: drec-dev-env + ports: + - containerPort: 80 --- apiVersion: v1 kind: Service @@ -35,4 +35,4 @@ spec: protocol: TCP type: NodePort selector: - app.kubernetes.io/name: drec-ui \ No newline at end of file + app.kubernetes.io/name: drec-ui diff --git a/drec-ui-prod.yaml b/drec-ui-prod.yaml index 70a69a6..39cfe61 100644 --- a/drec-ui-prod.yaml +++ b/drec-ui-prod.yaml @@ -14,14 +14,14 @@ spec: app.kubernetes.io/name: drec-ui spec: containers: - - image: 895706603967.dkr.ecr.eu-west-1.amazonaws.com/drec-ui:{{BUILD_NUMBER}} - imagePullPolicy: Always - name: drec-ui - envFrom: - - secretRef: - name: drec-prod-env - ports: - - containerPort: 80 + - image: 895706603967.dkr.ecr.eu-west-1.amazonaws.com/drec-ui:{{BUILD_NUMBER}} + imagePullPolicy: Always + name: drec-ui + envFrom: + - secretRef: + name: drec-prod-env + ports: + - containerPort: 80 --- apiVersion: v1 kind: Service diff --git a/drec-ui-stage.yaml b/drec-ui-stage.yaml index 9d4d973..3afe6f9 100644 --- a/drec-ui-stage.yaml +++ b/drec-ui-stage.yaml @@ -14,14 +14,14 @@ spec: app.kubernetes.io/name: drec-ui spec: containers: - - image: 895706603967.dkr.ecr.eu-west-1.amazonaws.com/drec-ui:{{BUILD_NUMBER}} - imagePullPolicy: Always - name: drec-ui - envFrom: - - secretRef: - name: drec-stage-env - ports: - - containerPort: 80 + - image: 895706603967.dkr.ecr.eu-west-1.amazonaws.com/drec-ui:{{BUILD_NUMBER}} + imagePullPolicy: Always + name: drec-ui + envFrom: + - secretRef: + name: drec-stage-env + ports: + - containerPort: 80 --- apiVersion: v1 kind: Service From a5f983e7e9d2d927ddbe2f85c9fa1fc276da590c Mon Sep 17 00:00:00 2001 From: Daniel Mohns Date: Thu, 23 May 2024 13:32:53 +0200 Subject: [PATCH 3/6] Update `.prettierrc` --- .prettierrc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.prettierrc b/.prettierrc index dcb7279..48cd1cf 100755 --- a/.prettierrc +++ b/.prettierrc @@ -1,4 +1,12 @@ { "singleQuote": true, - "trailingComma": "all" -} \ No newline at end of file + "trailingComma": "all", + "overrides": [ + { + "files": "*.{yaml,yml}", + "options": { + "singleQuote": false + } + } + ] +} From bb871753a24d9ced033c050b1c92e33a5f821470 Mon Sep 17 00:00:00 2001 From: Daniel Mohns Date: Thu, 23 May 2024 13:35:14 +0200 Subject: [PATCH 4/6] Fix `markdownlint` --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09659f1..b201756 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # DRec UI CHANGELOG.md ## 0.0.1 + - Dockerfile and buildspec.yml changes -- CICD testing \ No newline at end of file +- CICD testing From c77d87b6025d18b43f70b368457828d178382c75 Mon Sep 17 00:00:00 2001 From: Daniel Mohns Date: Thu, 23 May 2024 13:37:11 +0200 Subject: [PATCH 5/6] Update `.editorconfig` --- .editorconfig | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/.editorconfig b/.editorconfig index 59d9a3a..30e849c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,16 +1,6 @@ -# Editor configuration, see https://editorconfig.org -root = true +# EditorConfig is awesome: https://EditorConfig.org [*] +# Ensure consistent file encoding in UNIX style charset = utf-8 -indent_style = space -indent_size = 2 -insert_final_newline = true -trim_trailing_whitespace = true - -[*.ts] -quote_type = single - -[*.md] -max_line_length = off -trim_trailing_whitespace = false +end_of_line = lf From e949526d55f3fc84b9d211b25f262a8e38131adb Mon Sep 17 00:00:00 2001 From: Daniel Mohns Date: Thu, 23 May 2024 13:39:53 +0200 Subject: [PATCH 6/6] Remove accidentally commited file --- docker-compose.yaml | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 docker-compose.yaml diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index e554127..0000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,26 +0,0 @@ -version: "3" -services: - drec-ui: - build: - context: . - dockerfile: Dockerfile - container_name: drec-ui - ports: - - 80:80 - # env_file: - # - .env - # environment: - # - DB_HOST=drec-postgres - # - INFLUXDB_URL=http://drec-influxdb:8086 - - # drec-ui: - # build: - # context: ./apps/drec-angular-ui - # dockerfile: Dockerfile - # container_name: drec-ui - # ports: - # - "80:80" - # depends_on: - # - fluxdb - # - postgres - # - redis