Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add linting to CI #1174

Merged
merged 5 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/linters/.hadolint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ignored:
- DL3048
- DL3005
- DL3008
- DL3003
- SC2035
37 changes: 37 additions & 0 deletions .github/linters/.markdown-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
default: true

# Line length
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md013
MD013: false

# Inline HTML
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md033
MD033: false

# List indentation
# 2 spaces breaks list formatting in mkdocs
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md007
MD007:
indent: 4

# Fenced code blocks should have a language specified
# We use a second, un-languaged code block to denote the output
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md040
MD040: false

# Blank line inside blockquote
# This is typically done when a section has a "New as of" or "Warning" in addition to a note
# May wish to take advantage of github-style admonitions
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md028
MD028: false

# No duplicate headers
# HISTORY.md has a ton of these
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md024
MD024: false

# First line h1
# The issue template doesn't have one
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md041
MD041: false
8 changes: 8 additions & 0 deletions .github/linters/.yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
extends: default

rules:
line-length: disable

ignore:
- plugins/scheduler-k3s/templates/*
80 changes: 80 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
name: "lint"

# yamllint disable-line rule:truthy
on:
pull_request:
branches:
- "*"
push:
branches:
- "master"

concurrency:
group: lint-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
hadolint:
name: hadolint
runs-on: ubuntu-22.04
steps:
- name: Clone
uses: actions/checkout@v4
- name: Run hadolint
uses: hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf
with:
config: .github/linters/.hadolint.yml

markdown-lint:
name: markdown-lint
runs-on: ubuntu-22.04
steps:
- name: Clone
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: ".github/workflows/lint.yml"
- name: Install markdownlint-cli
run: npm install -g markdownlint-cli@0.35.0
- name: Run markdown-lint
run: markdownlint -c .github/linters/.markdown-lint.yml *.md **/*.md

shellcheck:
name: shellcheck
runs-on: ubuntu-22.04
steps:
- name: Clone
uses: actions/checkout@v4
- name: Run shellcheck
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38
with:
ignore_paths: >-
./tests/unit/fixtures/.profile.d/app.sh

shfmt:
name: shfmt
runs-on: ubuntu-22.04
steps:
- name: Clone
uses: actions/checkout@v4
- name: Run shfmt
uses: luizm/action-sh-checker@c6edb3de93e904488b413636d96c6a56e3ad671a
env:
SHFMT_OPTS: -l -bn -ci -i 2 -d
with:
sh_checker_shellcheck_disable: true

yamllint:
name: yamllint
runs-on: ubuntu-22.04
steps:
- name: Clone
uses: actions/checkout@v4
- name: Run yamllint
uses: ibiqlik/action-yamllint@2576378a8e339169678f9939646ee3ee325e845c
with:
config_file: ".github/linters/.yamllint.yml"
3 changes: 0 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ jobs:
- name: shellcheck
run: make shellcheck

- name: lint
run: make lint

- name: install requirements
run: make deps fpm package_cloud

Expand Down
7 changes: 7 additions & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
disable=SC2128
disable=SC1091
disable=SC2002
disable=SC2294
disable=SC2034
disable=SC2031
disable=SC2030
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ All notable changes to this project will be documented in this file.

- @michaelshobbs remove erlang from buildpack bundle

**NOTE: v0.4.0 is now based on heroku-16**
> NOTE: v0.4.0 is now based on heroku-16

## [0.3.36](https://github.com/gliderlabs/herokuish/compare/v0.3.35...v0.3.36) - 2018-03-10

Expand All @@ -890,7 +890,7 @@ All notable changes to this project will be documented in this file.
- @michaelshobbs Update nodejs to version v121
- @michaelshobbs Update go to version v85

**NOTE: This will be the last version of herokuish based on cedar-14**
> NOTE: This will be the last version of herokuish based on cedar-14

## [0.3.35](https://github.com/gliderlabs/herokuish/compare/v0.3.34...v0.3.35) - 2018-02-09

Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ARG STACK_VERSION=20

