Skip to content

Commit

Permalink
feature: yaml lint
Browse files Browse the repository at this point in the history
  • Loading branch information
sheeeng committed Oct 7, 2021
1 parent 61e6da0 commit 28330ca
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 71 deletions.
4 changes: 3 additions & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "2" # required to adjust maintainability checks
version: "2" # required to adjust maintainability checks
checks:
argument-count:
config:
Expand Down Expand Up @@ -26,7 +26,9 @@ checks:
threshold: 8
similar-code:
config:
# yamllint disable-line rule:empty-values
threshold: # language-specific defaults. an override will affect all languages.
identical-code:
config:
# yamllint disable-line rule:empty-values
threshold: # language-specific defaults. an override will affect all languages.
52 changes: 52 additions & 0 deletions .github/linters/.yaml-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
# https://github.com/adrienverge/yamllint
extends: relaxed

yaml-files:
- "*.yaml"
- "*.yml"
- ".yamllint"
- ".yamllint.yaml"

rules:
braces:
level: warning
max-spaces-inside: 1
brackets:
level: warning
max-spaces-inside: 1
colons:
level: warning
commas:
level: warning
comments:
level: warning
require-starting-space: true
min-spaces-from-content: 1
comments-indentation: disable
document-start: disable
document-end: disable
empty-lines:
level: warning
empty-values:
level: warning
hyphens:
max-spaces-after: 1
level: warning
indentation:
spaces: 2
indent-sequences: consistent
check-multi-line-strings: true
key-duplicates: enable
key-ordering: disable
line-length:
max: 160
level: warning
allow-non-breakable-inline-mappings: true
new-line-at-end-of-file: enable
new-lines: enable
octal-values: disable
quoted-strings: disable
trailing-spaces: enable
truthy:
level: warning
77 changes: 39 additions & 38 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,54 @@
name: "CodeQL"

# yamllint disable-line rule:truthy
on:
push:
branches: [master, ]
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
schedule:
- cron: '0 9 * * 3'
- cron: "0 9 * * 3"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: go, javascript

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: go, javascript

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

# - run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
13 changes: 7 additions & 6 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# yamllint disable-line rule:truthy
on:
push:
branches:
Expand All @@ -8,9 +9,9 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: deploy
uses: ./.github/action-deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- uses: actions/checkout@master
- name: deploy
uses: ./.github/action-deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
45 changes: 26 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Test
# yamllint disable-line rule:truthy
on: [pull_request]
jobs:
go:
Expand All @@ -8,33 +9,39 @@ jobs:
redis:
image: redis
ports:
- 6379:6379
- 6379:6379
memcached:
image: memcached
ports:
- 11211:11211
- 11211:11211
env:
MEMCACHED: localhost:11211
REDIS_URL: 'redis://localhost:6379/0'
REDIS_URL: "redis://localhost:6379/0"
steps:
- name: Set up Go 1.15
uses: actions/setup-go@v1
with:
go-version: 1.15.1
id: go
- name: Set up Go 1.15
uses: actions/setup-go@v1
with:
go-version: 1.15.1
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v1

- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Go Test
run: |
for i in {1..5}; do if ! echo stats | nc -w 1 localhost 11211 >/dev/null; then echo 'Waiting for memcached' && sleep 1; fi; done
go test ./... -race -coverprofile=coverage.txt -covermode=atomic -v
- name: codecov upload
uses: codecov/[email protected]
env:
token: ${{ secrets.CODECOV_TOKEN }}

- name: Go Test
run: |
for i in {1..5}; do if ! echo stats | nc -w 1 localhost 11211 >/dev/null; then echo 'Waiting for memcached' && sleep 1; fi; done
go test ./... -race -coverprofile=coverage.txt -covermode=atomic -v
- name: yaml lint
run: |
pip install --user yamllint
yamllint --config-file=.github/linters/.yaml-lint.yml .
- name: codecov upload
uses: codecov/[email protected]
env:
token: ${{ secrets.CODECOV_TOKEN }}
node:
name: Website Test
runs-on: ubuntu-latest
Expand All @@ -47,7 +54,7 @@ jobs:
- uses: cypress-io/github-action@v2
with:
start: yarn start
wait-on: 'http://localhost:3000'
wait-on: "http://localhost:3000"
working-directory: website
browser: chrome
record: true
Expand Down
8 changes: 4 additions & 4 deletions deploy/aws-lambda/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ provider:
Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:provider.environment.TABLE_NAME}"

package:
exclude:
- ./**
include:
- ./main
exclude:
- ./**
include:
- ./main

functions:
create:
Expand Down
4 changes: 2 additions & 2 deletions deploy/docker-compose/insecure/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
version: '3.0'
version: "3.0"

services:
memcached:
image: memcached
restart: always
expose:
- "11211"

yopass:
image: jhaals/yopass
restart: always
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ services:
expose:
- "80"

volumes:
# yamllint disable rule:empty-values
volumes:
certs:
vhost.d:
html:
acme.sh:
# yamllint enable rule:empty-values

0 comments on commit 28330ca

Please sign in to comment.