Skip to content

Commit 97ae70b

Browse files
committed
Update CI files
[noissue]
1 parent 189da4a commit 97ae70b

9 files changed

Lines changed: 49 additions & 19 deletions

File tree

.ci/ansible/Containerfile.j2

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ RUN pip3 install \
2727
{{ " " }}"{{ item.source }}"
2828
{%- endfor %}
2929

30-
RUN mkdir -p /etc/nginx/pulp/
30+
USER pulp:pulp
31+
RUN PULP_STATIC_ROOT=/var/lib/operator/static/ PULP_CONTENT_ORIGIN=localhost \
32+
/usr/local/bin/pulpcore-manager collectstatic --clear --noinput --link
33+
USER root:root
34+
3135
{% for item in plugins %}
3236
RUN export plugin_path="$(pip3 show {{ item.name }} | sed -n -e 's/Location: //p')/{{ item.name }}" && \
3337
ln $plugin_path/app/webserver_snippets/nginx.conf /etc/nginx/pulp/{{ item.name }}.conf || true

.ci/ansible/start_container.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
community.crypto.openssh_keypair:
2020
path: ssh/id_ed25519
2121
type: ed25519
22+
owner: 700 # pulp in the container
23+
become: true
2224
when: stream_test | default(false)
2325

2426
- name: "Generate Pulp Settings"

.github/template_gitref

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2021.08.26-174-g56e0727
1+
2021.08.26-185-g0d1e7a4

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ jobs:
196196

197197
- name: Extract Deprecations from Logs
198198
id: deprecations
199-
run: echo "::set-output name=deprecations-${{ matrix.env.TEST }}::$(docker logs pulp 2>&1 | grep -i pulpcore.deprecation | base64 -w 0)"
199+
run: echo deprecations-${{ matrix.env.TEST }}=$(docker logs pulp 2>&1 | grep -i pulpcore.deprecation | base64 -w 0) >> $GITHUB_OUTPUT
200200

201201
- name: Logs
202202
if: always()

.github/workflows/scripts/before_script.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ tail -v -n +1 .ci/ansible/vars/main.yaml
2929
echo "PULP CONFIG:"
3030
tail -v -n +1 .ci/ansible/settings/settings.* ~/.config/pulp_smash/settings.json
3131

32+
# Needed for some functional tests
33+
cmd_prefix bash -c "echo '%wheel ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/nopasswd"
34+
cmd_prefix bash -c "usermod -a -G wheel pulp"
35+
3236
SCENARIOS=("pulp" "performance" "azure" "s3" "stream" "plugin-from-pypi" "generate-bindings")
3337
if [[ " ${SCENARIOS[*]} " =~ " ${TEST} " ]]; then
3438
# Many functional tests require these

.github/workflows/scripts/install.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ services:
7979
volumes:
8080
- ./settings:/etc/pulp
8181
- ./ssh:/keys/
82-
- ~/.config:/root/.config
82+
- ~/.config:/var/lib/pulp/.config
8383
- ../../../pulp-openapi-generator:/root/pulp-openapi-generator
8484
env:
8585
PULP_WORKERS: "4"
@@ -156,6 +156,15 @@ fi
156156

157157
ansible-playbook build_container.yaml
158158
ansible-playbook start_container.yaml
159+
160+
# .config needs to be accessible by the pulp user in the container, but some
161+
# files will likely be modified on the host by post/pre scripts.
162+
chmod 777 ~/.config/pulp_smash/
163+
chmod 666 ~/.config/pulp_smash/settings.json
164+
sudo chown -R 700:700 ~runner/.config
165+
# Plugins often write to ~/.config/pulp/cli.toml from the host
166+
sudo chmod 777 ~runner/.config/pulp
167+
sudo chmod 666 ~runner/.config/pulp/cli.toml
159168
echo ::group::SSL
160169
# Copy pulp CA
161170
sudo docker cp pulp:/etc/pulp/certs/pulp_webserver.crt /usr/local/share/ca-certificates/pulp_webserver.crt

.github/workflows/scripts/script.sh

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ fi
6464
echo "machine pulp
6565
login admin
6666
password password
67-
" | cmd_stdin_prefix bash -c "cat > /root/.netrc"
68-
cmd_stdin_prefix bash -c "chmod og-rw /root/.netrc"
67+
" | cmd_user_stdin_prefix bash -c "cat >> ~pulp/.netrc"
68+
# Some commands like ansible-galaxy specifically require 600
69+
cmd_user_stdin_prefix bash -c "chmod 600 ~pulp/.netrc"
6970

7071
cat unittest_requirements.txt | cmd_stdin_prefix bash -c "cat > /tmp/unittest_requirements.txt"
7172
cat functest_requirements.txt | cmd_stdin_prefix bash -c "cat > /tmp/functest_requirements.txt"
@@ -90,17 +91,17 @@ cmd_prefix bash -c "cat /etc/pulp/certs/pulp_webserver.crt | tee -a "$CERTIFI"
9091

