summaryrefslogtreecommitdiff
path: root/contrib/cirrus/runner.sh
diff options
context:
space:
mode:
authorChris Evich <cevich@redhat.com>2021-01-19 10:42:25 -0500
committerChris Evich <cevich@redhat.com>2021-01-21 10:26:57 -0500
commit4e4d318b710a9787e404d5edb4f418884c1cf786 (patch)
tree9707c6beb9f9542f8574fe804f51f74ff2bb03eb /contrib/cirrus/runner.sh
parent7d297ddbdabe81b94184f2b2fe095f42389ddfa6 (diff)
downloadpodman-4e4d318b710a9787e404d5edb4f418884c1cf786.tar.gz
podman-4e4d318b710a9787e404d5edb4f418884c1cf786.tar.bz2
podman-4e4d318b710a9787e404d5edb4f418884c1cf786.zip
Cirrus: Upload swagger YAML in every context
The podman documentation site uses javascript to display API documentation at: http://docs.podman.io/en/latest/Reference.html As input, the javascript sources from a CORS-enabled Google Cloud Storage object. This commit ensures the storage object is present and updated for every Cirrus-CI execution context: Tags, Branches, and PRs. As of this commit, the documentation site only utilizes the object uploaded by the Cirrus-CI run on the `master` branch: `swagger-master.yaml`. The file produced and uploaded due to a PR is intended for testing purposes: Confirm it's generation and uploading are both functional. Signed-off-by: Chris Evich <cevich@redhat.com>
Diffstat (limited to 'contrib/cirrus/runner.sh')
-rwxr-xr-xcontrib/cirrus/runner.sh54
1 files changed, 52 insertions, 2 deletions
diff --git a/contrib/cirrus/runner.sh b/contrib/cirrus/runner.sh
index d9f91c7af..50bc1102f 100755
--- a/contrib/cirrus/runner.sh
+++ b/contrib/cirrus/runner.sh
@@ -130,20 +130,70 @@ exec_container() {
}
function _run_swagger() {
+ local upload_filename
+ local upload_bucket
local download_url
+ local envvarsfile
+ req_env_vars GCPJSON GCPNAME GCPPROJECT CTR_FQIN
+
# Building this is a PITA, just grab binary for use in automation
# Ref: https://goswagger.io/install.html#static-binary
download_url=$(\
curl -s https://api.github.com/repos/go-swagger/go-swagger/releases/latest | \
jq -r '.assets[] | select(.name | contains("linux_amd64")) | .browser_download_url')
- curl -o /usr/local/bin/swagger -L'#' "$download_url"
+
+ # The filename and bucket depend on the automation context
+ #shellcheck disable=SC2154,SC2153
+ if [[ -n "$CIRRUS_PR" ]]; then
+ upload_bucket="libpod-pr-releases"
+ upload_filename="swagger-pr$CIRRUS_PR.yaml"
+ elif [[ -n "$CIRRUS_TAG" ]]; then
+ upload_bucket="libpod-master-releases"
+ upload_filename="swagger-$CIRRUS_TAG.yaml"
+ elif [[ "$CIRRUS_BRANCH" == "master" ]]; then
+ upload_bucket="libpod-master-releases"
+ # readthedocs versioning uses "latest" for "master" (default) branch
+ upload_filename="swagger-latest.yaml"
+ elif [[ -n "$CIRRUS_BRANCH" ]]; then
+ upload_bucket="libpod-master-releases"
+ upload_filename="swagger-$CIRRUS_BRANCH.yaml"
+ else
+ die "Unknown execution context, expected a non-empty value for \$CIRRUS_TAG, \$CIRRUS_BRANCH, or \$CIRRUS_PR"
+ fi
+
+ curl -s -o /usr/local/bin/swagger -L'#' "$download_url"
chmod +x /usr/local/bin/swagger
+ # Swagger validation takes a significant amount of time
+ msg "Pulling \$CTR_FQIN '$CTR_FQIN' (background process)"
+ podman pull --quiet $CTR_FQIN &
+
cd $GOSRC
make swagger
# Cirrus-CI Artifact instruction expects file here
- cp -v $GOSRC/pkg/api/swagger.yaml $GOSRC/
+ cp -v $GOSRC/pkg/api/swagger.yaml ./
+
+ envvarsfile=$(mktemp -p '' .tmp_$(basename $0)_XXXXXXXX)
+ trap "rm -f $envvarsfile" EXIT # contains secrets
+ # Warning: These values must _not_ be quoted, podman will not remove them.
+ #shellcheck disable=SC2154
+ cat <<eof>>$envvarsfile
+GCPJSON=$GCPJSON
+GCPNAME=$GCPNAME
+GCPPROJECT=$GCPPROJECT
+FROM_FILEPATH=$GOSRC/swagger.yaml
+TO_GCSURI=gs://$upload_bucket/$upload_filename
+eof
+
+ msg "Waiting for backgrounded podman pull to complete..."
+ wait %%
+ podman run -it --rm --security-opt label=disable \
+ --env-file=$envvarsfile \
+ -v $GOSRC:$GOSRC:ro \
+ --workdir $GOSRC \
+ $CTR_FQIN
+ rm -f $envvarsfile
}
function _run_consistency() {