forked from SlackBuildsOrg/slackbuilds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
88 lines (72 loc) · 3.24 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
variables:
FF_DISABLE_UMASK_FOR_DOCKER_EXECUTOR: "true"
# renovate: datasource=gitlab-releases depName=gitlab-org/cli
GLAB_VERSION: 1.47.0
# renovate: datasource=docker depName=aclemons/sbo-maintainer-tools versioning=loose
SBO_MAINTAINER_TOOLS_IMAGE: aclemons/sbo-maintainer-tools:0.9.3-15.0@sha256:570ccd359aafa3df56d3316dc1f8206a1902c1e53829cf2e70dde9e8b6fc93d3
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
default:
image: docker:27.3.1@sha256:8d5039800a368057d99fc0a75167d80f345ac8650850509adc7fe25c64cba9dd
services:
- docker:27.3.1-dind@sha256:8d5039800a368057d99fc0a75167d80f345ac8650850509adc7fe25c64cba9dd
pr-checks:
script: |
set -e
set -o pipefail
apk add git
wget --quiet "https://gitlab.com/gitlab-org/cli/-/releases/v$GLAB_VERSION/downloads/glab_""$GLAB_VERSION""_Linux_x86_64.tar.gz"
tar -xf "glab_""$GLAB_VERSION""_Linux_x86_64.tar.gz" bin/glab
chmod 0755 bin/glab
mv bin/glab /usr/local/bin
rm -rf bin
docker pull "$SBO_MAINTAINER_TOOLS_IMAGE"
git diff-tree --name-only --diff-filter=d --no-commit-id -r $CI_MERGE_REQUEST_DIFF_BASE_SHA $CI_COMMIT_SHA | sed '/^\./d' | sed -n '/[^\/][^\/]*\/[^\/][^\/]*\//p' | xargs -I xx dirname xx | sort -u | while read -r project ; do
mkfifo pipe
tee sbolint-output < pipe &
exec 3>pipe
set +e
docker run --rm -v "$(pwd):/work" -w /work "$SBO_MAINTAINER_TOOLS_IMAGE" sbolint "$project" >&3 2>&1
sbolint_status="$?"
set -e
exec 3>&-
rm pipe
{
if [[ "$sbolint_status" -eq 0 ]] ; then
printf '#### ✅ sbolint - %s\n\n' "$project ✅"
else
printf '#### ⛔️ sbolint - %s\n\n' "$project ⛔️"
fi
printf '```\n'
cat sbolint-output
rm sbolint-output
printf '```\n'
} > comment-output
if [ -z "$MR_AUTOMATION_TOKEN" ] ; then
printf 'No token available for MR comments\n'
cat comment-output
else
# $CI_PROJECT_PATH points to the fork
GITLAB_TOKEN="$MR_AUTOMATION_TOKEN" glab mr --repo "SlackBuilds.org/slackbuilds" comment $(echo "$CI_OPEN_MERGE_REQUESTS" | cut -d '!' -f2) --unique=true --message "$(cat comment-output)"
fi
done
git diff-tree --name-only --diff-filter=d --no-commit-id -r $CI_MERGE_REQUEST_DIFF_BASE_SHA $CI_COMMIT_SHA | sed '/^\./d' | sed -n '/[^\/][^\/]*\/[^\/][^\/]*\//p' | xargs -I xx dirname xx | sort -u | while read -r project ; do
short_project="$(printf '%s\n' "$project" | cut -d/ -f2)"
response="$(wget -q -O - "https://slackbuilds.org/revdeps.php?q=$short_project" | sort)"
{
printf '#### reverse dependencies - %s\n\n' "$project"
if [[ "$response" == "" ]] ; then
printf 'None\n'
else
printf '%s\n' "$response" | sort | sed 's/^/- [ ] /'
fi
} > comment-output
if [ -z "$MR_AUTOMATION_TOKEN" ] ; then
printf 'No token available for MR comments\n'
cat comment-output
else
# $CI_PROJECT_PATH points to the fork
GITLAB_TOKEN="$MR_AUTOMATION_TOKEN" glab mr --repo "SlackBuilds.org/slackbuilds" comment $(echo "$CI_OPEN_MERGE_REQUESTS" | cut -d '!' -f2) --unique=true --message "$(cat comment-output)"
fi
done