9192
# check for any uncommitted migrations
9293
echo "Checking for uncommitted migrations..."
93-
cmd_prefix bash -c "django-admin makemigrations --check --dry-run"
94+
cmd_user_prefix bash -c "django-admin makemigrations --check --dry-run"
9495

9596
# Run unit tests.
96-
cmd_prefix bash -c "PULP_DATABASES__default__USER=postgres pytest -v -r sx --color=yes -p no:pulpcore --pyargs pulp_file.tests.unit"
97+
cmd_user_prefix bash -c "PULP_DATABASES__default__USER=postgres pytest -v -r sx --color=yes -p no:pulpcore --pyargs pulp_file.tests.unit"
9798

9899
# Run functional tests
99100
if [[ "$TEST" == "performance" ]]; then
100101
if [[ -z ${PERFORMANCE_TEST+x} ]]; then
101-
cmd_prefix bash -c "pytest -vv -r sx --color=yes --pyargs --capture=no --durations=0 pulp_file.tests.performance"
102+
cmd_user_prefix bash -c "pytest -vv -r sx --color=yes --pyargs --capture=no --durations=0 pulp_file.tests.performance"
102103
else
103-
cmd_prefix bash -c "pytest -vv -r sx --color=yes --pyargs --capture=no --durations=0 pulp_file.tests.performance.test_$PERFORMANCE_TEST"
104+
cmd_user_prefix bash -c "pytest -vv -r sx --color=yes --pyargs --capture=no --durations=0 pulp_file.tests.performance.test_$PERFORMANCE_TEST"
104105
fi
105106
exit
106107
fi
@@ -110,20 +111,20 @@ if [ -f $FUNC_TEST_SCRIPT ]; then
110111
else
111112

112113
if [[ "$GITHUB_WORKFLOW" == "File Nightly CI/CD" ]] || [[ "${RELEASE_WORKFLOW:-false}" == "true" ]]; then
113-
cmd_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulp_file.tests.functional -m parallel -n 8 --nightly"
114-
cmd_prefix bash -c "pytest -v -r sx --color=yes --pyargs pulp_file.tests.functional -m 'not parallel' --nightly"
114+
cmd_user_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulp_file.tests.functional -m parallel -n 8 --nightly"
115+
cmd_user_prefix bash -c "pytest -v -r sx --color=yes --pyargs pulp_file.tests.functional -m 'not parallel' --nightly"
115116

116117

117-
cmd_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulpcore.tests.functional -m 'from_pulpcore_for_all_plugins and parallel' -n 8 --nightly"
118-
cmd_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulpcore.tests.functional -m 'from_pulpcore_for_all_plugins and not parallel' --nightly"
118+
cmd_user_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulpcore.tests.functional -m 'from_pulpcore_for_all_plugins and parallel' -n 8 --nightly"
119+
cmd_user_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulpcore.tests.functional -m 'from_pulpcore_for_all_plugins and not parallel' --nightly"
119120

120121
else
121-
cmd_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulp_file.tests.functional -m parallel -n 8"
122-
cmd_prefix bash -c "pytest -v -r sx --color=yes --pyargs pulp_file.tests.functional -m 'not parallel'"
122+
cmd_user_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulp_file.tests.functional -m parallel -n 8"
123+
cmd_user_prefix bash -c "pytest -v -r sx --color=yes --pyargs pulp_file.tests.functional -m 'not parallel'"
123124

124125

125-
cmd_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulpcore.tests.functional -m 'from_pulpcore_for_all_plugins and parallel' -n 8"
126-
cmd_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulpcore.tests.functional -m 'from_pulpcore_for_all_plugins and not parallel'"
126+
cmd_user_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulpcore.tests.functional -m 'from_pulpcore_for_all_plugins and parallel' -n 8"
127+
cmd_user_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulpcore.tests.functional -m 'from_pulpcore_for_all_plugins and not parallel'"
127128

128129
fi
129130

.github/workflows/scripts/utils.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@ cmd_prefix() {
1414
docker exec "$PULP_CI_CONTAINER" "$@"
1515
}
1616

17+
# Run a command as the limited pulp user
18+
cmd_user_prefix() {
19+
docker exec -u pulp "$PULP_CI_CONTAINER" "$@"
20+
}
21+
1722
# Run a command, and pass STDIN
1823
cmd_stdin_prefix() {
1924
docker exec -i "$PULP_CI_CONTAINER" "$@"
2025
}
26+
27+
# Run a command as the lmited pulp user, and pass STDIN
28+
cmd_user_stdin_prefix() {
29+
docker exec -i -u pulp "$PULP_CI_CONTAINER" "$@"
30+
}

.github/workflows/update_ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
5353
- name: Set short_ref
5454
id: vars
55-
run: echo ::set-output name=short_ref::${GITHUB_REF#refs/*/}
55+
run: echo short_ref=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT
5656

5757
- name: Run update
5858
run: |

0 commit comments

Comments
 (0)