Skip to content

Commit bea9b6f

Browse files
committed
Automate conformance testing on PR using zot
Signed-off-by: Josh Dolitsky <josh@dolit.ski>
1 parent 7fe7cbe commit bea9b6f

4 files changed

Lines changed: 68 additions & 0 deletions

File tree

.github/workflows/build-pr.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,32 @@ jobs:
2323
go-version: ${{ matrix.go }}
2424

2525
- name: run tests
26+
id: tests
2627
run: |
2728
export PATH="$(go env GOPATH)/bin:${PATH}"
2829
make install.tools
2930
make .gitvalidation
3031
make docs conformance
32+
33+
set +e
34+
make conformance-ci
35+
CONFORMANCE_RC="$?"
36+
set -e
37+
if [[ -f report.html ]]; then
38+
echo "Found report.html."
39+
echo "has-report=true" >> $GITHUB_OUTPUT
40+
fi
41+
42+
# TODO: Fail with CONFORMANCE_RC if non-zero
43+
# (conformance not yet passing for this registry)
44+
echo "Conformance return code: ${CONFORMANCE_RC}"
45+
exit 0
46+
47+
- name: Upload OCI conformance results as build artifact
48+
if: always() && steps.tests.outputs.has-report == 'true'
49+
uses: actions/upload-artifact@v3
50+
with:
51+
name: oci-conformance-results-${{ matrix.go }}
52+
path: |
53+
./report.html
54+
./junit.xml

.github/workflows/build.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,32 @@ jobs:
2323
go-version: ${{ matrix.go }}
2424

2525
- name: run tests
26+
id: tests
2627
run: |
2728
export PATH="$(go env GOPATH)/bin:${PATH}"
2829
make install.tools
2930
make .gitvalidation
3031
make docs conformance
32+
33+
set +e
34+
make conformance-ci
35+
CONFORMANCE_RC="$?"
36+
set -e
37+
if [[ -f report.html ]]; then
38+
echo "Found report.html."
39+
echo "has-report=true" >> $GITHUB_OUTPUT
40+
fi
41+
42+
# TODO: Fail with CONFORMANCE_RC if non-zero
43+
# (conformance not yet passing for this registry)
44+
echo "Conformance return code: ${CONFORMANCE_RC}"
45+
exit 0
46+
47+
- name: Upload OCI conformance results as build artifact
48+
if: always() && steps.tests.outputs.has-report == 'true'
49+
uses: actions/upload-artifact@v3
50+
with:
51+
name: oci-conformance-results-${{ matrix.go }}
52+
path: |
53+
./report.html
54+
./junit.xml

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ header.html
55
tags
66
go.mod
77
go.sum
8+
junit.xml
9+
report.html

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,24 @@ conformance-test:
9191

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

94+
TEST_REGISTRY_CONTAINER ?= ghcr.io/project-zot/zot-minimal-linux-amd64:v2.0.0-rc3
95+
conformance-ci:
96+
docker rm -f oci-conformance && \
97+
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
98+
docker run -d \
99+
-v $(shell pwd)/$(OUTPUT_DIRNAME)/zot-config.json:/etc/zot/config.json \
100+
--name=oci-conformance \
101+
-p 5000:5000 \
102+
$(TEST_REGISTRY_CONTAINER) && \
103+
export OCI_ROOT_URL="http://localhost:5000" && \
104+
export OCI_NAMESPACE="myorg/myrepo" && \
105+
export OCI_TEST_PULL=1 && \
106+
export OCI_TEST_PUSH=1 && \
107+
export OCI_TEST_CONTENT_DISCOVERY=1 && \
108+
export OCI_TEST_CONTENT_MANAGEMENT=1 && \
109+
sleep 5 && \
110+
$(shell pwd)/$(OUTPUT_DIRNAME)/conformance.test
111+
94112
$(OUTPUT_DIRNAME)/conformance.test:
95113
cd conformance && \
96114
CGO_ENABLED=0 go test -c -o $(shell pwd)/$(OUTPUT_DIRNAME)/conformance.test \

0 commit comments

Comments
 (0)