Skip to content

Commit 7469756

Browse files
authored
Merge pull request #56 from dokku-community/lint-ci
ci: add linting to ci
2 parents 16fab88 + 33d5bee commit 7469756

11 files changed

+175
-21
lines changed

.editorconfig

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
root = true
2+
3+
[*]
4+
insert_final_newline = true
5+
indent_style = space
6+
indent_size = 2
7+
8+
[Makefile]
9+
insert_final_newline = true
10+
indent_style = tab
11+
indent_size = 4
12+
13+
[*.mk]
14+
insert_final_newline = true
15+
indent_style = tab
16+
indent_size = 4
17+
18+
[*.{go,mod}]
19+
insert_final_newline = true
20+
indent_style = tab
21+
indent_size = 4
22+
23+
[*.md]
24+
tab_width = 4

.github/dependabot.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
version: 2
3+
updates:
4+
- package-ecosystem: github-actions
5+
directory: "/"
6+
schedule:
7+
interval: daily
8+
open-pull-requests-limit: 10
9+
labels:
10+
- "type: dependencies"

.github/linters/.markdown-lint.yaml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
default: true
3+
4+
# Line length
5+
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md013
6+
MD013: false
7+
8+
# Inline HTML
9+
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md033
10+
MD033: false
11+
12+
# List indentation
13+
# 2 spaces breaks list formatting in mkdocs
14+
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md007
15+
MD007:
16+
indent: 4
17+
18+
# Fenced code blocks should have a language specified
19+
# We use a second, un-languaged code block to denote the output
20+
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md040
21+
MD040: false
22+
23+
# Blank line inside blockquote
24+
# This is typically done when a section has a "New as of" or "Warning" in addition to a note
25+
# May wish to take advantage of github-style admonitions
26+
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md028
27+
MD028: false
28+
29+
# No duplicate headers
30+
# HISTORY.md has a ton of these
31+
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md024
32+
MD024: false
33+
34+
# First line h1
35+
# The issue template doesn't have one
36+
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md041
37+
MD041: false

.github/linters/.yamllint.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
extends: default
3+
4+
rules:
5+
line-length: disable
6+
7+
ignore:
8+
- plugins/scheduler-k3s/templates/*

.github/workflows/lint.yaml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
name: "lint"
3+
4+
# yamllint disable-line rule:truthy
5+
on:
6+
pull_request:
7+
branches:
8+
- "*"
9+
push:
10+
branches:
11+
- "master"
12+
13+
concurrency:
14+
group: lint-${{ github.event.pull_request.number || github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
markdown-lint:
19+
name: markdown-lint
20+
runs-on: ubuntu-24.04
21+
steps:
22+
- name: Clone
23+
uses: actions/checkout@v4
24+
- name: Setup node
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: "20"
28+
cache: "npm"
29+
cache-dependency-path: ".github/workflows/lint.yaml"
30+
- name: Install markdownlint-cli
31+
run: npm install -g [email protected]
32+
- name: Run markdown-lint
33+
run: markdownlint -c .github/linters/.markdown-lint.yaml *.md **/*.md
34+
35+
shellcheck:
36+
name: shellcheck
37+
runs-on: ubuntu-24.04
38+
steps:
39+
- name: Clone
40+
uses: actions/checkout@v4
41+
- name: Run shellcheck
42+
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # 2.0.0
43+
44+
shfmt:
45+
name: shfmt
46+
runs-on: ubuntu-24.04
47+
steps:
48+
- name: Clone
49+
uses: actions/checkout@v4
50+
- name: Run shfmt
51+
uses: luizm/action-sh-checker@17bd25a6ee188d2b91f677060038f4ba37ba14b2 # v0.9.0
52+
env:
53+
SHFMT_OPTS: -l -bn -ci -i 2 -d
54+
with:
55+
sh_checker_shellcheck_disable: true
56+
57+
yamllint:
58+
name: yamllint
59+
runs-on: ubuntu-24.04
60+
steps:
61+
- name: Clone
62+
uses: actions/checkout@v4
63+
- name: Run yamllint
64+
uses: ibiqlik/action-yamllint@2576378a8e339169678f9939646ee3ee325e845c # v3.1.1
65+
with:
66+
config_file: ".github/linters/.yamllint.yaml"

.shellcheckrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# SC1091 - Not following: FILE: does not exist (No such file or directory) - <https://github.com/koalaman/shellcheck/wiki/SC1091>
2+
disable=SC1091

README.md

+14-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
dokku-apt
2-
=========
1+
# dokku-apt
32

43
Inject deb packages into dokku based on files in project.
54

