Commit 18f91a39 authored by Kevin Daudt's avatar Kevin Daudt

merge: create docker image with lint tools included

See merge request !1
parents 314aa1a4 cbe79fdf
Pipeline #152 passed with stages
in 52 seconds
image: alpinelinux/docker-cli:latest
stages:
- build
- upload
build:
stage: build
tags:
- docker-alpine
- x86_64
script:
- docker build -t $CI_PROJECT_NAME:latest .
upload:
stage: upload
before_script:
- docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
only:
- master
script:
- docker-push-image $CI_PROJECT_NAME:latest $DOCKER_NAMESPACE/$CI_PROJECT_NAME:latest
FROM alpine:edge
RUN apk add --no-cache abuild atools spdx-licenses-list shellcheck git \
&& adduser -D lint
COPY overlay/ /
USER lint
CMD changed-aports master | lint
# apkbuild-lint-tools
Docker container with the necessary linting tools for verifying APKBUILD files
\ No newline at end of file
Docker container with the necessary linting tools for verifying APKBUILD files
## Tools
* **[atools](https://gitlab.alpinelinux.org/Leo/atools)** - Contains `apkbuild-lint`
for general codestyle linting
* **[shellcheck](https://www.shellcheck.net/)** - A generic shell script linter,
warning against common issues in shell scripts. Note that by default it's
too strict for APKBUILD files.
* **apkbuild-shellcheck** - A wrapper script to use shellcheck on APKBUILD
files. It uses a shim file that defines variabes normally defined by abuild
and 'uses' them so that shellcheck does not warn about them, while still
warning about other variables. It also disables some checks that are not
applicable for APKBUILDs.
## Auxilary scripts
* **changed-aports** - Returns a list of changed APKBUILD files in a certain
branch, give a base branch: `changed-aports <basebranch>`.
#!/bin/sh
shellcheck -s ash \
-e SC2016 \
-e SC2086 \
-e SC2169 \
-e SC2155 \
-e SC2100 \
-e SC2209 \
-e SC2030 \
-e SC2031 \
-e SC1090 \
-xa /usr/share/abuild/APKBUILD_SHIM
#!/bin/sh
if [ $# -lt 1 ]; then
echo "Usage: $0 <basebranch>"
exit 1
fi
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "Fatal: not inside a git repository"
exit 2
fi
basebranch=$1
if ! git rev-parse --verify --quiet $basebranch >/dev/null; then
# The base branch does not eixst, probably due to a shallow clone
git fetch origin refs/heads/$basebranch:refs/heads/$basebranch
fi
git --no-pager diff --diff-filter=ACMR --name-only $basebranch...HEAD -- "*/APKBUILD" | xargs -n1 dirname
#!/bin/sh
BLUE="\e[34m"
MAGENTA="\e[35m"
RESET="\e[0m"
has_problems=0
while read PKG; do
printf "$BLUE==>$RESET Linting $PKG\n"
(
cd "$PKG"
repo=$(basename $(dirname $PKG));
if [ "$repo" = "main" ]; then
export SKIP_AL1=1
export SKIP_AL13=1
fi
printf "\n\n"
printf "$BLUE"
printf '======================================================\n'
printf " abuild sanitycheck:\n"
printf '======================================================'
printf "$RESET\n\n"
abuild sanitycheck || has_problems=1
printf "\n\n"
printf "$BLUE"
printf '======================================================\n'
printf " apkbuild-shellcheck:\n"
printf '======================================================'
printf "$RESET\n"
apkbuild-shellcheck || has_problems=1
printf "\n\n"
printf "$BLUE"
printf '======================================================\n'
printf " apkbuild-lint:\n"
printf '======================================================'
printf "$RESET\n\n"
apkbuild-lint APKBUILD || has_problems=1
return $has_problems
) || has_problems=1
echo
done
exit $has_problems
#!/bin/sh
set -e
arch=
builddir=
checkdepends=
depends=
depends_dev=
install=
install_if=
ldpath=
license=
makedepends=
md5sums=
options=
pkgbasedir=
pkgdesc=
pkgdir=
pkgname=
pkgrel=
pkgver=
pkggroups=
pkgusers=
provides=
replaces=
sha256sums=
sha512sums=
sonameprefix=
source=
srcdir=
startdir=
subpackages=
subpkgdir=
subpkgname=
url=
# abuild.conf
CFLAGS=
CXXFLAGS=
CPPFLAGS=
LDFLAGS=
JOBS=
MAKEFLAGS=
. ./APKBUILD
: "$arch"
: "$builddir"
: "$checkdepends"
: "$depends"
: "$depends_dev"
: "$install"
: "$install_if"
: "$ldpath"
: "$license"
: "$makedepends"
: "$md5sums"
: "$options"
: "$pkgbasedir"
: "$pkgdesc"
: "$pkgdir"
: "$pkgname"
: "$pkgrel"
: "$pkgver"
: "$pkggroups"
: "$pkgusers"
: "$provides"
: "$replaces"
: "$sha256sums"
: "$sha512sums"
: "$sonameprefix"
: "$source"
: "$srcdir"
: "$startdir"
: "$subpackages"
: "$subpkgdir"
: "$subpkgname"
: "$url"
# abuild.conf
: "$CFLAGS"
: "$CXXFLAGS"
: "$CPPFLAGS"
: "$LDFLAGS"
: "$JOBS"
: "$MAKEFLAGS"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment