0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2025-03-11 02:17:43 -05:00

fix(ci/cd): detect uncommited swagger docs (#1724)

Signed-off-by: Alexei Dodon <adodon@cisco.com>
This commit is contained in:
Alexei Dodon 2023-08-23 19:21:43 +03:00 committed by GitHub
parent 6d65401499
commit ca2904762a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 53 additions and 45 deletions

View file

@ -1,10 +1,10 @@
name: Bug report name: Bug report
description: File a bug report description: File a bug report
title: "[Bug]: " title: "[Bug]: "
labels: bug labels: ["bug"]
body: body:
- type: input - type: input
attributes: attributes:
label: "zot version" label: "zot version"
placeholder: "v1.4.3 or commit hash" placeholder: "v1.4.3 or commit hash"
validations: validations:
@ -23,12 +23,12 @@ body:
1. Configuration 1. Configuration
2. Client tool used 2. Client tool used
3. Seen error 3. Seen error
- type: textarea - type: textarea
attributes: attributes:
label: "Expected behavior" label: "Expected behavior"
description: "A clear and concise description of what you expected to happen." description: "A clear and concise description of what you expected to happen."
- type: textarea - type: textarea
attributes: attributes:
label: "Screenshots" label: "Screenshots"

View file

@ -1,7 +1,7 @@
name: Feature request name: Feature request
description: Request a feature description: Request a feature
title: "[Feat]: " title: "[Feat]: "
labels: feature labels: ["feature"]
body: body:
- type: textarea - type: textarea
attributes: attributes:

View file

@ -88,11 +88,11 @@ jobs:
pip install localstack # Install LocalStack cli pip install localstack # Install LocalStack cli
docker pull localstack/localstack:1.3 # Make sure to pull the latest version of the image docker pull localstack/localstack:1.3 # Make sure to pull the latest version of the image
localstack start -d # Start LocalStack in the background localstack start -d # Start LocalStack in the background
echo "Waiting for LocalStack startup..." # Wait 30 seconds for the LocalStack container echo "Waiting for LocalStack startup..." # Wait 30 seconds for the LocalStack container
localstack wait -t 30 # to become ready before timing out localstack wait -t 30 # to become ready before timing out
echo "Startup complete" echo "Startup complete"
aws --endpoint-url=http://localhost:4566 s3api create-bucket --bucket zot-storage --region us-east-2 --create-bucket-configuration="{\"LocationConstraint\": \"us-east-2\"}" aws --endpoint-url=http://localhost:4566 s3api create-bucket --bucket zot-storage --region us-east-2 --create-bucket-configuration="{\"LocationConstraint\": \"us-east-2\"}"
aws dynamodb --endpoint-url http://localhost:4566 --region "us-east-2" create-table --table-name BlobTable --attribute-definitions AttributeName=Digest,AttributeType=S --key-schema AttributeName=Digest,KeyType=HASH --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5 aws dynamodb --endpoint-url http://localhost:4566 --region "us-east-2" create-table --table-name BlobTable --attribute-definitions AttributeName=Digest,AttributeType=S --key-schema AttributeName=Digest,KeyType=HASH --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5
env: env:

View file

@ -35,7 +35,7 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: | run: |
cd $GITHUB_WORKSPACE cd $GITHUB_WORKSPACE
go install github.com/swaggo/swag/cmd/swag go install github.com/swaggo/swag/cmd/swag@v1.8.12
go mod download go mod download
sudo apt-get update sudo apt-get update
sudo apt-get -y install rpm uidmap sudo apt-get -y install rpm uidmap
@ -56,7 +56,7 @@ jobs:
minio/minio:edge-cicd server /data minio/minio:edge-cicd server /data
- name: Install py minio - name: Install py minio
run: pip3 install minio run: pip3 install minio
- name: Wait for minio to come up - name: Wait for minio to come up
run: | run: |
curl --connect-timeout 5 \ curl --connect-timeout 5 \
@ -64,7 +64,7 @@ jobs:
--retry 12 \ --retry 12 \
--retry-max-time 120 \ --retry-max-time 120 \
'http://localhost:9000/minio/health/live' 'http://localhost:9000/minio/health/live'
- name: Create minio bucket - name: Create minio bucket
run: | run: |
python3 - <<'EOF' python3 - <<'EOF'
@ -88,7 +88,7 @@ jobs:
run: | run: |
sudo haproxy -d -f examples/cluster/haproxy.cfg -D sudo haproxy -d -f examples/cluster/haproxy.cfg -D
sleep 10 sleep 10
- name: Prepare configuration files - name: Prepare configuration files
run: | run: |
cp test/cluster/config-minio.json test/cluster/config-minio1.json cp test/cluster/config-minio.json test/cluster/config-minio1.json
@ -96,7 +96,7 @@ jobs:
cp test/cluster/config-minio.json test/cluster/config-minio2.json cp test/cluster/config-minio.json test/cluster/config-minio2.json
sed -i 's/8082/8083/g' test/cluster/config-minio.json sed -i 's/8082/8083/g' test/cluster/config-minio.json
cp test/cluster/config-minio.json test/cluster/config-minio3.json cp test/cluster/config-minio.json test/cluster/config-minio3.json
- name: Run push-pull tests - name: Run push-pull tests
run: | run: |
make binary make binary
@ -124,7 +124,7 @@ jobs:
env: env:
AWS_ACCESS_KEY_ID: minioadmin AWS_ACCESS_KEY_ID: minioadmin
AWS_SECRET_ACCESS_KEY: minioadmin AWS_SECRET_ACCESS_KEY: minioadmin
- name: Run benchmark with --src-cidr arg - name: Run benchmark with --src-cidr arg
run: | run: |
make bench make bench
@ -142,7 +142,7 @@ jobs:
env: env:
AWS_ACCESS_KEY_ID: minioadmin AWS_ACCESS_KEY_ID: minioadmin
AWS_SECRET_ACCESS_KEY: minioadmin AWS_SECRET_ACCESS_KEY: minioadmin
- name: Run benchmark with --src-ips arg - name: Run benchmark with --src-ips arg
run: | run: |
make bench make bench
@ -152,12 +152,12 @@ jobs:
sleep 10 sleep 10
# run zb with --src-ips # run zb with --src-ips
bin/zb-linux-amd64 -c 10 -n 50 -o ci-cd --src-ips 127.0.0.2,127.0.0.3,127.0.0.4,127.0.0.5,127.0.0.6,127.0.12.5,127.0.12.6 http://localhost:8080 bin/zb-linux-amd64 -c 10 -n 50 -o ci-cd --src-ips 127.0.0.2,127.0.0.3,127.0.0.4,127.0.0.5,127.0.0.6,127.0.12.5,127.0.12.6 http://localhost:8080
killall -r zot-* killall -r zot-*
env: env:
AWS_ACCESS_KEY_ID: minioadmin AWS_ACCESS_KEY_ID: minioadmin
AWS_SECRET_ACCESS_KEY: minioadmin AWS_SECRET_ACCESS_KEY: minioadmin
# Download previous benchmark result from cache (if exists) # Download previous benchmark result from cache (if exists)
- name: Download previous benchmark data - name: Download previous benchmark data
uses: actions/cache@v3 uses: actions/cache@v3

View file

@ -54,7 +54,7 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: | run: |
cd $GITHUB_WORKSPACE cd $GITHUB_WORKSPACE
go install github.com/swaggo/swag/cmd/swag@latest go install github.com/swaggo/swag/cmd/swag@v1.8.12
go mod download go mod download
go install github.com/wadey/gocovmerge@latest go install github.com/wadey/gocovmerge@latest
go get -u github.com/swaggo/swag/cmd/swag go get -u github.com/swaggo/swag/cmd/swag

View file

@ -25,7 +25,7 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: | run: |
cd $GITHUB_WORKSPACE cd $GITHUB_WORKSPACE
go install github.com/swaggo/swag/cmd/swag go install github.com/swaggo/swag/cmd/swag@v1.8.12
go mod download go mod download
sudo apt-get update sudo apt-get update
sudo apt-get install libgpgme-dev libassuan-dev libbtrfs-dev libdevmapper-dev pkg-config rpm uidmap sudo apt-get install libgpgme-dev libassuan-dev libbtrfs-dev libdevmapper-dev pkg-config rpm uidmap
@ -72,7 +72,7 @@ jobs:
run: | run: |
make test-bats-referrers make test-bats-referrers
- name: Run metadata tests - name: Run metadata tests
run: | run: |
make test-bats-metadata make test-bats-metadata
- name: Run push-pull tests - name: Run push-pull tests
run: | run: |
@ -101,10 +101,10 @@ jobs:
pip install localstack awscli-local[ver1] # install LocalStack cli and awslocal pip install localstack awscli-local[ver1] # install LocalStack cli and awslocal
docker pull localstack/localstack # Make sure to pull the latest version of the image docker pull localstack/localstack # Make sure to pull the latest version of the image
localstack start -d # Start LocalStack in the background localstack start -d # Start LocalStack in the background
echo "Waiting for LocalStack startup..." # Wait 30 seconds for the LocalStack container echo "Waiting for LocalStack startup..." # Wait 30 seconds for the LocalStack container
localstack wait -t 30 # to become ready before timing out localstack wait -t 30 # to become ready before timing out
echo "Startup complete" echo "Startup complete"
- name: Run cloud-only tests - name: Run cloud-only tests
run: | run: |
make test-cloud-only make test-cloud-only

View file

@ -22,7 +22,7 @@ jobs:
with: with:
cache: false cache: false
go-version: 1.20.x go-version: 1.20.x
- name: Run zb - name: Run zb
run: | run: |
make binary make binary

View file

@ -3,7 +3,7 @@ on:
schedule: schedule:
- cron: '30 1 * * *' - cron: '30 1 * * *'
workflow_dispatch: workflow_dispatch:
permissions: read-all permissions: read-all
# Here we are running two tests: # Here we are running two tests:
@ -40,10 +40,10 @@ jobs:
pip install localstack awscli-local[ver1] # install LocalStack cli and awslocal pip install localstack awscli-local[ver1] # install LocalStack cli and awslocal
docker pull localstack/localstack # Make sure to pull the latest version of the image docker pull localstack/localstack # Make sure to pull the latest version of the image
localstack start -d # Start LocalStack in the background localstack start -d # Start LocalStack in the background
echo "Waiting for LocalStack startup..." # Wait 30 seconds for the LocalStack container echo "Waiting for LocalStack startup..." # Wait 30 seconds for the LocalStack container
localstack wait -t 30 # to become ready before timing out localstack wait -t 30 # to become ready before timing out
echo "Startup complete" echo "Startup complete"
- name: Run restore s3 blobs after cache is deleted - name: Run restore s3 blobs after cache is deleted
run: | run: |
make test-restore-s3-blobs make test-restore-s3-blobs

View file

@ -6,7 +6,7 @@ name: conformance
# or API. # or API.
on: on:
push: push:
branches: branches:
- main - main
pull_request: pull_request:
branches: branches:
@ -25,7 +25,7 @@ jobs:
with: with:
cache: false cache: false
go-version: 1.20.x go-version: 1.20.x
- name: Checkout this PR - name: Checkout this PR
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Start zot server - name: Start zot server
run: | run: |
@ -57,7 +57,7 @@ jobs:
OCI_REFERRERS: 1 OCI_REFERRERS: 1
OCI_CROSSMOUNT_NAMESPACE: oci-conformance/crossmount-test OCI_CROSSMOUNT_NAMESPACE: oci-conformance/crossmount-test
run: | run: |
./conformance.test ./conformance.test
- run: mkdir -p .out/ && mv {report.html,junit.xml} .out/ - run: mkdir -p .out/ && mv {report.html,junit.xml} .out/
if: always() if: always()
- name: Upload test results zip as build artifact - name: Upload test results zip as build artifact

View file

@ -22,7 +22,7 @@ jobs:
# Needs for private repositories. # Needs for private repositories.
contents: read contents: read
actions: read actions: read
steps: steps:
- name: "Checkout code" - name: "Checkout code"
uses: actions/checkout@v3 # v3.0.0 uses: actions/checkout@v3 # v3.0.0
@ -41,8 +41,8 @@ jobs:
# repo_token: ${{ secrets.SCORECARD_READ_TOKEN }} # repo_token: ${{ secrets.SCORECARD_READ_TOKEN }}
# Publish the results for public repositories to enable scorecard badges. For more details, see # Publish the results for public repositories to enable scorecard badges. For more details, see
# https://github.com/ossf/scorecard-action#publishing-results. # https://github.com/ossf/scorecard-action#publishing-results.
# For private repositories, `publish_results` will automatically be set to `false`, regardless # For private repositories, `publish_results` will automatically be set to `false`, regardless
# of the value entered here. # of the value entered here.
publish_results: true publish_results: true
@ -54,7 +54,7 @@ jobs:
name: SARIF file name: SARIF file
path: results.sarif path: results.sarif
retention-days: 5 retention-days: 5
# Upload the results to GitHub's code scanning dashboard. # Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning" - name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@v2.21.4 # v1.0.26 uses: github/codeql-action/upload-sarif@v2.21.4 # v1.0.26

View file

@ -55,7 +55,7 @@ add-extensions = $(subst $(1),$(2),$(sort $(filter-valid)))
BUILD_LABELS = $(call add-extensions,$(space),$(comma)) BUILD_LABELS = $(call add-extensions,$(space),$(comma))
.PHONY: all .PHONY: all
all: modcheck swagger binary binary-minimal binary-debug cli bench exporter-minimal verify-config test covhtml check check-gh-actions all: modcheck swaggercheck binary binary-minimal binary-debug cli bench exporter-minimal verify-config test covhtml check check-gh-actions
.PHONY: modtidy .PHONY: modtidy
modtidy: modtidy:
@ -70,6 +70,15 @@ modcheck: modtidy
exit 1;\ exit 1;\
fi fi
.PHONY: swaggercheck
swaggercheck: swagger
$(eval UNCOMMITED_FILES = $(shell git status --porcelain | grep -c swagger))
@if [ $(UNCOMMITED_FILES) != 0 ]; then \
echo "Updated swagger files uncommitted, make sure all swagger files are committed:";\
git status;\
exit 1;\
fi
.PHONY: create-name .PHONY: create-name
create-name: create-name:
ifdef BUILD_LABELS ifdef BUILD_LABELS
@ -95,7 +104,7 @@ binary: modcheck create-name build-metadata
.PHONY: binary-debug .PHONY: binary-debug
binary-debug: $(if $(findstring ui,$(BUILD_LABELS)), ui) binary-debug: $(if $(findstring ui,$(BUILD_LABELS)), ui)
binary-debug: modcheck swagger create-name build-metadata binary-debug: modcheck swaggercheck create-name build-metadata
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot-$(OS)-$(ARCH)-debug $(BUILDMODE_FLAGS) -tags $(BUILD_LABELS),debug,containers_image_openpgp -v -gcflags all='-N -l' -ldflags "-X zotregistry.io/zot/pkg/api/config.ReleaseTag=${RELEASE_TAG} -X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=$(extended-name) -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION}" ./cmd/zot env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot-$(OS)-$(ARCH)-debug $(BUILDMODE_FLAGS) -tags $(BUILD_LABELS),debug,containers_image_openpgp -v -gcflags all='-N -l' -ldflags "-X zotregistry.io/zot/pkg/api/config.ReleaseTag=${RELEASE_TAG} -X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=$(extended-name) -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION}" ./cmd/zot
.PHONY: cli .PHONY: cli

View file

@ -452,7 +452,6 @@ func (rh *RouteHandler) CheckManifest(response http.ResponseWriter, request *htt
response.WriteHeader(http.StatusOK) response.WriteHeader(http.StatusOK)
} }
// NOTE: https://github.com/swaggo/swag/issues/387.
type ImageManifest struct { type ImageManifest struct {
ispec.Manifest ispec.Manifest
} }