FROM golang:1.22 AS builder
RUN mkdir /src
ADD . /src/
COPY . /src/
WORKDIR /src

ARG VERSION
Expand All @@ -15,7 +15,7 @@ ARG TARGETARCH

ADD https://raw.githubusercontent.com/heroku/stack-images/main/heroku-${STACK_VERSION}/setup.sh /tmp/setup-01.sh
ADD https://raw.githubusercontent.com/heroku/stack-images/main/heroku-${STACK_VERSION}-build/setup.sh /tmp/setup-02.sh
ADD bin/setup.sh /tmp/setup.sh
COPY bin/setup.sh /tmp/setup.sh
RUN --mount=source=build-deps/${STACK_VERSION},target=/build STACK_VERSION=${STACK_VERSION} TARGETARCH=${TARGETARCH} /tmp/setup.sh && \
rm -rf /tmp/setup.sh

Expand All @@ -24,9 +24,9 @@ ENV DEBIAN_FRONTEND noninteractive
LABEL com.gliderlabs.herokuish/stack=$STACK

RUN apt-get update -qq \
&& apt-get install -qq -y daemontools \
&& apt-get install --no-install-recommends -qq -y daemontools \
&& cp /etc/ImageMagick-6/policy.xml /etc/ImageMagick-6/policy.xml.custom \
&& apt-get -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confnew \
&& apt-get -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confnew \
--allow-downgrades \
--allow-remove-essential \
--allow-change-held-packages \
Expand Down
12 changes: 0 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,6 @@ ci-report:
ruby -v
rm -f ~/.gitconfig

lint:
# SC2002: Useless cat - https://github.com/koalaman/shellcheck/wiki/SC2002
# SC2030: Modification of name is local - https://github.com/koalaman/shellcheck/wiki/SC2030
# SC2031: Modification of name is local - https://github.com/koalaman/shellcheck/wiki/SC2031
# SC2034: VAR appears unused - https://github.com/koalaman/shellcheck/wiki/SC2034
# SC2206: Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.
# SC2001: See if you can use ${variable//search/replace} instead.
# SC2231: Quote expansions in this for loop glob to prevent wordsplitting, e.g. "$dir"/*.txt .
# SC2230: which is non-standard. Use builtin 'command -v' instead.
@echo linting...
shellcheck -e SC2002,SC2030,SC2031,SC2034,SC2206,SC2001,SC2231,SC2230 -s bash include/*.bash tests/**/tests.sh

