Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb3bc8d3

Browse files
authored
Other: Improve check-drone-drift script (grafana#5925)
* Improve check-drone-drift scriptInstead of checking the line count of the current branch an main, run`make drone` and check if there are changes to the target`.drone/drone.yml` file.Signed-off-by: Christian Haudum <christian.haudum@gmail.com>* Generate .drone/drone.yml using `make drone`Signed-off-by: Christian Haudum <christian.haudum@gmail.com>* fixup! Generate .drone/drone.yml using `make drone`Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
1 parent6bdecd6 commitb3bc8d3

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed

‎.drone/drone.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ steps:
1212
from_secret:docker_password
1313
repo:grafana/loki-build-image
1414
tags:
15-
-0.20.2
15+
-0.20.3
1616
username:
1717
from_secret:docker_username
1818
when:
@@ -1118,6 +1118,6 @@ kind: secret
11181118
name:deploy_config
11191119
---
11201120
kind:signature
1121-
hmac:2f47de5e61231501593c473c31c46c695edabd18e6dd5e06817d272720c144f8
1121+
hmac:64871d70248fbe43acab816fe107dc657442ded224b48779ac15f4559143a2c6
11221122

11231123
...

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ else
576576
endif
577577

578578
check-drone-drift:
579-
./tools/check-drone-drift.shmain
579+
./tools/check-drone-drift.sh$(BUILD_IMAGE_VERSION)
580580

581581

582582
# support go modules

‎tools/check-drone-drift.sh‎

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,30 @@ set -uo pipefail
44

55
command -v drone>/dev/null2>&1|| {echo"drone is not installed";exit 1; }
66

7-
TARGET_BRANCH="$1"
87
DRONE_JSONNET_FILE=".drone/drone.jsonnet"
98
DRONE_CONFIG_FILE=".drone/drone.yml"
9+
DRONE_ACTUAL_CONFIG_FILE="$(mktemp)"
10+
DRONE_EXPECTED_CONFIG_FILE="$(mktemp)"
1011

1112
# Check for a drift between the jsonnet and the resulting file consumed by Drone
12-
modified_drone_jsonnet=$(git diff"${TARGET_BRANCH}" --"${DRONE_JSONNET_FILE}"| wc -l)
13-
if [["${modified_drone_jsonnet}"-gt"0" ]];then
14-
modified_drone_config=$(git diff"${TARGET_BRANCH}" --"${DRONE_CONFIG_FILE}"| wc -l)
15-
if [["${modified_drone_config}"-lt"1" ]];then
16-
echo"There is a drift between${DRONE_JSONNET_FILE} and${DRONE_CONFIG_FILE}"
17-
echo"You can fix it by running:"
18-
echo"make drone"
19-
exit 1
20-
fi
21-
fi
13+
drone jsonnet \
14+
--stream \
15+
--stdout \
16+
--format \
17+
-V __build-image-version="${1:-latest}" \
18+
--source"${DRONE_JSONNET_FILE}" \
19+
>"${DRONE_EXPECTED_CONFIG_FILE}"
20+
# remove last 5 lines which contain the signature
21+
head -n -5"${DRONE_CONFIG_FILE}">"${DRONE_ACTUAL_CONFIG_FILE}"
22+
diff"${DRONE_EXPECTED_CONFIG_FILE}""${DRONE_ACTUAL_CONFIG_FILE}"
23+
24+
EXIT_STATUS=$?
25+
if [["${EXIT_STATUS}"-eq 1 ]];then
26+
echo"There is a drift between${DRONE_JSONNET_FILE} and${DRONE_CONFIG_FILE}"
27+
echo"You can fix it by running:"
28+
echo"make drone"
29+
else
30+
echo"${DRONE_CONFIG_FILE} is up to date"
31+
fi
32+
33+
exit"${EXIT_STATUS}"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp