mirror of
https://github.com/containers/podman.git
synced 2025-05-22 09:36:57 +08:00
Merge pull request #9022 from cevich/swagger_upload
Cirrus: Upload swagger YAML in every context
This commit is contained in:
19
.cirrus.yml
19
.cirrus.yml
@ -254,20 +254,27 @@ bindings_task:
|
|||||||
always: *runner_stats
|
always: *runner_stats
|
||||||
|
|
||||||
|
|
||||||
# Build the "libpod" API documentation `swagger.yaml` for eventual
|
# Build the "libpod" API documentation `swagger.yaml` and
|
||||||
# publishing along side the official podman documentation.
|
# publish it to google-cloud-storage (GCS).
|
||||||
swagger_task:
|
swagger_task:
|
||||||
name: "Test Swagger"
|
name: "Test Swagger"
|
||||||
alias: swagger
|
alias: swagger
|
||||||
depends_on:
|
depends_on:
|
||||||
- build
|
- build
|
||||||
container: *smallcontainer
|
gce_instance: *standardvm
|
||||||
env:
|
env:
|
||||||
<<: *stdenvars
|
<<: *stdenvars
|
||||||
TEST_FLAVOR: swagger
|
TEST_FLAVOR: swagger
|
||||||
TEST_ENVIRON: container
|
# TODO: Due to podman 3.0 activity (including new images), avoid
|
||||||
CTR_FQIN: ${FEDORA_CONTAINER_FQIN}
|
# disturbing the status-quo just to incorporate this one new
|
||||||
clone_script: *full_clone # build-cache not available to container tasks
|
# container image. Uncomment line below when CI activities normalize.
|
||||||
|
#CTR_FQIN: 'quay.io/libpod/gcsupld:${IMAGE_SUFFIX}'
|
||||||
|
CTR_FQIN: 'quay.io/libpod/gcsupld:c4813063494828032'
|
||||||
|
GCPJSON: ENCRYPTED[927dc01e755eaddb4242b0845cf86c9098d1e3dffac38c70aefb1487fd8b4fe6dd6ae627b3bffafaba70e2c63172664e]
|
||||||
|
GCPNAME: ENCRYPTED[c145e9c16b6fb88d476944a454bf4c1ccc84bb4ecaca73bdd28bdacef0dfa7959ebc8171a27b2e4064d66093b2cdba49]
|
||||||
|
GCPPROJECT: 'libpod-218412'
|
||||||
|
gopath_cache: *ro_gopath_cache
|
||||||
|
clone_script: *noop # Comes from cache
|
||||||
setup_script: *setup
|
setup_script: *setup
|
||||||
main_script: *main
|
main_script: *main
|
||||||
always: *binary_artifacts
|
always: *binary_artifacts
|
||||||
|
@ -130,20 +130,70 @@ exec_container() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _run_swagger() {
|
function _run_swagger() {
|
||||||
|
local upload_filename
|
||||||
|
local upload_bucket
|
||||||
local download_url
|
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
|
# Building this is a PITA, just grab binary for use in automation
|
||||||
# Ref: https://goswagger.io/install.html#static-binary
|
# Ref: https://goswagger.io/install.html#static-binary
|
||||||
download_url=$(\
|
download_url=$(\
|
||||||
curl -s https://api.github.com/repos/go-swagger/go-swagger/releases/latest | \
|
curl -s https://api.github.com/repos/go-swagger/go-swagger/releases/latest | \
|
||||||
jq -r '.assets[] | select(.name | contains("linux_amd64")) | .browser_download_url')
|
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
|
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
|
cd $GOSRC
|
||||||
make swagger
|
make swagger
|
||||||
|
|
||||||
# Cirrus-CI Artifact instruction expects file here
|
# 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() {
|
function _run_consistency() {
|
||||||
|
@ -202,7 +202,6 @@ case "$TEST_FLAVOR" in
|
|||||||
int) ;&
|
int) ;&
|
||||||
sys) ;&
|
sys) ;&
|
||||||
bindings) ;&
|
bindings) ;&
|
||||||
swagger) ;&
|
|
||||||
endpoint)
|
endpoint)
|
||||||
# Use existing host bits when testing is to happen inside a container
|
# Use existing host bits when testing is to happen inside a container
|
||||||
# since this script will run again in that environment.
|
# since this script will run again in that environment.
|
||||||
@ -214,6 +213,7 @@ case "$TEST_FLAVOR" in
|
|||||||
|
|
||||||
install_test_configs
|
install_test_configs
|
||||||
;;
|
;;
|
||||||
|
swagger) ;& # use next item
|
||||||
consistency) make clean ;;
|
consistency) make clean ;;
|
||||||
release) ;;
|
release) ;;
|
||||||
*) die_unknown TEST_FLAVOR
|
*) die_unknown TEST_FLAVOR
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<redoc spec-url='https://storage.googleapis.com/libpod-master-releases/swagger-latest-master.yaml' sort-props-alphabetically></redoc>
|
<redoc spec-url='https://storage.googleapis.com/libpod-master-releases/swagger-latest.yaml' sort-props-alphabetically></redoc>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script>
|
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Reference in New Issue
Block a user