release: build/rpm/$(NAME)-$(VERSION)-1.x86_64.rpm build/deb/$(NAME)_$(VERSION)_all.deb bin/gh-release bin/gh-release-body
ls -lah build build/* || true
chmod +x build/linux/$(NAME) build/darwin/$(NAME)
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ For example, build processes that produce Docker images without producing interm
`herokuish exec` will by default drop root privileges through use of [setuidgid](https://cr.yp.to/daemontools/setuidgid.html),
but if already running as a non-root user setuidgid will fail, you can opt-out from this by setting the env-var `HEROKUISH_SETUIDGUID=false`.

#### Buildpacks
### Buildpacks

Herokuish does not come with any buildpacks, but it is tested against recent versions of Heroku supported buildpacks. You can see this information with `herokuish version`. Example output:

Expand All @@ -78,7 +78,7 @@ buildpacks:

You can install all supported buildpacks with `herokuish buildpack install`, or you can manually install buildpacks individually with `herokuish buildpack install <url> [committish]`. You can also mount a directory containing your platform's supported buildpacks (see Paths, next section), or you could bake your supported buildpacks into an image. These are the types of decisions that are up to you.

#### Paths
### Paths

Use `herokuish paths` to see relevant system paths it uses. You can use these to import or mount data for use inside a container. They can also be overridden by setting the appropriate environment variable.

Expand All @@ -93,11 +93,11 @@ BUILDPACK_PATH=/tmp/buildpacks # Path to installed buildpacks

```

#### Entrypoints
### Entrypoints

Some subcommands are made to be used as default commands or entrypoint commands for containers. Specifically, herokuish detects if it was called as `/start`, `/exec`, or `/build` which will shortcut it to running those subcommands directly. This means you can either install the binary in those locations or create symlinks from those locations, allowing you to use them as your container entrypoint.

#### Help
### Help

Don't be afraid of the help command. It actually tells you exactly what a command does:

Expand Down Expand Up @@ -128,7 +128,7 @@ Having trouble pushing an app to Dokku or Heroku? Use Herokuish with a local Doc
instance to debug. This is especially helpful with Dokku to help determine if it's a buildpack
issue or an issue with Dokku. Buildpack issues should be filed against Herokuish.

#### Running an app against Herokuish
### Running an app against Herokuish

```shell
docker run --rm -v /abs/app/path:/tmp/app gliderlabs/herokuish /bin/herokuish test
Expand All @@ -147,7 +147,7 @@ Mounting your local app source directory to `/tmp/app` and running `/bin/herokui

You can use this output when you submit issues.

#### Running an app tests using Heroku buildpacks
### Running an app tests using Heroku buildpacks

```shell
docker run --rm -v /abs/app/path:/tmp/app gliderlabs/herokuish /bin/herokuish buildpack test
Expand Down Expand Up @@ -175,7 +175,7 @@ docker run --platform linux/amd64 --rm -v /abs/app/path:/tmp/app gliderlabs/hero

However, there is a risk of compatibility issues when running on a different platform than the one you are developing on. If you are getting strange compilation or segfaults, try running the build process on an x86 platform.

#### Troubleshooting
## Troubleshooting

If you run into an issue and looking for more insight into what `herokuish` is doing, you can set the `$TRACE` environment variable.

Expand Down
8 changes: 5 additions & 3 deletions buildpacks/buildpack-clojure/tests/clojure-ring/test.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
source "$(dirname $BASH_SOURCE)/../../../test"
app-test "$(basename $(dirname $BASH_SOURCE))"
buildpack-test "$(basename $(dirname $BASH_SOURCE))"
# shellcheck shell=bash

source "$(dirname "$BASH_SOURCE")/../../../test"
app-test "$(basename "$(dirname "$BASH_SOURCE")")"
buildpack-test "$(basename "$(dirname "$BASH_SOURCE")")"
6 changes: 4 additions & 2 deletions buildpacks/buildpack-go/tests/go/test.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
source "$(dirname $BASH_SOURCE)/../../../test"
app-test "$(basename $(dirname $BASH_SOURCE))"
# shellcheck shell=bash

source "$(dirname "$BASH_SOURCE")/../../../test"
app-test "$(basename "$(dirname "$BASH_SOURCE")")"
6 changes: 4 additions & 2 deletions buildpacks/buildpack-gradle/tests/gradle/test.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
source "$(dirname $BASH_SOURCE)/../../../test"
app-test "$(basename $(dirname $BASH_SOURCE))"
# shellcheck shell=bash

source "$(dirname "$BASH_SOURCE")/../../../test"
app-test "$(basename "$(dirname "$BASH_SOURCE")")"
6 changes: 4 additions & 2 deletions buildpacks/buildpack-java/tests/java-jetty/test.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
source "$(dirname $BASH_SOURCE)/../../../test"
app-test "$(basename $(dirname $BASH_SOURCE))"
# shellcheck shell=bash

source "$(dirname "$BASH_SOURCE")/../../../test"
app-test "$(basename "$(dirname "$BASH_SOURCE")")"
6 changes: 4 additions & 2 deletions buildpacks/buildpack-multi/tests/multi/test.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
source "$(dirname $BASH_SOURCE)/../../../test"
app-test "$(basename $(dirname $BASH_SOURCE))"
# shellcheck shell=bash

source "$(dirname "$BASH_SOURCE")/../../../test"
app-test "$(basename "$(dirname "$BASH_SOURCE")")"
6 changes: 4 additions & 2 deletions buildpacks/buildpack-nodejs/tests/nodejs-express/test.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
source "$(dirname $BASH_SOURCE)/../../../test"
app-test "$(basename $(dirname $BASH_SOURCE))"
# shellcheck shell=bash

source "$(dirname "$BASH_SOURCE")/../../../test"
app-test "$(basename "$(dirname "$BASH_SOURCE")")"
6 changes: 4 additions & 2 deletions buildpacks/buildpack-null/tests/null/test.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
source "$(dirname $BASH_SOURCE)/../../../test"
app-test "$(basename $(dirname $BASH_SOURCE))"
# shellcheck shell=bash

source "$(dirname "$BASH_SOURCE")/../../../test"
app-test "$(basename "$(dirname "$BASH_SOURCE")")"
10 changes: 5 additions & 5 deletions buildpacks/buildpack-php/tests/php/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ This application supports the [Getting Started with PHP on Heroku](https://devce
Install the [Heroku Toolbelt](https://toolbelt.heroku.com/).

```sh
$ git clone git@github.com:heroku/php-getting-started.git # or clone your own fork
$ cd php-getting-started
$ heroku create
$ git push heroku main
$ heroku open
git clone git@github.com:heroku/php-getting-started.git # or clone your own fork
cd php-getting-started
heroku create
git push heroku main
heroku open
```

or
Expand Down
6 changes: 4 additions & 2 deletions buildpacks/buildpack-play/tests/play/test.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
source "$(dirname $BASH_SOURCE)/../../../test"
app-test "$(basename $(dirname $BASH_SOURCE))"
# shellcheck shell=bash

source "$(dirname "$BASH_SOURCE")/../../../test"
app-test "$(basename "$(dirname "$BASH_SOURCE")")"
6 changes: 4 additions & 2 deletions buildpacks/buildpack-python/tests/python-django/test.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
source "$(dirname $BASH_SOURCE)/../../../test"
app-test "$(basename $(dirname $BASH_SOURCE))"
# shellcheck shell=bash

source "$(dirname "$BASH_SOURCE")/../../../test"
app-test "$(basename "$(dirname "$BASH_SOURCE")")"
6 changes: 4 additions & 2 deletions buildpacks/buildpack-python/tests/python-flask/test.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
source "$(dirname $BASH_SOURCE)/../../../test"
app-test "$(basename $(dirname $BASH_SOURCE))"
# shellcheck shell=bash

source "$(dirname "$BASH_SOURCE")/../../../test"
app-test "$(basename "$(dirname "$BASH_SOURCE")")"
8 changes: 5 additions & 3 deletions buildpacks/buildpack-ruby/tests/ruby-sinatra/test.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
source "$(dirname $BASH_SOURCE)/../../../test"
app-test "$(basename $(dirname $BASH_SOURCE))"
buildpack-test "$(basename $(dirname $BASH_SOURCE))"
# shellcheck shell=bash

source "$(dirname "$BASH_SOURCE")/../../../test"
app-test "$(basename "$(dirname "$BASH_SOURCE")")"
buildpack-test "$(basename "$(dirname "$BASH_SOURCE")")"
6 changes: 4 additions & 2 deletions buildpacks/buildpack-scala/tests/scala/test.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
source "$(dirname $BASH_SOURCE)/../../../test"
app-test "$(basename $(dirname $BASH_SOURCE))"
# shellcheck shell=bash

source "$(dirname "$BASH_SOURCE")/../../../test"
app-test "$(basename "$(dirname "$BASH_SOURCE")")"
6 changes: 4 additions & 2 deletions buildpacks/buildpack-static/tests/static/test.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
source "$(dirname $BASH_SOURCE)/../../../test"
app-test "$(basename $(dirname $BASH_SOURCE))"
# shellcheck shell=bash

source "$(dirname "$BASH_SOURCE")/../../../test"
app-test "$(basename "$(dirname "$BASH_SOURCE")")"
Loading
Loading