Skip to content

Commit

Permalink
[redhat-3.7] oci: Create workflow for OCI Conformance (PROJQUAY-2812) (
Browse files Browse the repository at this point in the history
…#1744)

* Create workflow for OCI Conformance

* Set ubuntu runner to be 20.04 (#1666)

(cherry picked from commit e07b8ef)

* Use real Quay image for OCI tests (#1687)

Co-authored-by: Oleg Bulatov <oleg@bulatov.me>

---------

Co-authored-by: Oleg Bulatov <oleg@bulatov.me>
Co-authored-by: Dave O'Connor <1656866+HammerMeetNail@users.noreply.github.com>
  • Loading branch information
3 people committed Feb 7, 2023
1 parent 5b1d1f6 commit 7c22f8e
Show file tree
Hide file tree
Showing 2 changed files with 188 additions and 64 deletions.
71 changes: 7 additions & 64 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
jobs:
build:
name: Format
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:

- uses: actions/checkout@v2
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
unit:
name: Unit Test
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:

- uses: actions/checkout@v2
Expand All @@ -66,7 +66,7 @@ jobs:

e2e:
name: E2E Tests
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:

- uses: actions/checkout@v2
Expand All @@ -87,7 +87,7 @@ jobs:

registry:
name: E2E Registry Tests
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:

- uses: actions/checkout@v2
Expand All @@ -108,7 +108,7 @@ jobs:

docker:
name: Docker Build
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Docker Build
Expand All @@ -118,7 +118,7 @@ jobs:

mysql:
name: E2E MySQL Test
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:

- uses: actions/checkout@v2
Expand All @@ -142,7 +142,7 @@ jobs:

psql:
name: E2E Postgres Test
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:

- uses: actions/checkout@v2
Expand All @@ -163,60 +163,3 @@ jobs:
- name: tox
run: tox -e py38-psql

oci:
name: OCI Conformance
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2
- uses: actions/checkout@v2
with:
repository: opencontainers/distribution-spec
path: dist-spec

- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8

- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.14

- name: Set GOPATH
run: |
# temporary fix for https://github.com/actions/setup-go/issues/14
echo "GOPATH=$(dirname $GITHUB_WORKSPACE)" >> $GITHUB_ENV
echo "$(dirname $GITHUB_WORKSPACE)/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
# Quay
sudo apt-get update
sudo apt-get install libgpgme-dev libldap2-dev libsasl2-dev swig
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
# Conformance
cd dist-spec/conformance
go mod vendor
CGO_ENABLED=0 go test -c -o conformance.test
- name: conformance
env:
TEST: 'true'
PYTHONPATH: '.'
run: TEST=true PYTHONPATH=. pytest test/registry/conformance_tests.py -s -vv

- name: Copy report
run: mkdir -p .report/ && mv {report.html,junit.xml} .report/
if: always()

- name: Upload test results
uses: actions/upload-artifact@v1
with:
name: oci-test-results-${{ github.sha }}
path: .report/
if: always()
181 changes: 181 additions & 0 deletions .github/workflows/oci-distribution-spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
name: OCI Distribution Spec
on:
# See the documentation for more intricate event dispatch here:
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#on
push:
branches:
- "!dependabot/*"
- "*"
pull_request:
branches:
- "*"
jobs:
oci:
name: OCI Distribution Spec
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres_user
POSTGRES_PASSWORD: postgres_password
POSTGRES_DB: postgres_db
POSTGRES_PORT: 5432
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:latest
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Enable pg_trgm extension
run: |
psql "postgresql://postgres_user:postgres_password@localhost:5432/postgres_db" \
--command="create extension if not exists pg_trgm;"
- uses: actions/checkout@v3

- uses: actions/checkout@v3
with:
repository: opencontainers/distribution-spec
path: dist-spec

- name: Set up Go 1.18
uses: actions/setup-go@v3
with:
go-version: 1.18

- name: Build conformance.test binary
run: |
cd dist-spec/conformance
CGO_ENABLED=0 go test -c -o conformance.test
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and export to Docker
uses: docker/build-push-action@v3
with:
context: .
load: true
tags: localhost/quay
cache-from: type=gha
cache-to: type=gha

- name: Start Quay
run: |
IP=$(ip addr show dev eth0 | sed -n 's: *inet \([0-9.]*\)/.*:\1:p')
mkdir -p /tmp/config
cat >/tmp/config/config.yaml <<EOF
BUILDLOGS_REDIS: {"host": "$IP", "port": 6379}
DATABASE_SECRET_KEY: anothercrazykey!
DB_URI: postgresql://postgres_user:postgres_password@$IP:5432/postgres_db
DISTRIBUTED_STORAGE_CONFIG: {"default": ["LocalStorage", {"storage_path": "/datastorage/registry"}]}
DISTRIBUTED_STORAGE_PREFERENCE: ["default"]
SERVER_HOSTNAME: localhost
SETUP_COMPLETE: true
USER_EVENTS_REDIS: {"host": "$IP", "port": 6379}
DATA_MODEL_CACHE_CONFIG:
engine: memcached
endpoint: [127.0.0.1, 18080]
repository_blob_cache_ttl: 60s
catalog_page_cache_ttl: 60s
namespace_geo_restrictions_cache_ttl: 240s
# OCI Conformance tests don't expect tags to be cached.
# If we implement cache invalidation, we can enable it back.
active_repo_tags_cache_ttl: 0s
appr_applications_list_cache_ttl: 3600s
appr_show_package_cache_ttl: 3600s
EOF
# Run the Quay container. See also:
# https://access.redhat.com/documentation/en-us/red_hat_quay/3.8/html/deploy_red_hat_quay_-_high_availability/deploying_red_hat_quay
docker run \
--detach \
--health-cmd="curl -f http://localhost:8080/health/instance" \
--health-interval=10s \
--health-retries=5 \
--health-timeout=5s \
--name=quay \
--publish=127.0.0.1:443:8443/tcp \
--publish=127.0.0.1:80:8080/tcp \
--volume=/tmp/config:/conf/stack:Z \
localhost/quay
for i in 1 2 3 4 5 6 7 8 9 10; do
status=$(docker inspect -f '{{.State.Health.Status}}' quay)
printf "[%s] status: %s\n" "$(date -u +'%F %T')" "$status"
if [ "$status" == "healthy" ]; then
break
fi
sleep 5
done
docker exec -i quay python <<EOF
from app import app
from data import model
from data.database import configure
configure(app.config)
myuser = model.user.create_user("myuser", "p@ssw0rd", "admin@localhost.local", auto_verify=True)
myorg = model.organization.create_organization("myorg", "myorg@localhost.local", myuser)
EOF
- name: Run conformance tests
run: |
# Registry details
export OCI_ROOT_URL="http://localhost"
export OCI_NAMESPACE="myuser/myrepo"
export OCI_CROSSMOUNT_NAMESPACE="myorg/other"
export OCI_USERNAME="myuser"
export OCI_PASSWORD="p@ssw0rd"
# Which workflows to run
export OCI_TEST_PULL=1
export OCI_TEST_PUSH=1
export OCI_TEST_CONTENT_DISCOVERY=1
export OCI_TEST_CONTENT_MANAGEMENT=0
# Extra settings
export OCI_HIDE_SKIPPED_WORKFLOWS=0
export OCI_DEBUG=1
export OCI_DELETE_MANIFEST_BEFORE_BLOBS=0
./dist-spec/conformance/conformance.test
- name: Create report
run: |
mkdir -p .oci-test-results/ .logs/
mv report.html junit.xml .oci-test-results/ || true
docker logs quay >.logs/quay.log 2>&1 || true
if: always()

- name: Stop Quay
run: |
docker rm --force --volumes quay
if: always()

- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: oci-test-results
path: .oci-test-results/
if: always()

- name: Upload Quay logs
uses: actions/upload-artifact@v3
with:
name: logs
path: .logs/
if: always()

0 comments on commit 7c22f8e

Please sign in to comment.