post-process swagger yaml for publish

Signed-off-by: baude <bbaude@redhat.com>
Signed-off-by: Chris Evich <cevich@redhat.com>
This commit is contained in:
baude
2020-01-17 09:41:40 -06:00
committed by Chris Evich
parent ab7e1a4c40
commit 9be6f30a42
6 changed files with 62 additions and 33 deletions

View File

@ -660,24 +660,17 @@ upload_snap_task:
- 'cd contrib/snapcraft && snapcraft && snapcraft push *.snap --release edge' - 'cd contrib/snapcraft && snapcraft && snapcraft push *.snap --release edge'
test_docs_task: docs_task:
# Only run this for PRs on mention, but always run after merge
only_if: $CIRRUS_CHANGE_MESSAGE =~ '.*CI:DOCS.*' || $CIRRUS_BRANCH == $DEST_BRANCH
only_if: >-
$CIRRUS_BRANCH != $DEST_BRANCH &&
$CIRRUS_CHANGE_MESSAGE =~ '.*CI:DOCS.*'
depends_on: depends_on:
- "gating" - "gating"
- "vendor"
#- "test_docs"
#- "varlink_api"
#- "build_each_commit"
stub_script: '/bin/true'
script:
#publish_docs_task: - "$SCRIPT_BASE/build_swagger.sh |& ${TIMESTAMP}"
# - "$SCRIPT_BASE/upload_release_archive.sh |& ${TIMESTAMP}"
# only_if: $CIRRUS_BRANCH == $DEST_BRANCH &&
# $CIRRUS_TAG =~ '^v[0-9]\.[0-9]\.[0-9]$'
# Post message to IRC if everything passed PR testing # Post message to IRC if everything passed PR testing
@ -706,7 +699,7 @@ success_task:
- "test_building_snap" - "test_building_snap"
- "upload_snap" - "upload_snap"
- "verify_test_built_images" - "verify_test_built_images"
- "test_docs" - "docs"
env: env:
CIRRUS_WORKING_DIR: "/usr/src/libpod" CIRRUS_WORKING_DIR: "/usr/src/libpod"

View File

@ -212,6 +212,12 @@ run-docker-py-tests:
$(eval testLogs=$(shell mktemp)) $(eval testLogs=$(shell mktemp))
./bin/podman run --rm --security-opt label=disable --privileged -v $(testLogs):/testLogs --net=host -e DOCKER_HOST=tcp://localhost:8080 $(DOCKERPY_IMAGE) sh -c "pytest $(DOCKERPY_TEST) " ./bin/podman run --rm --security-opt label=disable --privileged -v $(testLogs):/testLogs --net=host -e DOCKER_HOST=tcp://localhost:8080 $(DOCKERPY_IMAGE) sh -c "pytest $(DOCKERPY_TEST) "
pkg/api/swagger.yaml: .gopathok release.txt
make -C pkg/api
.PHONY: swagger
swagger: pkg/api/swagger.yaml
clean: ## Clean artifacts clean: ## Clean artifacts
rm -rf \ rm -rf \
.gopathok \ .gopathok \

17
contrib/cirrus/build_swagger.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
set -e
source $(dirname $0)/lib.sh
# 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("'"$(uname | tr '[:upper:]' '[:lower:]')"'_amd64")) | .browser_download_url')
curl -o /usr/local/bin/swagger -L'#' "$download_url"
chmod +x /usr/local/bin/swagger
cd $GOSRC
make swagger
echo "Preserving build details for later use."
mv -v release.txt actual_release.txt # Another 'make' during testing could overwrite it

View File

