Skip to content

Commit

Permalink
Update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mdellweg committed Jun 21, 2024
1 parent 5c5d77c commit 50f21a9
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 15 deletions.
7 changes: 7 additions & 0 deletions .ci/container_setup.d/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Files in this directory of the form '<number>-<name>.sh' are executed in alphabetical order.
They can assume to be provided with the following environmnent variables:
* PULP_CLI_CONFIG a path to a config file for the ci container
* CONTAINER_RUNTIME the command for interacting with containers
* BASE_PATH the directory the 'run_container.sh' script lives in

Also a running container named 'pulp-ephemeral'.
58 changes: 48 additions & 10 deletions .ci/run_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ then
fi
export CONTAINER_RUNTIME

TMPDIR="$(mktemp -d)"

cleanup () {
"${CONTAINER_RUNTIME}" stop pulp-ephemeral && true
rm -rf "${TMPDIR}"
}

trap cleanup EXIT
trap cleanup INT

if [ -z "${KEEP_CONTAINER:+x}" ]
then
RM="yes"
Expand All @@ -38,12 +48,36 @@ else
SELINUX=""
fi;

"${CONTAINER_RUNTIME}" run ${RM:+--rm} --env S6_KEEP_ENV=1 ${PULP_API_ROOT:+--env PULP_API_ROOT} --detach --name "pulp-ephemeral" --volume "${BASEPATH}/settings:/etc/pulp${SELINUX:+:Z}" --publish "8080:80" "ghcr.io/pulp/pulp:${IMAGE_TAG}"
mkdir -p "${TMPDIR}/settings/certs"
cp "${BASEPATH}/settings/settings.py" "${TMPDIR}/settings"

# shellcheck disable=SC2064
trap "${CONTAINER_RUNTIME} stop pulp-ephemeral" EXIT
# shellcheck disable=SC2064
trap "${CONTAINER_RUNTIME} stop pulp-ephemeral" INT
if [ -z "${PULP_HTTPS:+x}" ]
then
PROTOCOL="http"
PORT="80"
PULP_CONTENT_ORIGIN="http://localhost:8080/"
else
PROTOCOL="https"
PORT="443"
PULP_CONTENT_ORIGIN="https://localhost:8080/"
python3 -m trustme -d "${TMPDIR}/settings/certs"
export PULP_CA_BUNDLE="${TMPDIR}/settings/certs/client.pem"
ln -fs server.pem "${TMPDIR}/settings/certs/pulp_webserver.crt"
ln -fs server.key "${TMPDIR}/settings/certs/pulp_webserver.key"
fi
export PULP_CONTENT_ORIGIN

"${CONTAINER_RUNTIME}" \
run ${RM:+--rm} \
--env S6_KEEP_ENV=1 \
${PULP_HTTPS:+--env PULP_HTTPS} \
${PULP_API_ROOT:+--env PULP_API_ROOT} \
--env PULP_CONTENT_ORIGIN \
--detach \
--name "pulp-ephemeral" \
--volume "${TMPDIR}/settings:/etc/pulp${SELINUX:+:Z}" \
--publish "8080:${PORT}" \
"ghcr.io/pulp/pulp:${IMAGE_TAG}"

echo "Wait for pulp to start."
for counter in $(seq 40 -1 0)
Expand All @@ -58,23 +92,27 @@ do
fi

sleep 3
if curl --fail "http://localhost:8080${PULP_API_ROOT:-/pulp/}api/v3/status/" > /dev/null 2>&1
if curl --insecure --fail "${PROTOCOL}://localhost:8080${PULP_API_ROOT:-/pulp/}api/v3/status/" > /dev/null 2>&1
then
echo "SUCCESS."
break
fi
echo "."
done

# show pulpcore/plugin versions we're using
curl -s "http://localhost:8080${PULP_API_ROOT:-/pulp/}api/v3/status/" | jq '.versions|map({key: .component, value: .version})|from_entries'

# Set admin password
"${CONTAINER_RUNTIME}" exec "pulp-ephemeral" pulpcore-manager reset-admin-password --password password

# Create pulp config
PULP_CLI_CONFIG="${TMPDIR}/settings/certs/cli.toml"
export PULP_CLI_CONFIG
pulp config create --overwrite --location "${PULP_CLI_CONFIG}" --base-url "${PROTOCOL}://localhost:8080" ${PULP_API_ROOT:+--api-root "${PULP_API_ROOT}"} --username "admin" --password "password"
# show pulpcore/plugin versions we're using
pulp --config "${PULP_CLI_CONFIG}" --refresh-api status

if [ -d "${BASEPATH}/container_setup.d/" ]
then
run-parts --regex '^[0-9]+-[-_[:alnum:]]*\.sh$' "${BASEPATH}/container_setup.d/"
run-parts --exit-on-error --regex '^[0-9]+-[-_[:alnum:]]*\.sh$' "${BASEPATH}/container_setup.d/"
fi

PULP_LOGGING="${CONTAINER_RUNTIME}" "$@"
1 change: 0 additions & 1 deletion .ci/settings/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CONTENT_ORIGIN = "http://localhost:8080/"
ALLOWED_EXPORT_PATHS = ["/tmp"]
ORPHAN_PROTECTION_TIME = 0
ANALYTICS = False
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:

jobs:
test:
if: "endsWith(github.base_ref, 'main')"
runs-on: "ubuntu-20.04"
steps:
- uses: "actions/checkout@v4"
Expand All @@ -22,5 +23,12 @@ jobs:
- name: "Install Test Dependencies"
run: |
pip install -r doc_requirements.txt
- name: Build docs
run: make docs
- name: "Build docs"
run: |
make docs
no-test:
if: "!endsWith(github.base_ref, 'main')"
runs-on: "ubuntu-20.04"
steps:
- run: |
echo "Skip docs testing on non-main branches."
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ jobs:
IMAGE_TAG: ${{ matrix.image_tag }}
FROM_TAG: ${{ matrix.from_tag }}
CONTAINER_FILE: ${{ matrix.container_file }}
PULP_HTTPS: ${{ matrix.pulp_https }}
PULP_API_ROOT: ${{ matrix.pulp_api_root }}
run: .ci/run_container.sh make test
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ __pycache__/
build/
tests/cli.toml
pytest_pulp_cli/GPG-PRIVATE-KEY-fixture-signing
/.ci/settings/certs
site/
dist/
*.po~
2 changes: 1 addition & 1 deletion lint_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Lint requirements
black==24.4.2
flake8==7.0.0
flake8==7.1.0
flake8-pyproject==1.2.3
isort==5.13.2
mypy==1.10.0
Expand Down

0 comments on commit 50f21a9

Please sign in to comment.