mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-19 08:48:21 +03:00
ci/bash-lib: fix gcs return code (#7630)
Currently the return code of the function is the return code of the `eval "$restore_trap"` line, whereas semantically we want the return code of the `gsutil` call. This is not an issue in most cases as the `set -e` should kick in, but if the function appears as the condition in an `if` statement the `-e` flag is suspended. The main use-case right now is that the daily license check is _not_ uploading artifacts. CHANGELOG_BEGIN CHANGELOG_END
This commit is contained in:
parent
664a0c0076
commit
8e905b34c0
@ -30,7 +30,8 @@ steps:
|
|||||||
| curl -XPOST -i -H 'Content-Type: application/json' -d @- $channel
|
| curl -XPOST -i -H 'Content-Type: application/json' -d @- $channel
|
||||||
}
|
}
|
||||||
gcs() {
|
gcs() {
|
||||||
local args cleanup cmd cred key restore_trap
|
local args cleanup cmd cred key restore_trap ret
|
||||||
|
ret=1
|
||||||
|
|
||||||
cred="$1"
|
cred="$1"
|
||||||
cmd="$2"
|
cmd="$2"
|
||||||
@ -45,9 +46,11 @@ steps:
|
|||||||
gcloud auth activate-service-account --key-file=$key
|
gcloud auth activate-service-account --key-file=$key
|
||||||
|
|
||||||
BOTO_CONFIG=/dev/null gsutil $cmd "${args[@]}"
|
BOTO_CONFIG=/dev/null gsutil $cmd "${args[@]}"
|
||||||
|
ret=$?
|
||||||
eval "$cleanup"
|
eval "$cleanup"
|
||||||
trap - EXIT
|
trap - EXIT
|
||||||
eval "$restore_trap"
|
eval "$restore_trap"
|
||||||
|
return $ret
|
||||||
}
|
}
|
||||||
gpg_verify() {
|
gpg_verify() {
|
||||||
local key gpg_dir signature_file res
|
local key gpg_dir signature_file res
|
||||||
|
@ -245,8 +245,6 @@ fetch_s3_versions = do
|
|||||||
|
|
||||||
docs :: IO ()
|
docs :: IO ()
|
||||||
docs = do
|
docs = do
|
||||||
Control.forM_ [IO.stdout, IO.stderr] $
|
|
||||||
\h -> IO.hSetBuffering h IO.LineBuffering
|
|
||||||
putStrLn "Checking for new version..."
|
putStrLn "Checking for new version..."
|
||||||
gh_versions <- fetch_gh_versions
|
gh_versions <- fetch_gh_versions
|
||||||
s3_versions <- fetch_s3_versions
|
s3_versions <- fetch_s3_versions
|
||||||
@ -318,7 +316,11 @@ does_backup_exist gcp_credentials bash_lib path = do
|
|||||||
"set -euo pipefail",
|
"set -euo pipefail",
|
||||||
"eval \"$(dev-env/bin/dade assist)\"",
|
"eval \"$(dev-env/bin/dade assist)\"",
|
||||||
"source \"" <> bash_lib <> "\"",
|
"source \"" <> bash_lib <> "\"",
|
||||||
"if gcs \"" <> gcp_credentials <> "\" ls \"" <> path <> "\"; then",
|
"GCRED=$(cat <<END",
|
||||||
|
gcp_credentials,
|
||||||
|
"END",
|
||||||
|
")",
|
||||||
|
"if gcs \"$GCRED\" ls \"" <> path <> "\" >/dev/null; then",
|
||||||
"echo True",
|
"echo True",
|
||||||
"else",
|
"else",
|
||||||
"echo False",
|
"echo False",
|
||||||
@ -332,7 +334,11 @@ push_to_gcp gcp_credentials bash_lib local_path remote_path = do
|
|||||||
"set -euo pipefail",
|
"set -euo pipefail",
|
||||||
"eval \"$(dev-env/bin/dade assist)\"",
|
"eval \"$(dev-env/bin/dade assist)\"",
|
||||||
"source \"" <> bash_lib <> "\"",
|
"source \"" <> bash_lib <> "\"",
|
||||||
"gcs \"" <> gcp_credentials <> "\" cp \"" <> local_path <> "\" \"" <> remote_path <> "\"",
|
"GCRED=$(cat <<END",
|
||||||
|
gcp_credentials,
|
||||||
|
"END",
|
||||||
|
")",
|
||||||
|
"gcs \"$GCRED\" cp \"" <> local_path <> "\" \"" <> remote_path <> "\"",
|
||||||
"'"]
|
"'"]
|
||||||
|
|
||||||
check_releases :: String -> String -> IO ()
|
check_releases :: String -> String -> IO ()
|
||||||
@ -351,7 +357,7 @@ check_releases gcp_credentials bash_lib = do
|
|||||||
putStrLn $ gcp_path <> " already exists."
|
putStrLn $ gcp_path <> " already exists."
|
||||||
else do
|
else do
|
||||||
putStr $ gcp_path <> " does not exist; pushing..."
|
putStr $ gcp_path <> " does not exist; pushing..."
|
||||||
push_to_gcp gcp_credentials bash_lib f gcp_path
|
push_to_gcp gcp_credentials bash_lib (temp_dir </> f) gcp_path
|
||||||
putStrLn " done."))
|
putStrLn " done."))
|
||||||
|
|
||||||
data CliArgs = Docs | Check { bash_lib :: String, gcp_credentials :: String }
|
data CliArgs = Docs | Check { bash_lib :: String, gcp_credentials :: String }
|
||||||
@ -373,6 +379,8 @@ parser = info "This program is meant to be run by CI cron. You probably don't ha
|
|||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
|
Control.forM_ [IO.stdout, IO.stderr] $
|
||||||
|
\h -> IO.hSetBuffering h IO.LineBuffering
|
||||||
opts <- Opt.execParser parser
|
opts <- Opt.execParser parser
|
||||||
case opts of
|
case opts of
|
||||||
Docs -> docs
|
Docs -> docs
|
||||||
|
Loading…
Reference in New Issue
Block a user