forked from eclipse-basyx/basyx-java-server-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_docker_publication_guard.sh
More file actions
executable file
·76 lines (64 loc) · 3.36 KB
/
Copy pathtest_docker_publication_guard.sh
File metadata and controls
executable file
·76 lines (64 loc) · 3.36 KB
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
#!/usr/bin/env bash
# /*******************************************************************************
# * Copyright (C) 2026 the Eclipse BaSyx Authors
# *
# * Permission is hereby granted, free of charge, to any person obtaining
# * a copy of this software and associated documentation files (the
# * "Software"), to deal in the Software without restriction, including
# * without limitation the rights to use, copy, modify, merge, publish,
# * distribute, sublicense, and/or sell copies of the Software, and to
# * permit persons to whom the Software is furnished to do so, subject to
# * the following conditions:
# *
# * The above copyright notice and this permission notice shall be
# * included in all copies or substantial portions of the Software.
# *
# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# *
# * SPDX-License-Identifier: MIT
# ******************************************************************************/
set -euo pipefail
readonly SCRIPT_DIRECTORY="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
readonly GUARD_SCRIPT="${SCRIPT_DIRECTORY}/check_docker_publication.sh"
readonly WORKFLOW_DIRECTORY="${SCRIPT_DIRECTORY}/.."
assert_guard_result() {
local description="$1"
local repository="$2"
local is_fork="$3"
local expected="$4"
local actual
actual="$(bash "${GUARD_SCRIPT}" "${repository}" "${is_fork}")"
if [[ "${actual}" != "${expected}" ]]; then
echo "${description}: expected ${expected}, got ${actual}" >&2
exit 1
fi
}
assert_workflow_uses_guard() {
local workflow="$1"
if [[ "$(grep -c 'check_docker_publication.sh' "${workflow}")" -ne 1 ]]; then
echo "${workflow} must invoke the shared Docker publication guard exactly once" >&2
exit 1
fi
}
# Release workflow cases
assert_guard_result "release in upstream" "eclipse-basyx/basyx-java-server-sdk" "false" "true"
assert_guard_result "release in upstream marked as fork" "eclipse-basyx/basyx-java-server-sdk" "true" "false"
assert_guard_result "release in fork" "contributor/basyx-java-server-sdk" "true" "false"
assert_guard_result "release in renamed repository" "eclipse-basyx/basyx-java-server-sdk-renamed" "false" "false"
# Snapshot push workflow cases
assert_guard_result "push in upstream" "eclipse-basyx/basyx-java-server-sdk" "false" "true"
assert_guard_result "push in upstream marked as fork" "eclipse-basyx/basyx-java-server-sdk" "true" "false"
assert_guard_result "push in fork" "contributor/basyx-java-server-sdk" "true" "false"
assert_guard_result "push in renamed repository" "eclipse-basyx/basyx-java-server-sdk-renamed" "false" "false"
# Missing event metadata must fail closed.
assert_guard_result "missing fork metadata" "eclipse-basyx/basyx-java-server-sdk" "" "false"
assert_guard_result "missing repository metadata" "" "false" "false"
assert_workflow_uses_guard "${WORKFLOW_DIRECTORY}/docker-milestone-release.yml"
assert_workflow_uses_guard "${WORKFLOW_DIRECTORY}/docker-snapshot-release.yml"
echo "Docker publication guard tests passed"