Skip to content

Commit 2df36fd

Browse files
Fix PR Findings
1 parent d47fad3 commit 2df36fd

File tree

6 files changed

+51
-18
lines changed

6 files changed

+51
-18
lines changed

pushflatpakscript/docker.d/init_worker.sh

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,18 @@ case $ENV in
2626
echo $REPO_TOKEN_BETA | base64 -d > $REPO_TOKEN_BETA_PATH
2727
echo $REPO_TOKEN_STABLE | base64 -d > $REPO_TOKEN_STABLE_PATH
2828

29-
if [[$COT_PRODUCT == 'thunderbird']]; then
30-
test_var_set 'REPO_TOKEN_ESR'
29+
30+
if [ "$COT_PRODUCT" = thunderbird ]; then
31+
# test_var_set 'REPO_TOKEN_RELEASE'
32+
# must either have REPO_TOKEN_RELEASE or REPO_TOKEN_ESR defined
33+
if [[ -z "$REPO_TOKEN_RELEASE" ]] && [[ -z "$REPO_TOKEN_ESR" ]]; then
34+
echo "error: must have token defined for release or esr channel"
35+
exit 1
36+
fi
37+
38+
export REPO_TOKEN_RELEASE_PATH=$CONFIG_DIR/release_token.txt
39+
echo $REPO_TOKEN_RELEASE | base64 -d > $REPO_TOKEN_RELEASE_PATH
40+
3141
export REPO_TOKEN_ESR_PATH=$CONFIG_DIR/esr_token.txt
3242
echo $REPO_TOKEN_ESR | base64 -d > $REPO_TOKEN_ESR_PATH
3343
fi
@@ -39,14 +49,13 @@ esac
3949

4050
case $COT_PRODUCT in
4151
firefox)
42-
export APP_ID_BETA="org.mozilla.firefox"
43-
export APP_ID_STABLE="org.mozilla.firefox"
52+
export APP_ID="org.mozilla.firefox"
4453
export TASKCLUSTER_SCOPE_PREFIX="project:releng:flathub:firefox:"
4554
;;
4655
thunderbird)
47-
export APP_ID_BETA="org.mozilla.Thunderbird"
48-
export APP_ID_STABLE="org.mozilla.ThunderbirdRelease"
49-
export APP_ID_ESR="org.mozilla.Thunderbird"
56+
export APP_ID="org.mozilla.Thunderbird"
57+
export APP_ID_RELEASE="org.mozilla.ThunderbirdRelease"
58+
export APP_ID_ESR="org.mozilla.ThunderbirdESR"
5059
export TASKCLUSTER_SCOPE_PREFIX="project:comm:thunderbird:releng:flathub:"
5160
;;
5261
*)

pushflatpakscript/docker.d/worker.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ work_dir: { "$eval": "WORK_DIR" }
22
artifact_dir: { "$eval": "ARTIFACTS_DIR" }
33
verbose: { "$eval": "VERBOSE == 'true'" }
44
app_ids:
5-
beta: {"$eval": "APP_ID_BETA" }
6-
stable: {"$eval": "APP_ID_STABLE"}
5+
beta: {"$eval": "APP_ID" }
6+
stable: {"$eval": "APP_ID"}
7+
release:
8+
$if: defined("APP_ID_RELEASE")
9+
then: {"$eval": "APP_ID_RELEASE"}
10+
else: ''
711
esr:
8-
$if: 'COT_PRODUCT == "thunderbird"'
9-
then: { "$eval": "APP_ID_ESR"}
12+
$if: defined("APP_ID_ESR")
13+
then: {"$eval": "APP_ID_ESR"}
1014
else: ''
1115
taskcluster_scope_prefix: { "$eval": "TASKCLUSTER_SCOPE_PREFIX" }
1216
push_to_flathub: { "$eval": "ENV == 'prod'" }
@@ -18,8 +22,13 @@ token_locations:
1822
then:
1923
beta: { "$eval": "REPO_TOKEN_BETA_PATH" }
2024
stable: { "$eval": "REPO_TOKEN_STABLE_PATH" }
25+
release:
26+
$if: defined("REPO_TOKEN_RELEASE_PATH")
27+
then: {"$eval": "REPO_TOKEN_RELEASE_PATH"}
28+
else: ''
2129
esr:
22-
$if: 'COT_PRODUCT == "thunderbird"'
23-
then: { "$eval": "REPO_TOKEN_ESR_PATH" }
30+
$if: defined("REPO_TOKEN_ESR_PATH")
31+
then: {"$eval": "REPO_TOKEN_ESR_PATH"}
2432
else: ''
33+
2534
else: {}

