Skip to content

Commit c13c1ea

Browse files
committed
Move some stances around in the ci scripts
1 parent 86437ce commit c13c1ea

4 files changed

Lines changed: 44 additions & 48 deletions

File tree

templates/github/.github/workflows/scripts/before_install.sh.j2

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,32 @@
22

33
{% include 'header.j2' %}
44

5-
# make sure this script runs at the repo root
6-
cd "$(dirname "$(realpath -e "$0")")"/../../..
7-
85
set -mveuo pipefail
96

10-
if [ "${GITHUB_REF##refs/heads/}" = "${GITHUB_REF}" ]
11-
then
12-
BRANCH_BUILD=0
13-
else
14-
BRANCH_BUILD=1
15-
BRANCH="${GITHUB_REF##refs/heads/}"
16-
fi
17-
if [ "${GITHUB_REF##refs/tags/}" = "${GITHUB_REF}" ]
18-
then
19-
TAG_BUILD=0
20-
else
21-
TAG_BUILD=1
22-
BRANCH="${GITHUB_REF##refs/tags/}"
23-
fi
7+
# make sure this script runs at the repo root
8+
cd "$(dirname "$(realpath -e "$0")")"/../../..
249

25-
COMMIT_MSG=$(git log --format=%B --no-merges -1)
26-
export COMMIT_MSG
10+
export PRE_BEFORE_INSTALL=$PWD/.github/workflows/scripts/pre_before_install.sh
11+
export POST_BEFORE_INSTALL=$PWD/.github/workflows/scripts/post_before_install.sh
2712

