-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
51 lines (47 loc) · 1.59 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Chronologically specify the pipeline stages to run
stages:
- permissions
- lint
# Relevant for scripts that are cloned here to be run e.g. when building an image
Ensure execute permissions:
stage: permissions
image: alpine
before_script:
- apk add fd
- printf 'Ensuring executable permissions on all files:'
script:
- |+
for fperm in $(fd . ${CI_PROJECT_DIR} --type f --exec stat -c %a); do
if [ "$fperm" != "755" ] && [ "$fperm" != "777" ]; then
printf "%s\n" "At least one file does not have execute permissions. Specifically it had the permission: $fperm" \
"All files in this repo should have 755/777 permissions, because they're being cloned and executed."
exit 1
fi
done
# Common settings for linters to avoid code repetition
# Needs can be used to specify dependencies
# Allow failure is whether the pipeline succeeds on failure or not
.lint-default: &lint-default
stage: lint
needs: []
services: []
allow_failure: false
Lint shell scripts:
<<: *lint-default
image: koalaman/shellcheck-alpine:latest
before_script:
- apk add fd
script:
- printf 'Running shellcheck:'
- printf '%s\n' 'https://github.com/koalaman/shellcheck/wiki/Checks'
- fd --extension sh --exec shellcheck
# Keep the python version in sync with what's in production
# Consider using black instead?
Lint python scripts:
<<: *lint-default
image: python:3.10-alpine
before_script:
- apk add --no-cache --virtual .deps gcc musl-dev
- pip install black
script:
- black --check --diff --exclude=migrations .