@ -9,6 +9,8 @@ req_env_var CI UPLDREL_IMAGE CIRRUS_BUILD_ID GOSRC RELEASE_GCPJSON RELEASE_GCPNA
[[ "$CI" == "true" ]] || \ [[ "$CI" == "true" ]] || \
die 56 "$0 must be run under Cirrus-CI to function" die 56 "$0 must be run under Cirrus-CI to function"
SWAGGER_FILEPATH="pkg/api/swagger.yaml"
# We store "releases" for each PR, mostly to validate the process is functional # We store "releases" for each PR, mostly to validate the process is functional
unset PR_OR_BRANCH BUCKET unset PR_OR_BRANCH BUCKET
if [[ -n "$CIRRUS_PR" ]] if [[ -n "$CIRRUS_PR" ]]
@ -62,7 +64,7 @@ echo "$RELEASE_GCPJSON" > "$TMPF"
unset RELEASE_GCPJSON unset RELEASE_GCPJSON
cd $GOSRC cd $GOSRC
for filename in $(ls -1 *.tar.gz *.zip *.msi) for filename in $(ls -1 *.tar.gz *.zip *.msi $SWAGGER_FILEPATH)
do do
unset EXT unset EXT
EXT=$(echo "$filename" | sed -r -e 's/.+\.(.+$)/\1/g') EXT=$(echo "$filename" | sed -r -e 's/.+\.(.+$)/\1/g')
@ -76,24 +78,32 @@ do
EXT="tar.gz" EXT="tar.gz"
fi fi
[[ "$OS_RELEASE_ID" == "ubuntu" ]] || \ if [[ $filename == $SWAGGER_FILEPATH ]]
chcon -t container_file_t "$filename"
# Form the generic "latest" file for this branch or pr
TO_PREFIX="${RELEASE_BASENAME}-latest-${PR_OR_BRANCH}-${RELEASE_DIST}"
# Form the fully-versioned filename for historical sake
ALSO_PREFIX="${RELEASE_BASENAME}-${RELEASE_VERSION}-${PR_OR_BRANCH}-${RELEASE_DIST}"
TO_SUFFIX="${RELEASE_ARCH}.${EXT}"
if [[ "$RELEASE_DIST" == "windows" ]] || [[ "$RELEASE_DIST" == "darwin" ]]
then then
TO_FILENAME="${TO_PREFIX}-${TO_SUFFIX}" # Support other tools referencing branch and/or version-specific refs.
ALSO_FILENAME="${ALSO_PREFIX}-${TO_SUFFIX}" TO_FILENAME="swagger-${RELEASE_VERSION}-${PR_OR_BRANCH}.yaml"
# For doc. ref. this must always be a static filename, e.g. swagger-latest-master.yaml
ALSO_FILENAME="swagger-latest-${PR_OR_BRANCH}.yaml"
else else
TO_FILENAME="${TO_PREFIX}-${RELEASE_DIST_VER}-${TO_SUFFIX}" # Form the generic "latest" file for this branch or pr
ALSO_FILENAME="${ALSO_PREFIX}-${TO_SUFFIX}" TO_PREFIX="${RELEASE_BASENAME}-latest-${PR_OR_BRANCH}-${RELEASE_DIST}"
# Form the fully-versioned filename for historical sake
ALSO_PREFIX="${RELEASE_BASENAME}-${RELEASE_VERSION}-${PR_OR_BRANCH}-${RELEASE_DIST}"
TO_SUFFIX="${RELEASE_ARCH}.${EXT}"
if [[ "$RELEASE_DIST" == "windows" ]] || [[ "$RELEASE_DIST" == "darwin" ]]
then
TO_FILENAME="${TO_PREFIX}-${TO_SUFFIX}"
ALSO_FILENAME="${ALSO_PREFIX}-${TO_SUFFIX}"
else
TO_FILENAME="${TO_PREFIX}-${RELEASE_DIST_VER}-${TO_SUFFIX}"
ALSO_FILENAME="${ALSO_PREFIX}-${TO_SUFFIX}"
fi
fi fi
[[ "$OS_RELEASE_ID" == "ubuntu" ]] || \
chcon -t container_file_t "$filename"
echo "Running podman ... $UPLDREL_IMAGE for $filename -> $TO_FILENAME" echo "Running podman ... $UPLDREL_IMAGE for $filename -> $TO_FILENAME"
echo "Warning: upload failures are completely ignored, avoiding any needless holdup of PRs."
podman run -i --rm \ podman run -i --rm \
-e "GCPNAME=$RELEASE_GCPNAME" \ -e "GCPNAME=$RELEASE_GCPNAME" \
-e "GCPPROJECT=$RELEASE_GCPROJECT" \ -e "GCPPROJECT=$RELEASE_GCPROJECT" \
@ -105,5 +115,5 @@ do
-e "BUCKET=$BUCKET" \ -e "BUCKET=$BUCKET" \
-v "$TMPF:$TMPF:ro" \ -v "$TMPF:$TMPF:ro" \
-v "$(realpath $GOSRC/$filename):/tmp/$filename:ro" \ -v "$(realpath $GOSRC/$filename):/tmp/$filename:ro" \
$UPLDREL_IMAGE || true $UPLDREL_IMAGE
done done

View File

@ -1,3 +1,5 @@
SWAGGER_OUT ?= swagger.yaml
swagger: swagger:
swagger generate spec -o swagger.yaml -w ./ swagger generate spec -o ${SWAGGER_OUT} -w ./
cat tags.yaml >> swagger.yaml cat tags.yaml >> swagger.yaml

View File

@ -788,11 +788,13 @@ func (s *APIServer) RegisterContainersHandlers(r *mux.Router) error {
// '500': // '500':
// "$ref": "#/responses/InternalError" // "$ref": "#/responses/InternalError"
r.HandleFunc(VersionedPath("/libpod/containers/{name:..*}/stats"), APIHandler(s.Context, generic.StatsContainer)).Methods(http.MethodGet) r.HandleFunc(VersionedPath("/libpod/containers/{name:..*}/stats"), APIHandler(s.Context, generic.StatsContainer)).Methods(http.MethodGet)
// swagger:operation GET /libpod/containers/{nameOrID}/top containers topContainer // swagger:operation GET /libpod/containers/{nameOrID}/top libpod libpodTopContainer
// //
// List processes running inside a container. Note // List processes running inside a container. Note
// //
// --- // ---
// tags:
// - containers
// parameters: // parameters:
// - in: path // - in: path
// name: nameOrID // name: nameOrID
@ -810,7 +812,6 @@ func (s *APIServer) RegisterContainersHandlers(r *mux.Router) error {
// - application/json // - application/json
// responses: // responses:
// '200': // '200':
// description: no error
// "ref": "#/responses/DockerTopResponse" // "ref": "#/responses/DockerTopResponse"
// '404': // '404':
// "$ref": "#/responses/NoSuchContainer" // "$ref": "#/responses/NoSuchContainer"