2813
{% if setup_py -%}
2914
COMPONENT_VERSION=$(sed -ne "s/\s*version.*=.*['\"]\(.*\)['\"][\s,]*/\1/p" setup.py)
3015
{%- else -%}
3116
COMPONENT_VERSION=$(python3 -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
3217
{%- endif %}
3318

19+
# Compose ansible container definition.
3420
mkdir .ci/ansible/vars || true
3521
echo "---" > .ci/ansible/vars/main.yaml
3622
echo "legacy_component_name: {{ plugin_name | snake }}" >> .ci/ansible/vars/main.yaml
3723
echo "component_name: {{ plugin_app_label }}" >> .ci/ansible/vars/main.yaml
3824
echo "component_version: '${COMPONENT_VERSION}'" >> .ci/ansible/vars/main.yaml
3925

40-
export PRE_BEFORE_INSTALL=$PWD/.github/workflows/scripts/pre_before_install.sh
41-
export POST_BEFORE_INSTALL=$PWD/.github/workflows/scripts/post_before_install.sh
42-
4326
if [ -f $PRE_BEFORE_INSTALL ]; then
4427
source $PRE_BEFORE_INSTALL
4528
fi
4629

47-
if [ "$GITHUB_EVENT_NAME" = "pull_request" ] || [ "${BRANCH_BUILD}" = "1" -a "${BRANCH}" != "{{ plugin_default_branch }}" ]
48-
then
49-
echo $COMMIT_MSG | sed -n -e 's/.*CI Base Image:\s*\([-_/[:alnum:]]*:[-_[:alnum:]]*\).*/ci_base: "\1"/p' >> .ci/ansible/vars/main.yaml
50-
fi
51-
30+
if [[ "$TEST" = "s3" ]]; then
5231
for i in {1..3}
5332
do
5433
ansible-galaxy collection install "amazon.aws:8.1.0" && s=0 && break || s=$? && sleep 3
@@ -58,6 +37,7 @@ then
5837
echo "Failed to install amazon.aws"
5938
exit $s
6039
fi
40+
fi
6141

6242
if [[ "$TEST" = "pulp" ]]; then
6343
python3 .ci/scripts/calc_constraints.py -u {% if setup_py -%} requirements.txt {% else -%} pyproject.toml {% endif -%} > upperbounds_constraints.txt

templates/github/.github/workflows/scripts/before_script.sh.j2

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
{% include 'header.j2' %}
44

5+
# This script dumps some files to help understand the setup of the test scenario.
6+
57
# make sure this script runs at the repo root
68
cd "$(dirname "$(realpath -e "$0")")"/../../..
79

@@ -17,33 +19,35 @@ if [[ -f $PRE_BEFORE_SCRIPT ]]; then
1719
fi
1820

1921
# Developers should be able to reproduce the containers with this config
20-
echo "CI vars:"
22+
echo "# CI vars:"
2123
tail -v -n +1 .ci/ansible/vars/main.yaml
2224

2325
# Developers often want to know the final pulp config
24-
echo "PULP CONFIG:"
26+
echo
27+
echo "# Pulp config:"
2528
tail -v -n +1 .ci/ansible/settings/settings.* ~/.config/pulp_smash/settings.json
2629

27-
echo "Containerfile:"
30+
echo
31+
echo "# Containerfile:"
2832
tail -v -n +1 .ci/ansible/Containerfile
2933

30-
echo "Constraints Files:"
31-
# The need not even exist.
34+
echo
35+
echo "# Constraints Files:"
36+
# They need not even exist.
3237
tail -v -n +1 ../*/*constraints.txt || true
3338

34-
# Needed for some functional tests
35-
cmd_prefix bash -c "echo '%wheel ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/nopasswd"
36-
cmd_prefix bash -c "usermod -a -G wheel pulp"
39+
echo
40+
echo "# pip list outside the container"
3741

38-
if [[ "${REDIS_DISABLED:-false}" == true ]]; then
39-
cmd_prefix bash -c "s6-rc -d change redis"
40-
echo "The Redis service was disabled for $TEST"
41-
fi
42+
echo
43+
echo "# pip list inside the container"
44+
cmd_prefix bash -c "pip3 list"
45+
46+
echo
47+
echo "# State of the containers"
48+
docker ps -a
4249

4350
if [[ -f $POST_BEFORE_SCRIPT ]]; then
4451
source $POST_BEFORE_SCRIPT
4552
fi
4653

47-
# Lots of plugins try to use this path, and throw warnings if they cannot access it.
48-
cmd_prefix mkdir /.pytest_cache
49-
cmd_prefix chown pulp:pulp /.pytest_cache

templates/github/.github/workflows/scripts/install.sh.j2

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
{% include 'header.j2' %}
44

5+
set -euv
6+
57
# make sure this script runs at the repo root
68
cd "$(dirname "$(realpath -e "$0")")"/../../..
79
REPO_ROOT="$PWD"
810

9-
set -euv
10-
1111
source .github/workflows/scripts/utils.sh
1212

1313
PLUGIN_VERSION="$(bump-my-version show current_version | tail -n -1 | python -c 'from packaging.version import Version; print(Version(input()))')"
@@ -227,6 +227,18 @@ if [[ "$TEST" = "azure" ]]; then
227227
az storage container create --name pulp-test --connection-string $AZURE_STORAGE_CONNECTION_STRING
228228
fi
229229

230-
echo ::group::PIP_LIST
231-
cmd_prefix bash -c "pip3 list"
232-
echo ::endgroup::
230+
# Needed for some functional tests
231+
cmd_prefix bash -c "echo '%wheel ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/nopasswd"
232+
cmd_prefix bash -c "usermod -a -G wheel pulp"
233+
{%- if disabled_redis_runners %}
234+
235+
# In some scenarios we want to simulate a failed redis cache.
236+
if [[ " {{ " ".join(disabled_redis_runners) }} " =~ " ${TEST} " ]]; then
237+
cmd_prefix bash -c "s6-rc -d change redis"
238+
echo "The Redis service was disabled for $TEST"
239+
fi
240+
{%- endif %}
241+
242+
# Lots of plugins try to use this path, and throw warnings if they cannot access it.
243+
cmd_prefix mkdir /.pytest_cache
244+
cmd_prefix chown pulp:pulp /.pytest_cache

templates/github/.github/workflows/test.yml.j2

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

7676
{{ run_script(name="Install", file="install.sh") | indent(6) }}
7777

78-
{{ run_script(name="Before Script", file="before_script.sh", extra_env={"REDIS_DISABLED": "${{ contains('%s', matrix.env.TEST) }}" % (disabled_redis_runners | default(["TILT"]) | join(' '))}) | indent(6) }}
78+
{{ run_script(name="Dump CI Metadata", file="before_script.sh") | indent(6) }}
7979

8080
{{ run_script(name="Script", file="script.sh") | indent(6) }}
8181
{%- if test_deprecations %}

0 commit comments

Comments
 (0)