Skip to content

Commit b23fd25

Browse files
committed
ci: workflows
1 parent 342d302 commit b23fd25

File tree

5 files changed

+202
-20
lines changed

5 files changed

+202
-20
lines changed

.github/assets/screenshot.png

243 KB
Loading
+85
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

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
3+
on: # yamllint disable-line rule:truthy
4+
workflow_run:
5+
types:
6+
- completed
7+
workflows:
8+
- '🧪 Test Docker images'
9+
10+
name: 📥 Merge pull requests
11+
12+
jobs:
13+
merge:
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 5
16+
if: >
17+
github.event.workflow_run.event == 'pull_request' &&
18+
github.event.workflow_run.conclusion == 'success' &&
19+
(
20+
(github.actor == 'renovate[bot]' &&
21+
startsWith(github.event.workflow_run.head_commit.message, 'deps(deps)')
22+
) ||
23+
(github.actor == 'lotyp' &&
24+
startsWith(github.event.workflow_run.head_commit.message, 'chore(master)')
25+
)
26+
)
27+
steps:
28+
- name: 🙋‍♂️ Request reviewer from @way-finder-bot
29+
uses: wayofdev/gh-actions/actions/github/pull-request/[email protected]
30+
with:
31+
reviewer: 'way-finder-bot'
32+
github-token: "${{ secrets.WAY_FINDER_BOT_TOKEN }}"
33+
34+
- name: 🙋‍♂️ Assign @way-finder-bot
35+
uses: wayofdev/gh-actions/actions/github/pull-request/[email protected]
36+
with:
37+
assignee: 'way-finder-bot'
38+
github-token: "${{ secrets.WAY_FINDER_BOT_TOKEN }}"
39+
40+
- name: ✅ Approve pull request
41+
uses: wayofdev/gh-actions/actions/github/pull-request/[email protected]
42+
with:
43+
github-token: "${{ secrets.WAY_FINDER_BOT_TOKEN }}"

Makefile

+73-19
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
export DOCKER_BUILDKIT ?= 1
55
export COMPOSE_DOCKER_CLI_BUILD ?= 1
66

7+
# Docker binary to use, when executing docker tasks
8+
DOCKER ?= docker
9+
710
IMAGE_NAMESPACE ?= wayofdev/nginx
811
IMAGE_TEMPLATE ?= k8s-alpine
912
IMAGE_TAG ?= $(IMAGE_NAMESPACE):$(IMAGE_TEMPLATE)-latest
@@ -13,6 +16,34 @@ CACHE_FROM ?= $(IMAGE_TAG)
1316
OS ?= $(shell uname)
1417
CURRENT_DIR ?= $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
1518

19+
YAML_CONFIG_PATH ?= .github/.yamllint.yaml
20+
21+
YAML_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \
22+
-v $(PWD):/data \
23+
cytopia/yamllint:latest \
24+
-c $(YAML_CONFIG_PATH) \
25+
-f colored .
26+
27+
ACTION_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \
28+
-v $(shell pwd):/repo \
29+
--workdir /repo \
30+
rhysd/actionlint:latest \
31+
-color
32+
33+
MARKDOWN_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \
34+
-v $(shell pwd):/app \
35+
--workdir /app \
36+
davidanson/markdownlint-cli2-rules:latest \
37+
--config ".github/.markdownlint.json"
38+
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+
46+
#
1647
# Self documenting Makefile code
1748
# ------------------------------------------------------------------------------------
1849
ifneq ($(TERM),)
@@ -36,7 +67,7 @@ else
3667
WHITE := ""
3768
RST := ""
3869
endif
39-
MAKE_LOGFILE = /tmp/docker-nginx.log
70+
MAKE_LOGFILE = /tmp/wayofdev-docker-nginx.log
4071
MAKE_CMD_COLOR := $(BLUE)
4172

4273
default: all
@@ -45,29 +76,31 @@ help: ## Show this menu
4576
@echo 'Management commands for package:'
4677
@echo 'Usage:'
4778
@echo ' ${MAKE_CMD_COLOR}make${RST} Builds default image and then runs dgoss tests'
48-
@grep -E '^[a-zA-Z_0-9%-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " ${MAKE_CMD_COLOR}make %-21s${RST} %s\n", $$1, $$2}'
79+
@grep -E '^[a-zA-Z_0-9%-]+:.*?## .*$$' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf " ${MAKE_CMD_COLOR}make %-21s${RST} %s\n", $$1, $$2}'
4980
@echo
5081
@echo ' 📑 Logs are stored in $(MAKE_LOGFILE)'
5182
@echo
5283
@echo ' 📦 Package docker-nginx (github.com/wayofdev/docker-nginx)'
53-
@echo ' 🤠 Author Andrij Orlenko (github.com/lotyp)'
84+
@echo ' 🤠 Author the dev (github.com/lotyp)'
5485
@echo ' 🏢 ${YELLOW}Org wayofdev (github.com/wayofdev)${RST}'
86+
@echo
5587
.PHONY: help
5688

5789
.EXPORT_ALL_VARIABLES:
5890