View file

@ -1399,7 +1399,7 @@ const docTemplate = `{
"description": "Platform describes the platform which the image in the manifest runs on.\n\nThis should only be used when referring to a manifest.", "description": "Platform describes the platform which the image in the manifest runs on.\n\nThis should only be used when referring to a manifest.",
"allOf": [ "allOf": [
{ {
"$ref": "#/definitions/github_com_opencontainers_image-spec_specs-go_v1.Platform" "$ref": "#/definitions/v1.Platform"
} }
] ]
}, },
@ -1416,7 +1416,7 @@ const docTemplate = `{
} }
} }
}, },
"github_com_opencontainers_image-spec_specs-go_v1.Platform": { "v1.Platform": {
"type": "object", "type": "object",
"properties": { "properties": {
"architecture": { "architecture": {

View file

@ -1390,7 +1390,7 @@
"description": "Platform describes the platform which the image in the manifest runs on.\n\nThis should only be used when referring to a manifest.", "description": "Platform describes the platform which the image in the manifest runs on.\n\nThis should only be used when referring to a manifest.",
"allOf": [ "allOf": [
{ {
"$ref": "#/definitions/github_com_opencontainers_image-spec_specs-go_v1.Platform" "$ref": "#/definitions/v1.Platform"
} }
] ]
}, },
@ -1407,7 +1407,7 @@
} }
} }
}, },
"github_com_opencontainers_image-spec_specs-go_v1.Platform": { "v1.Platform": {
"type": "object", "type": "object",
"properties": { "properties": {
"architecture": { "architecture": {

View file

@ -185,7 +185,7 @@ definitions:
type: string type: string
platform: platform:
allOf: allOf:
- $ref: '#/definitions/github_com_opencontainers_image-spec_specs-go_v1.Platform' - $ref: '#/definitions/v1.Platform'
description: |- description: |-
Platform describes the platform which the image in the manifest runs on. Platform describes the platform which the image in the manifest runs on.
@ -199,7 +199,7 @@ definitions:
type: string type: string
type: array type: array
type: object type: object
github_com_opencontainers_image-spec_specs-go_v1.Platform: v1.Platform:
properties: properties:
architecture: architecture:
description: |- description: |-