Skip to content

Commit

Permalink
Automate conformance testing on PR using zot
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Dolitsky <josh@dolit.ski>
  • Loading branch information
jdolitsky committed Apr 4, 2023
1 parent 7fe7cbe commit bea9b6f
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,32 @@ jobs:
go-version: ${{ matrix.go }}

- name: run tests
id: tests
run: |
export PATH="$(go env GOPATH)/bin:${PATH}"
make install.tools
make .gitvalidation
make docs conformance
set +e
make conformance-ci
CONFORMANCE_RC="$?"
set -e
if [[ -f report.html ]]; then
echo "Found report.html."
echo "has-report=true" >> $GITHUB_OUTPUT
fi
# TODO: Fail with CONFORMANCE_RC if non-zero
# (conformance not yet passing for this registry)
echo "Conformance return code: ${CONFORMANCE_RC}"
exit 0
- name: Upload OCI conformance results as build artifact
if: always() && steps.tests.outputs.has-report == 'true'
uses: actions/upload-artifact@v3
with:
name: oci-conformance-results-${{ matrix.go }}
path: |
./report.html
./junit.xml
24 changes: 24 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,32 @@ jobs:
go-version: ${{ matrix.go }}

- name: run tests
id: tests
run: |
export PATH="$(go env GOPATH)/bin:${PATH}"
make install.tools
make .gitvalidation
make docs conformance
set +e
make conformance-ci
CONFORMANCE_RC="$?"
set -e
if [[ -f report.html ]]; then
echo "Found report.html."
echo "has-report=true" >> $GITHUB_OUTPUT
fi
# TODO: Fail with CONFORMANCE_RC if non-zero
# (conformance not yet passing for this registry)
echo "Conformance return code: ${CONFORMANCE_RC}"
exit 0
- name: Upload OCI conformance results as build artifact
if: always() && steps.tests.outputs.has-report == 'true'
uses: actions/upload-artifact@v3
with:
name: oci-conformance-results-${{ matrix.go }}
path: |
./report.html
./junit.xml
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ header.html
tags
go.mod
go.sum
junit.xml
report.html
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,24 @@ conformance-test:

conformance-binary: $(OUTPUT_DIRNAME)/conformance.test

TEST_REGISTRY_CONTAINER ?= ghcr.io/project-zot/zot-minimal-linux-amd64:v2.0.0-rc3
conformance-ci:
docker rm -f oci-conformance && \
echo '{"distSpecVersion":"1.1.0-dev","storage":{"rootDirectory":"/tmp/zot","gc":false,"dedupe":false},"http":{"address":"0.0.0.0","port":"5000"},"log":{"level":"debug"}}' > $(shell pwd)/$(OUTPUT_DIRNAME)/zot-config.json
docker run -d \
-v $(shell pwd)/$(OUTPUT_DIRNAME)/zot-config.json:/etc/zot/config.json \
--name=oci-conformance \
-p 5000:5000 \
$(TEST_REGISTRY_CONTAINER) && \
export OCI_ROOT_URL="http://localhost:5000" && \
export OCI_NAMESPACE="myorg/myrepo" && \
export OCI_TEST_PULL=1 && \
export OCI_TEST_PUSH=1 && \
export OCI_TEST_CONTENT_DISCOVERY=1 && \
export OCI_TEST_CONTENT_MANAGEMENT=1 && \
sleep 5 && \
$(shell pwd)/$(OUTPUT_DIRNAME)/conformance.test

$(OUTPUT_DIRNAME)/conformance.test:
cd conformance && \
CGO_ENABLED=0 go test -c -o $(shell pwd)/$(OUTPUT_DIRNAME)/conformance.test \
Expand Down

0 comments on commit bea9b6f

Please sign in to comment.