91+
#
5992
# Default action
6093
# Defines default command when `make` is executed without additional parameters
6194
# ------------------------------------------------------------------------------------
62-
all: hooks generate build test
95+
all: generate build test
6396
PHONY: all
6497

65-
98+
#
6699
# Docker Actions
67100
# ------------------------------------------------------------------------------------
68101
build: ## Build default docker image
69102
cd $(CURRENT_DIR)$(DOCKERFILE_DIR); \
70-
docker build -t $(IMAGE_TAG) .
103+
$(DOCKER) build -t $(IMAGE_TAG) .
71104
PHONY: build
72105

73106
analyze: ## Analyze docker image
@@ -80,11 +113,6 @@ build-from-cache: ## Build default docker image using cached layers
80113
docker build --cache-from $(CACHE_FROM) . -t $(IMAGE_TAG)
81114
PHONY: build-from-cache
82115

83-
test: ## Run dgoss tests over docker images
84-
set -eux
85-
GOSS_FILES_STRATEGY=cp GOSS_FILES_PATH=$(DOCKERFILE_DIR) dgoss run --add-host app:127.0.0.1 -t $(IMAGE_TAG)
86-
.PHONY: test
87-
88116
pull: ## Pulls docker image from upstream
89117
docker pull $(IMAGE_TAG)
90118
.PHONY: pull
@@ -97,7 +125,7 @@ ssh: ## Login into built image
97125
docker run --rm -it -v $(PWD)/:/opt/docker-nginx $(IMAGE_TAG) sh
98126
.PHONY: ssh
99127

100-
128+
#
101129
# Ansible Actions
102130
# ------------------------------------------------------------------------------------
103131
generate: ## Generates dockerfiles from ansible templates
@@ -108,23 +136,49 @@ clean: ## Cleans up generated files
108136
rm -rf ./dist/*
109137
PHONY: clean
110138

139+
#
140+
# Testing
141+
# ------------------------------------------------------------------------------------
142+
test: ## Run dgoss tests over docker images
143+
set -eux
144+
GOSS_SLEEP="0.4" GOSS_WAIT_OPTS="-r 40s -s 2s > /dev/stdout" GOSS_FILES_STRATEGY=cp GOSS_FILES_PATH=$(DOCKERFILE_DIR) dgoss run --add-host app:127.0.0.1 -t $(IMAGE_TAG)
145+
.PHONY: test
111146

112-
# Code Quality, Git, Linting, Testing
147+
#
148+
# Code Quality, Git, Linting
113149
# ------------------------------------------------------------------------------------
114150
hooks: ## Install git hooks from pre-commit-config
115151
pre-commit install
152+
pre-commit install --hook-type commit-msg
116153
pre-commit autoupdate
117154
.PHONY: hooks
118155

156+
lint: lint-yaml lint-actions lint-md lint-ansible ## Runs all linting commands
157+
.PHONY: lint
158+
119159
lint-yaml: ## Lints yaml files inside project
120-
yamllint .
160+
@$(YAML_LINT_RUNNER) | tee -a $(MAKE_LOGFILE)
121161
.PHONY: lint-yaml
122162

163+
lint-actions: ## Lint all github actions
164+
@$(ACTION_LINT_RUNNER) | tee -a $(MAKE_LOGFILE)
165+
.PHONY: lint-actions
166+
167+
lint-md: ## Lint all markdown files using markdownlint-cli2
168+
@$(MARKDOWN_LINT_RUNNER) --fix "**/*.md" "!CHANGELOG.md" "!app/vendor" "!app/node_modules" | tee -a $(MAKE_LOGFILE)
169+
.PHONY: lint-md
170+
171+
lint-md-dry: ## Lint all markdown files using markdownlint-cli2 in dry-run mode
172+
@$(MARKDOWN_LINT_RUNNER) "**/*.md" "!CHANGELOG.md" "!app/vendor" "!app/node_modules" | tee -a $(MAKE_LOGFILE)
173+
.PHONY: lint-md-dry
174+
123175
lint-ansible: ## Lint ansible files inside project
124-
ansible-lint .
176+
@$(ANSIBLE_LINT_RUNNER) . | tee -a $(MAKE_LOGFILE)
125177
.PHONY: lint-ansible
126178

127-
lint-docker: ## Run hadolint linter over dist Dockerfiles
128-
hadolint -V ./dist/dev-alpine/Dockerfile
129-
hadolint -V ./dist/k8s-alpine/Dockerfile
130-
.PHONY: lint-docker
179+
#
180+
# Release
181+
# ------------------------------------------------------------------------------------
182+
commit: ## Run commitizen to create commit message
183+
czg commit --config="./.github/.cz.config.js"
184+
.PHONY: commit

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
This image is used together with [wayofdev/docker-php-dev](https://github.com/wayofdev/docker-php-dev) and other WOD images, to create local development environment for our projects.
2525

26-
![Screenshot](assets/screenshot.png)
26+
![Screenshot](.github/assets/screenshot.png)
2727

2828
## ⚙️ Development
2929

0 commit comments

Comments
 (0)