@@ -48,7 +47,7 @@ A config file for apt, as documented [here](https://linux.die.net/man/5/apt.conf
4847

4948
Example
5049

51-
```
50+
```shell
5251
Acquire::http::Proxy "http://user:[email protected]:8888/";
5352
```
5453

@@ -58,7 +57,7 @@ A file that can contain environment variables. Note that this is sourced, and sh
5857

5958
Example
6059

61-
```
60+
```shell
6261
export ACCEPT_EULA=y
6362
```
6463

@@ -72,7 +71,7 @@ Requires an empty line at end of file.
7271

7372
Example
7473

75-
```
74+
```shell
7675
https://packages.microsoft.com/keys/microsoft.asc
7776
```
7877

@@ -82,7 +81,7 @@ A file that contains [APT Preferences](https://wiki.debian.org/AptPreferences).
8281

8382
Example:
8483

85-
```
84+
```shell
8685
APT {
8786
Install-Recommends "false";
8887
}
@@ -93,7 +92,8 @@ APT {
9392
Overrides the `/etc/apt/sources.list` file. An empty file may be provided in order to remove upstream packages.
9493

9594
Example:
96-
```
95+
96+
```shell
9797
deb http://archive.ubuntu.com/ubuntu/ bionic main universe
9898
deb http://archive.ubuntu.com/ubuntu/ bionic-security main universe
9999
deb http://archive.ubuntu.com/ubuntu/ bionic-updates main universe
@@ -107,18 +107,19 @@ This file should contain apt packages to install, accepts multiple packages per
107107
If this file is included, an `apt-get update` is triggered beforehand.
108108

109109
Example:
110-
```
110+
111+
```shell
111112
nginx
112113
unifont
113114
```
114115

115116
#### Specifying package versions
116117

117-
You can specify a package version with '=1.2.3' after the package name.
118+
You can specify a package version with '=1.2.3' after the package name.
118119

119120
Example:
120121

121-
```
122+
```shell
122123
libgd2-dev=2.1.1
123124
```
124125

@@ -132,7 +133,7 @@ Requires an empty line at end of file.
132133

133134
Example:
134135

135-
```
136+
```shell
136137
ppa:nginx/stable
137138
deb http://archive.ubuntu.com/ubuntu quantal multiverse
138139
```
@@ -144,7 +145,7 @@ Requires an empty line at end of file.
144145

145146
Example:
146147

147-
```
148+
```shell
148149
ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true
149150
```
150151
@@ -158,7 +159,7 @@ Packages are installed in lexicographical order. As such, if any packages depend
158159
159160
Example:
160161
161-
```
162+
```shell
162163
$ ls dpkg-packages/
163164
your-package-0_0.0.1.deb
164165
```

builder-create-dokku-image

+7-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ source "$PLUGIN_AVAILABLE_PATH/apt/internal-functions"
77

88
hook-apt-builder-create-dokku-image() {
99
declare BUILDER_TYPE="$1" APP="$2" SOURCECODE_WORK_DIR="$3" DOKKU_IMAGE="$4"
10-
local IMAGE="dokku/$APP" DIR=/tmp/apt
10+
local IMAGE="dokku/$APP"
1111
local COMMAND CONTENT_SHA DOCKER_COMMIT_LABEL_ARGS DOCKER_RUN_LABEL_ARGS
12+
local TMP_WORK_DIR DOCKER_ARGS
1213

1314
if [[ -d "$SOURCECODE_WORK_DIR/dpkg-packages" ]]; then
1415
dokku_log_info1 "Rebuilding extended app image due to dpkg-packages usage"
@@ -20,7 +21,8 @@ hook-apt-builder-create-dokku-image() {
2021
return
2122
fi
2223

23-
local TMP_WORK_DIR=$(mktemp -d "/tmp/dokku-${DOKKU_PID}-${FUNCNAME[0]}.XXXXXX")
24+
TMP_WORK_DIR=$(mktemp -d "/tmp/dokku-${DOKKU_PID}-${FUNCNAME[0]}.XXXXXX")
25+
# shellcheck disable=SC2064
2426
trap "rm -rf '$TMP_WORK_DIR' >/dev/null" RETURN
2527
fn-apt-populate-work-dir "$SOURCECODE_WORK_DIR" "$TMP_WORK_DIR"
2628

@@ -32,6 +34,7 @@ hook-apt-builder-create-dokku-image() {
3234

3335
dokku_log_info1 "Creating extended app image with custom system packages"
3436
pushd "$TMP_WORK_DIR" >/dev/null
37+
# shellcheck disable=SC2086
3538
CID=$(tar -c . | "$DOCKER_BIN" container run "${DOCKER_RUN_LABEL_ARGS[@]}" $DOKKU_GLOBAL_RUN_ARGS -i -a stdin "$DOKKU_IMAGE" /bin/bash -c "mkdir -p /tmp/apt && tar -xC /tmp/apt")
3639
popd >/dev/null
3740
if test "$("$DOCKER_BIN" container wait "$CID")" -ne 0; then
@@ -43,12 +46,13 @@ hook-apt-builder-create-dokku-image() {
4346
"$DOCKER_BIN" container commit "${DOCKER_COMMIT_LABEL_ARGS[@]}" "$CID" "$IMAGE:apt" >/dev/null
4447
"$DOCKER_BIN" container rm "$CID" &>/dev/null || true
4548

46-
local DOCKER_ARGS=$(: | plugn trigger docker-args-build "$APP" "$BUILDER_TYPE")
49+
DOCKER_ARGS=$(: | plugn trigger docker-args-build "$APP" "$BUILDER_TYPE")
4750
declare -a ARG_ARRAY
4851
eval "ARG_ARRAY=($DOCKER_ARGS)"
4952

5053
COMMAND="$(fn-apt-command "$APP" "$DOKKU_IMAGE" "/tmp/apt")"
5154
DOCKER_RUN_LABEL_ARGS="--label=com.dokku.app-name=$APP"
55+
# shellcheck disable=SC2086
5256
CID=$("$DOCKER_BIN" container run "${DOCKER_RUN_LABEL_ARGS[@]}" $DOKKU_GLOBAL_RUN_ARGS -d "${ARG_ARRAY[@]}" "$IMAGE:apt" /bin/bash -e -c "$COMMAND")
5357

5458
"$DOCKER_BIN" container attach "$CID"

builder-dokku-image

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export DOCKER_BIN=${DOCKER_BIN:="docker"}
55
source "$PLUGIN_AVAILABLE_PATH/apt/internal-functions"
66

77
hook-apt-builder-dokku-image() {
8+
# shellcheck disable=SC2034
89
declare BUILDER_TYPE="$1" APP="$2" SOURCECODE_WORK_DIR="$3" DOKKU_IMAGE="$4"
910
local IMAGE="dokku/$APP"
1011
local CONTENT_SHA

internal-functions

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ fn-clean-extended-app-images() {
99
local images
1010

1111
# remove dangling extended app images
12+
# shellcheck disable=SC2046
1213
"$DOCKER_BIN" image rm $("$DOCKER_BIN" image ls --format 'dangling=true' --format "label=com.dokku.app-name=sha-$APP" --quiet) &>/dev/null || true
1314

1415
images="$("$DOCKER_BIN" image ls --filter "label=com.dokku.app-name=sha-$APP" --quiet)"
@@ -21,7 +22,7 @@ fn-clean-extended-app-images() {
2122

2223
fn-apt-fetch-sha() {
2324
declare SOURCECODE_WORK_DIR="$1" DOKKU_IMAGE="$2"
24-
local APT_FILES CONTENT INJECT_PACKAGES file
25+
local APT_FILES CONTENT INJECT_PACKAGES file file_contents
2526

2627
if [[ -d "$SOURCECODE_WORK_DIR/dpkg-packages" ]]; then
2728
return
@@ -31,7 +32,7 @@ fn-apt-fetch-sha() {
3132
for file in "${APT_FILES[@]}"; do
3233
if [[ -f "$SOURCECODE_WORK_DIR/$file" ]]; then
3334
INJECT_PACKAGES=true
34-
local file_contents=$(<$SOURCECODE_WORK_DIR/$file)
35+
file_contents="$(<"$SOURCECODE_WORK_DIR/$file")"
3536
CONTENT="${CONTENT}\n${file}\n${file_contents}"
3637
fi
3738
done
@@ -43,7 +44,7 @@ fn-apt-fetch-sha() {
4344
local image_digest
4445
image_digest="$("$DOCKER_BIN" image inspect --format='{{index .RepoDigests 0}}' "$DOKKU_IMAGE" 2>/dev/null || echo "$DOKKU_IMAGE")"
4546

46-
echo -n "$(<$PLUGIN_AVAILABLE_PATH/apt/plugin.toml)${image_digest}${CONTENT}" | sha256sum | cut -d " " -f 1
47+
echo -n "$(<"$PLUGIN_AVAILABLE_PATH/apt/plugin.toml")${image_digest}${CONTENT}" | sha256sum | cut -d " " -f 1
4748
}
4849

4950
fn-apt-populate-work-dir() {

pre-build

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ source "$PLUGIN_AVAILABLE_PATH/apt/internal-functions"
88
hook-apt-pre-build() {
99
declare BUILDER_TYPE="$1" APP="$2" SOURCECODE_WORK_DIR="$3"
1010
local IMAGE="dokku/$APP" DIR=/app
11-
local CID COMMAND DOCKER_COMMIT_LABEL_ARGS
11+
local CID COMMAND DOCKER_COMMIT_LABEL_ARGS DOCKER_ARGS
1212
# This trigger is only called with apps using buildpacks, so it's safe to assume this:
1313
local BUILDER_TYPE=herokuish
1414

@@ -24,7 +24,7 @@ hook-apt-pre-build() {
2424
popd >/dev/null
2525
fi
2626

27-
local DOCKER_ARGS=$(: | plugn trigger docker-args-build "$APP" "$BUILDER_TYPE")
27+
DOCKER_ARGS=$(: | plugn trigger docker-args-build "$APP" "$BUILDER_TYPE")
2828
declare -a ARG_ARRAY
2929
eval "ARG_ARRAY=($DOCKER_ARGS)"
3030

0 commit comments

Comments
 (0)