Skip to content

Commit 6bc8715

Browse files
authored
Merge pull request #453 from jdolitsky/conformance-lock
Rewrite conformance action to enable locking to spec version
2 parents cbc8204 + d53866a commit 6bc8715

5 files changed

Lines changed: 120 additions & 13 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: conformance-action-pr
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
run:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: checkout source code
13+
uses: actions/checkout@v3
14+
- name: Start a test registry (zot)
15+
run: |
16+
set -x
17+
make registry-ci
18+
- name: Run OCI distribution-spec conformance
19+
env:
20+
OCI_ROOT_URL: http://localhost:5000
21+
OCI_NAMESPACE: myorg/myrepo
22+
OCI_TEST_PULL: 1
23+
OCI_TEST_PUSH: 1
24+
OCI_TEST_CONTENT_DISCOVERY: 1
25+
OCI_TEST_CONTENT_MANAGEMENT: 1
26+
uses: ./
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: conformance-action
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
run:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: checkout source code
13+
uses: actions/checkout@v3
14+
- name: Start a test registry (zot)
15+
run: |
16+
set -x
17+
make registry-ci
18+
- name: Run OCI distribution-spec conformance
19+
env:
20+
OCI_ROOT_URL: http://localhost:5000
21+
OCI_NAMESPACE: myorg/myrepo
22+
OCI_TEST_PULL: 1
23+
OCI_TEST_PUSH: 1
24+
OCI_TEST_CONTENT_DISCOVERY: 1
25+
OCI_TEST_CONTENT_MANAGEMENT: 1
26+
uses: ./

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
EPOCH_TEST_COMMIT := 91d6d8466e68f1efff7977b63ad6f48e72245e05
22
CURRENT_COMMIT := $(shell git log --format="%H" -n 1)
3+
CONFORMANCE_VERSION ?= $(CURRENT_COMMIT)
34

45
DOCKER ?= $(shell command -v docker 2>/dev/null)
56
PANDOC ?= $(shell command -v pandoc 2>/dev/null)
@@ -94,12 +95,14 @@ conformance-binary: $(OUTPUT_DIRNAME)/conformance.test
9495
TEST_REGISTRY_CONTAINER ?= ghcr.io/project-zot/zot-minimal-linux-amd64:v2.0.0-rc6@sha256:bf95a94849cd9c6f596fb10e5a2d03b74267e7886d1ba0b3dab33337d9e46e5c
9596
registry-ci:
9697
docker rm -f oci-conformance && \
98+
mkdir -p $(OUTPUT_DIRNAME) && \
9799
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
98100
docker run -d \
99101
-v $(shell pwd)/$(OUTPUT_DIRNAME)/zot-config.json:/etc/zot/config.json \
100102
--name=oci-conformance \
101103
-p 5000:5000 \
102-
$(TEST_REGISTRY_CONTAINER)
104+
$(TEST_REGISTRY_CONTAINER) && \
105+
sleep 5
103106

104107
conformance-ci:
105108
export OCI_ROOT_URL="http://localhost:5000" && \
@@ -108,10 +111,9 @@ conformance-ci:
108111
export OCI_TEST_PUSH=1 && \
109112
export OCI_TEST_CONTENT_DISCOVERY=1 && \
110113
export OCI_TEST_CONTENT_MANAGEMENT=1 && \
111-
sleep 5 && \
112114
$(shell pwd)/$(OUTPUT_DIRNAME)/conformance.test
113115

114116
$(OUTPUT_DIRNAME)/conformance.test:
115117
cd conformance && \
116118
CGO_ENABLED=0 go test -c -o $(shell pwd)/$(OUTPUT_DIRNAME)/conformance.test \
117-
--ldflags="-X github.com/opencontainers/distribution-spec/conformance.Version=$(CURRENT_COMMIT)"
119+
--ldflags="-X github.com/opencontainers/distribution-spec/conformance.Version=$(CONFORMANCE_VERSION)"

action.yml

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,64 @@ branding:
77
inputs: {}
88
outputs: {}
99
runs:
10-
using: docker
11-
image: "docker://ghcr.io/opencontainers/distribution-spec/conformance:v1.0.0@sha256:6302582c3b35169f7846282ad5b81471cd8814f30f7a958030e04fd82b19e17f"
10+
using: composite
11+
steps:
12+
- name: Check required env vars for OCI distribution-spec conformance
13+
shell: bash
14+
id: check-conformance
15+
run: |
16+
set -x
17+
required_env_vars=(
18+
"OCI_ROOT_URL"
19+
"OCI_NAMESPACE"
20+
)
21+
for v in ${required_env_vars[@]}; do
22+
if [[ "${!v}" == "" ]]; then
23+
echo "Error: the following environment variable is required: ${v}"
24+
exit 1
25+
fi
26+
done
27+
28+
- name: Build OCI distribution-spec conformance binary
29+
shell: bash
30+
id: build-conformance
31+
run: |
32+
set -x
33+
34+
# Enter the directory containing the checkout of this action which is surpisingly hard to do (but we did it... #OCI)
35+
cd "$(dirname $(find $(find ~/work/_actions -name distribution-spec -print -quit) -name Makefile -print -quit))"
36+
37+
# The .git folder is not present, but the dirname is the requested action ref, so use this as the conformance version
38+
conformance_version="$(basename "${PWD}")"
39+
echo "conformance-version=${conformance_version}" >> $GITHUB_OUTPUT
40+
41+
# Build the conformance binary
42+
CONFORMANCE_VERSION="${conformance_version}" OUTPUT_DIRNAME=bin make conformance-binary
43+
44+
# Add bin to the PATH so we can just run "conformance.test"
45+
echo "${PWD}/bin" >> $GITHUB_PATH
46+
47+
- name: Run OCI distribution-spec conformance binary
48+
shell: bash
49+
id: run-conformance
50+
run: |
51+
set -x
52+
set +e
53+
conformance.test
54+
conformance_rc="$?"
55+
set -e
56+
if [[ -f report.html ]]; then
57+
echo "Found report.html."
58+
echo "has-report=true" >> $GITHUB_OUTPUT
59+
fi
60+
echo "Conformance return code: ${conformance_rc}"
61+
exit ${conformance_rc}
62+
63+
- name: Upload OCI distribution-spec conformance results as build artifact
64+
if: always() && steps.run-conformance.outputs.has-report == 'true'
65+
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
66+
with:
67+
name: oci-distribution-spec-conformance-results-${{ steps.build-conformance.outputs.conformance-version }}
68+
path: |
69+
report.html
70+
junit.xml

conformance/README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ jobs:
229229
steps:
230230
- name: Run OCI Distribution Spec conformance tests
231231
uses: opencontainers/distribution-spec@main
232+
# you can also run against a specific tag or commit instead
233+
# uses: opencontainers/distribution-spec@v1.1.0
232234
env:
233235
OCI_ROOT_URL: https://myreg.io
234236
OCI_NAMESPACE: mytestorg/mytestrepo
@@ -241,14 +243,6 @@ jobs:
241243
OCI_HIDE_SKIPPED_WORKFLOWS: 0
242244
OCI_DEBUG: 0
243245
OCI_DELETE_MANIFEST_BEFORE_BLOBS: 0
244-
- run: mkdir -p .out/ && mv {report.html,junit.xml} .out/
245-
if: always()
246-
- name: Upload test results zip as build artifact
247-
uses: actions/upload-artifact@v1
248-
with:
249-
name: oci-test-results-${{ github.sha }}
250-
path: .out/
251-
if: always()
252246
```
253247
254248
You can also add a badge pointing to list of runs for this action using the following markdown:

0 commit comments

Comments
 (0)