Skip to content

Commit

Permalink
ci: Add distribution registry validation test
Browse files Browse the repository at this point in the history
  • Loading branch information
STARRY-S committed Nov 25, 2024
1 parent 5e2e801 commit b6b1d64
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 6 deletions.
60 changes: 59 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- main
- dev
- dev*
jobs:
ci:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -48,3 +48,61 @@ jobs:
env:
TAG: dev
REPO: ${{ vars.PUBLIC_REGISTRY_REPO }}
validation-test:
runs-on: ubuntu-latest
services:
registry:
image: "registry:2"
ports:
- 5000:5000
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y util-linux libgpgme-dev libassuan-dev \
libbtrfs-dev libdevmapper-dev pkg-config gcc iproute2
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Build single target
env:
TAG: ${{ github.ref_name }}
COMMIT: ${{ github.sha }}
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v2"
args: build --clean --snapshot --single-target
- name: Setup testing environment
run: |
set -x
pip install pytest tox
pip install -r test/requirements.txt
sudo mkdir -p /etc/containers/registries.d
sudo cp package/default-policy.json /etc/containers/policy.json
sudo cp package/registries.d/default.yaml /etc/containers/registries.d/default.yaml
sudo cp ./dist/hangar_linux_amd64*/hangar /usr/local/bin/
# TODO: Workaround for permission denied when accessing '/run/containers/1001/auth.json'
sudo mkdir -p /run/containers/$UID
sudo chmod 755 /run/
sudo chmod 755 /run/containers
sudo chmod 755 /run/containers/$UID
sudo chown $UID /run/containers/$UID
sudo ls -al /run/containers/$UID
hangar version
echo "Done setup validation test environment"
- name: Distribution Registry Validation test
env:
REGISTRY_URL: 127.0.0.1:5000
run: |
cd test/
tox -e distribution_registry
4 changes: 2 additions & 2 deletions test/scripts/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
set -euo pipefail

# Configuration for Harbor
export HARBOR_HELM_VERSION="v1.14.2"
export HARBOR_URL="localhost"
export HARBOR_HELM_VERSION="v1.16.0"
export HARBOR_URL=${HARBOR_URL:-'localhost'}
export HARBOR_PORT="443" # ingress https
export HARBOR_PASSWORD="testpassword123"
export K3S_CLUSTER_NAME="testharbor"
Expand Down
8 changes: 7 additions & 1 deletion test/scripts/harbor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function setup_harbor() {
sleep 1
done
fi
k3d cluster create -p ${HARBOR_PORT}:${HARBOR_PORT} ${K3S_CLUSTER_NAME}
k3d cluster create --network host ${K3S_CLUSTER_NAME}
sleep 3 # Add some timeout

echo "Install harbor helm chart.."
Expand Down Expand Up @@ -58,6 +58,12 @@ function setup_harbor() {
k3d cluster delete ${K3S_CLUSTER_NAME} || true
exit 1
fi

echo "Wait a few seconds for harbor server ready"
sleep 10 # Add timeout for harbor ready
echo "---------- all pods ----------"
kubectl get pods -A
echo "------------------------------"
}

function delete_k3s_cluster() {
Expand Down
4 changes: 2 additions & 2 deletions test/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ while [[ $# -gt 0 ]]; do
esac
done

tox -e flake8

if [[ ${HARBOR:-} = "" ]] && [[ ${DISTRIBUTION:-} = "" ]]; then
HARBOR=1
DISTRIBUTION=1
Expand Down Expand Up @@ -86,5 +88,3 @@ if [[ ${DISTRIBUTION:-} != "" ]]; then
delete_distribution_registry
echo "Hangar validation test with Distribution registry: Done"
fi

tox -e flake8
6 changes: 6 additions & 0 deletions test/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ deps = -r requirements.txt
changedir = suite
commands =
pytest -v -n 4 --dist=loadfile .

[testenv:distribution_registry]
deps = -r requirements.txt
changedir = suite
commands =
pytest -v -n 4 --dist=loadfile .

0 comments on commit b6b1d64

Please sign in to comment.