0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-30 22:34:13 -05:00

ci/cd: add a basic push-pull testing using client tools

Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
This commit is contained in:
Ramkumar Chinchani 2022-02-04 17:44:16 +00:00 committed by Ramkumar Chinchani
parent f89925fb27
commit c73e71b018
3 changed files with 76 additions and 4 deletions

46
.github/workflows/ecosystem-tools.yaml vendored Normal file
View file

@ -0,0 +1,46 @@
name: "Ecosystem client tools"
on:
push:
branches:
- main
pull_request:
branches: [main]
release:
types:
- published
jobs:
client-tools:
name: Check client tools
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.17.x
- name: Install dependencies
run: |
cd $GITHUB_WORKSPACE
go get -u github.com/swaggo/swag/cmd/swag
go mod download
sudo apt-get update
sudo apt-get -y install rpm uidmap
# install skopeo
. /etc/os-release
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key | sudo apt-key add -
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install skopeo
# install notation
curl -Lo notation.tar.gz https://github.com/notaryproject/notation/releases/download/v0.7.1-alpha.1/notation_0.7.1-alpha.1_linux_amd64.tar.gz
sudo tar xvzf notation.tar.gz -C /usr/bin notation
# install oras
curl -LO https://github.com/oras-project/oras/releases/download/v0.12.0/oras_0.12.0_linux_amd64.tar.gz
mkdir -p oras-install/
tar -zxf oras_0.12.0_*.tar.gz -C oras-install/
sudo mv oras-install/oras /usr/bin/
rm -rf oras_0.12.0_*.tar.gz oras-install/
- name: Run push-pull tests
run: |
make push-pull

View file

@ -15,7 +15,7 @@ ARCH ?= amd64
BENCH_OUTPUT ?= stdout
.PHONY: all
all: swagger binary binary-minimal binary-debug binary-arch binary-arch-minimal cli cli-arch bench bench-arch exporter-minimal verify-config test test-clean check
all: swagger binary binary-minimal binary-debug binary-arch binary-arch-minimal cli cli-arch bench bench-arch exporter-minimal verify-config test covhtml test-clean check
.PHONY: binary-minimal
binary-minimal: swagger
@ -79,6 +79,28 @@ run-bench: binary bench
bin/zb -c 10 -n 100 -o $(BENCH_OUTPUT) http://localhost:8080
killall zot
.PHONY: push-pull
push-pull: binary check-skopeo
bin/zot serve examples/config-minimal.json &
sleep 5
# skopeo push/pull
skopeo --debug copy --format=oci --dest-tls-verify=false docker://ghcr.io/project-zot/golang:1.17 docker://localhost:8080/golang:1.17
skopeo --debug copy --src-tls-verify=false docker://localhost:8080/golang:1.17 oci:golang:1.17
# oras artifacts
echo "{\"name\":\"foo\",\"value\":\"bar\"}" > config.json
echo "hello world" > artifact.txt
oras push localhost:8080/hello-artifact:v2 \
--manifest-config config.json:application/vnd.acme.rocket.config.v1+json \
artifact.txt:text/plain -d -v
rm -f artifact.txt # first delete the file
oras pull localhost:8080/hello-artifact:v2 -d -v -a
grep -q "hello world" artifact.txt # should print "hello world"
if [ $? -ne 0 ]; then \
killall zot; \
exit 1; \
fi
killall zot
.PHONY: test-clean
test-clean:
$(shell sudo rm -rf /etc/containers/certs.d/127.0.0.1:8089/)

View file

@ -551,10 +551,14 @@ func (is *ImageStoreFS) PutImageManifest(repo string, reference string, mediaTyp
return "", zerr.ErrBadManifest
}
if manifest.Config.MediaType == ispec.MediaTypeImageConfig {
digest, err := is.validateOCIManifest(repo, reference, &manifest)
if err != nil {
is.log.Error().Err(err).Msg("invalid oci image manifest")
return digest, err
}
}
} else if mediaType == artifactspec.MediaTypeArtifactManifest {
var m notation.Descriptor
if err := json.Unmarshal(body, &m); err != nil {