Skip to content

Commit 2aae75b

Browse files
authored
Merge pull request #74 from wayofdev/ci/structure-updates
fix: coding standards
2 parents c8254a9 + 8d5b75c commit 2aae75b

File tree

9 files changed

+129
-33
lines changed

9 files changed

+129
-33
lines changed
File renamed without changes.
File renamed without changes.

.github/.yamllint.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ rules:
4646
require-starting-space: true
4747
min-spaces-from-content: 1
4848

49+
comments-indentation: false
50+
4951
line-length: disable
5052

53+
octal-values:
54+
forbid-implicit-octal: true
55+
forbid-explicit-octal: true
56+
5157
...
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
3+
on: # yamllint disable-line rule:truthy
4+
pull_request:
5+
branches:
6+
- master
7+
8+
name: 🧹 Fix coding standards
9+
10+
jobs:
11+
commit-linting:
12+
timeout-minutes: 4
13+
runs-on: ubuntu-latest
14+
concurrency:
15+
cancel-in-progress: true
16+
group: commit-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
17+
permissions:
18+
contents: read
19+
pull-requests: read
20+
steps:
21+
- name: 📦 Check out the codebase
22+
uses: actions/[email protected]
23+
24+
- name: 🧐 Lint commits using "commitlint"
25+
uses: wagoid/[email protected]
26+
with:
27+
configFile: ${{ github.workspace }}/.github/.commitlint.config.mjs
28+
failOnWarnings: false
29+
failOnErrors: true
30+
helpURL: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint'
31+
32+
yaml-linting:
33+
timeout-minutes: 4
34+
runs-on: ubuntu-latest
35+
concurrency:
36+
cancel-in-progress: true
37+
group: yaml-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
38+
permissions:
39+
contents: read
40+
pull-requests: read
41+
steps:
42+
- name: 📦 Check out the codebase
43+
uses: actions/[email protected]
44+
45+
- name: 🧐 Lint YAML files
46+
uses: ibiqlik/[email protected]
47+
with:
48+
config_file: .github/.yamllint.yaml
49+
file_or_dir: '.'
50+
strict: true
51+
52+
markdown-linting:
53+
timeout-minutes: 4
54+
runs-on: ubuntu-latest
55+
concurrency:
56+
cancel-in-progress: true
57+
group: markdown-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
58+
steps:
59+
- name: 📦 Check out the codebase
60+
uses: actions/[email protected]
61+
62+
- name: 🧐 Lint Markdown files
63+
uses: DavidAnson/[email protected]
64+
with:
65+
config: '.github/.markdownlint.json'
66+
globs: |
67+
**/*.md
68+
!CHANGELOG.md
69+
70+
ansible-linting:
71+
timeout-minutes: 4
72+
runs-on: ubuntu-latest
73+
concurrency:
74+
cancel-in-progress: true
75+
group: ansible-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
76+
env:
77+
YAMLLINT_CONFIG_FILE: '${{ github.workspace }}/.github/.yamllint.yaml'
78+
steps:
79+
- name: 📦 Check out the codebase
80+
uses: actions/[email protected]
81+
82+
- name: 🧐 Lint Ansible files
83+
uses: ansible/[email protected]
84+
with:
85+
args: '-c ${{ github.workspace }}/.github/.ansible-lint.yml'

.github/workflows/merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
startsWith(github.event.workflow_run.head_commit.message, 'deps(deps)')
2222
) ||
2323
(github.actor == 'lotyp' &&
24-
startsWith(github.head_ref, 'release-please--')
24+
startsWith(github.event.workflow_run.head_commit.message, 'chore(master)')
2525
)
2626
)
2727
steps:

.pre-commit-config.yaml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,46 @@
22

33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.4.0
5+
rev: v4.6.0
66
hooks:
77
- id: trailing-whitespace
88
- id: end-of-file-fixer
99
- id: fix-encoding-pragma
1010

1111
- repo: https://github.com/adrienverge/yamllint
12-
rev: v1.31.0
12+
rev: v1.35.1
1313
hooks:
1414
- id: yamllint
1515
files: \.(yaml|yml)$
1616
types: [file, yaml]
17-
entry: yamllint --strict
17+
entry: yamllint -c .github/.yamllint.yaml --strict
1818

1919
- repo: https://github.com/commitizen-tools/commitizen
20-
rev: 3.2.2
20+
rev: v3.29.0
2121
hooks:
2222
- id: commitizen
2323
stages:
2424
- commit-msg
2525

26+
- repo: https://github.com/mpalmer/action-validator
27+
rev: v0.6.0
28+
hooks:
29+
- id: action-validator
30+
stages:
31+
- commit-msg
32+
2633
- repo: https://github.com/ansible/ansible-lint
27-
rev: v6.16.0
34+
rev: v24.7.0
2835
hooks:
2936
- id: ansible-lint
30-
entry: ansible-lint . --force-color
37+
entry: bash -c 'YAMLLINT_CONFIG_FILE=".github/.yamllint.yaml" ansible-lint . --force-color -c .github/.ansible-lint.yml'
3138
pass_filenames: false
3239
always_run: true
3340
additional_dependencies:
3441
- .[community]
3542

3643
- repo: https://github.com/robertdebock/pre-commit
37-
rev: v1.5.2
44+
rev: v1.5.3
3845
hooks:
3946
- id: ansible_role_find_unused_variable
4047
- id: ansible_role_find_empty_files

Makefile

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ CACHE_FROM ?= $(IMAGE_TAG)
1616
OS ?= $(shell uname)
1717
CURRENT_DIR ?= $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
1818

19-
# Yamllint docker image
19+
YAML_CONFIG_PATH ?= .github/.yamllint.yaml
20+
2021
YAML_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \
2122
-v $(PWD):/data \
2223
cytopia/yamllint:latest \
23-
-c ./.github/.yamllint.yaml \
24+
-c $(YAML_CONFIG_PATH) \
2425
-f colored .
2526

2627
ACTION_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \
@@ -35,6 +36,13 @@ MARKDOWN_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \
3536
davidanson/markdownlint-cli2-rules:latest \
3637
--config ".github/.markdownlint.json"
3738

39+
ANSIBLE_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \
40+
-v $(shell pwd):/code \
41+
-e YAMLLINT_CONFIG_FILE=$(YAML_CONFIG_PATH) \
42+
--workdir /code \
43+
pipelinecomponents/ansible-lint:latest \
44+
ansible-lint --show-relpath --config-file ".github/.ansible-lint.yml"
45+
3846
#
3947
# Self documenting Makefile code
4048
# ------------------------------------------------------------------------------------
@@ -91,7 +99,7 @@ PHONY: all
9199
# ------------------------------------------------------------------------------------
92100
build: ## Build default docker image
93101
cd $(CURRENT_DIR)$(DOCKERFILE_DIR); \
94-
docker build -t $(IMAGE_TAG) .
102+
$(DOCKER) build -t $(IMAGE_TAG) .
95103
PHONY: build
96104

97105
analyze: ## Analyze docker image
@@ -101,19 +109,19 @@ analyze: ## Analyze docker image
101109

102110
build-from-cache: ## Build default docker image using cached layers
103111
cd $(CURRENT_DIR)$(DOCKERFILE_DIR); \
104-
docker build --cache-from $(CACHE_FROM) . -t $(IMAGE_TAG)
112+
$(DOCKER) build --cache-from $(CACHE_FROM) . -t $(IMAGE_TAG)
105113
PHONY: build-from-cache
106114

107115
pull: ## Pulls docker image from upstream
108-
docker pull $(IMAGE_TAG)
116+
$(DOCKER) pull $(IMAGE_TAG)
109117
.PHONY: pull
110118

111119
push: ## Pushes image to upstream
112-
docker push $(IMAGE_TAG)
120+
$(DOCKER) push $(IMAGE_TAG)
113121
.PHONY: push
114122

115123
ssh: ## Login into built image
116-
docker run --rm -it -v $(PWD)/:/opt/docker-php-base $(IMAGE_TAG) sh
124+
$(DOCKER) run --rm -it -v $(PWD)/:/opt/docker-php-base $(IMAGE_TAG) sh
117125
.PHONY: ssh
118126

119127
#
@@ -144,7 +152,7 @@ hooks: ## Install git hooks from pre-commit-config
144152
pre-commit autoupdate
145153
.PHONY: hooks
146154

147-
lint: lint-yaml lint-actions lint-md ## Runs all linting commands
155+
lint: lint-yaml lint-actions lint-md lint-ansible ## Runs all linting commands
148156
.PHONY: lint
149157

150158
lint-yaml: ## Lints yaml files inside project
@@ -164,21 +172,9 @@ lint-md-dry: ## Lint all markdown files using markdownlint-cli2 in dry-run mode
164172
.PHONY: lint-md-dry
165173

166174
lint-ansible: ## Lint ansible files inside project
167-
ansible-lint .
175+
@$(ANSIBLE_LINT_RUNNER) . | tee -a $(MAKE_LOGFILE)
168176
.PHONY: lint-ansible
169177

170-
lint-docker: ## Run hadolint linter over dist Dockerfiles
171-
hadolint -V ./dist/base/8.1-cli-alpine/Dockerfile
172-
hadolint -V ./dist/base/8.1-fpm-alpine/Dockerfile
173-
hadolint -V ./dist/base/8.1-supervisord-alpine/Dockerfile
174-
hadolint -V ./dist/base/8.2-cli-alpine/Dockerfile
175-
hadolint -V ./dist/base/8.2-fpm-alpine/Dockerfile
176-
hadolint -V ./dist/base/8.2-supervisord-alpine/Dockerfile
177-
hadolint -V ./dist/base/8.3-cli-alpine/Dockerfile
178-
hadolint -V ./dist/base/8.3-fpm-alpine/Dockerfile
179-
hadolint -V ./dist/base/8.3-supervisord-alpine/Dockerfile
180-
.PHONY: lint-docker
181-
182178
#
183179
# Release
184180
# ------------------------------------------------------------------------------------

src/playbook.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
---
22

3-
- hosts: all
3+
- name: Generate PHP Dockerfiles
4+
hosts: all
45
gather_facts: false
56
tags:
67
- template
78
tasks:
8-
- import_tasks: roles/base/main.yml
9+
- name: Create dist for all supported PHP versions
10+
ansible.builtin.import_tasks: roles/base/main.yml
911

1012
...

src/roles/base/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
src: "{{ item.src }}"
5252
dest: "{{ item.dst }}"
5353
force: true
54-
mode: 0644
54+
mode: "0644"
5555
with_items:
5656
- "{{ tpl_fpm_configs }}"
5757

@@ -61,7 +61,7 @@
6161
src: "{{ item.src }}"
6262
dest: "{{ item.dst }}"
6363
force: true
64-
mode: 0644
64+
mode: "0644"
6565
with_items:
6666
- "{{ tpl_supervisord_configs }}"
6767

0 commit comments

Comments
 (0)