pushflatpakscript/src/pushflatpakscript/flathub.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def check_app_id_matches_flatpak(context, flatpak_path, channel):
150150
flatpak_refs = [ref.split("/")[1] for ref in flatpak_refs if ref.startswith("app/")]
151151

152152
# Create a list, if any, of all unexpected Flatpak IDs present in repo
153-
invalid_refs = set(flatpak_refs) - {context.config["app_ids"]}
153+
invalid_refs = set(flatpak_refs) - set(context.config["app_ids"].values())
154154

155155
if context.config["app_ids"][channel] not in flatpak_refs:
156156
raise TaskVerificationError(f"Supplied app ID ({context.config['app_ids'][channel]}) is not present in Flatpak!")
@@ -159,6 +159,15 @@ def check_app_id_matches_flatpak(context, flatpak_path, channel):
159159
raise TaskVerificationError("One or more invalid app IDs are present in Flatpak!")
160160

161161

162+
def check_config_for_channel(config, channel):
163+
"""Verify AppID and token location defined for supplied channel"""
164+
if channel not in config["app_ids"]:
165+
raise TaskVerificationError(f"Supplied channel ({channel}) does not have a configured appID")
166+
167+
if channel not in config["token_locations"]:
168+
raise TaskVerificationError(f"Supplied channel ({channel}) does not have a configured token")
169+
170+
162171
def sanitize_buildid(bytes_input):
163172
"""Flathub API returns bytes to we're decoding that to unicode string"""
164173
return bytes_input.decode().strip()
@@ -174,6 +183,8 @@ def push(context, flatpak_file_path, channel):
174183
# We don't raise an error because we still want green tasks on dev instances
175184
return
176185

186+
check_config_for_channel(context.config, channel)
187+
177188
token_args = ["--token-file", context.config["token_locations"][channel]]
178189
log.info("Grab a flatpak buildid from Flathub ...")
179190
publish_build_output = run_flat_manager_client_process(

pushflatpakscript/src/pushflatpakscript/task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from scriptworker.exceptions import TaskVerificationError
22

3-
_CHANNELS_AUTHORIZED_TO_REACH_FLATHUB = ("beta", "stable", "esr")
3+
_CHANNELS_AUTHORIZED_TO_REACH_FLATHUB = ("beta", "stable", "release", "esr")
44
ALLOWED_CHANNELS = ("mock", *_CHANNELS_AUTHORIZED_TO_REACH_FLATHUB)
55

66

pushflatpakscript/tests/test_config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
"WORK_DIR": "",
1010
"ARTIFACTS_DIR": "",
1111
"VERBOSE": "true",
12-
"APP_ID_STABLE": "",
13-
"APP_ID_BETA": "",
12+
"APP_ID": "",
13+
"APP_ID_RELEASE": "",
14+
"APP_ID_ESR": "",
1415
"COT_PRODUCT": "firefox",
1516
"TASKCLUSTER_SCOPE_PREFIX": "",
1617
"FLATHUB_URL": "https://flat.example",

pushflatpakscript/tests/test_task.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ def test_get_flatpak_channel_dep(raises, channel):
3535
)
3636
def test_get_flatpak_channel_prod(raises, scopes, channel):
3737
task = {"scopes": scopes, "payload": {"channel": channel}}
38-
config = {"app_ids": {"stable": "org.mozilla.firefox", "beta": "org.mozilla.firefox"}, "taskcluster_scope_prefix": "project:releng:flathub:firefox:", "push_to_flathub": True}
38+
config = {"app_ids": {"stable": "org.mozilla.firefox", "beta": "org.mozilla.firefox"},
39+
"token_locations": {"stable": "stable.txt", "beta": "beta.txt"},
40+
"taskcluster_scope_prefix": "project:releng:flathub:firefox:",
41+
"push_to_flathub": True}
3942
if raises:
4043
with pytest.raises(TaskVerificationError):
4144
get_flatpak_channel(config, task)

0 commit comments

Comments
 (0)