Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preliminary steps to save the CI infrastructure #39009

Open
wants to merge 38 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
6df7a6a
Add comments
kwankyu Feb 13, 2025
871934b
Add logs_artifact_postfix input argument for docker.yml
kwankyu Feb 13, 2025
daff1ac
Removed gentoo platform from CI
kwankyu Feb 13, 2025
06c11b7
Avoid semantic change in bash command
kwankyu Feb 13, 2025
557c69e
Refactor default inputs
kwankyu Feb 14, 2025
3cfeeca
Use standard image for optional and experimental
kwankyu Feb 14, 2025
84d04df
Update DEFAULT_SYSTEM_FACTORS
kwankyu Feb 16, 2025
81ddcef
Turned off standard-constraints_pkgs-norequirements
kwankyu Feb 16, 2025
fccfaea
Fix tyopos in portability_testing.rst
kwankyu Feb 16, 2025
30085e4
Adjust jobs order
kwankyu Feb 16, 2025
be82775
Fix malformatted list
kwankyu Feb 16, 2025
5498aa8
Update the documentation
kwankyu Feb 16, 2025
f4e765a
More edits of the doc
kwankyu Feb 17, 2025
63dd959
For debugging
kwankyu Feb 17, 2025
c7a2750
Update linux mint versions
kwankyu Feb 17, 2025
6b741d9
For debug
kwankyu Feb 17, 2025
5162007
Improve CI workflows
kwankyu Feb 17, 2025
a7e556e
Explain new tool in doc
kwankyu Feb 17, 2025
eb05a30
Touch CI Linux incremental
kwankyu Feb 17, 2025
6578eb6
For debug
kwankyu Feb 17, 2025
35f10f9
Fix missing build/make/Makefile error
kwankyu Feb 18, 2025
b1520b7
Fix retrofit-worktree
kwankyu Feb 18, 2025
75e7e79
Revive standard-constraints_pkgs
kwankyu Feb 19, 2025
fda2061
Remove subprojects/factory directory
kwankyu Feb 19, 2025
7937b24
Remove archlinux-latest
kwankyu Feb 19, 2025
4ba72d4
Simplify Dockerfile
kwankyu Feb 19, 2025
5e22dfb
Some edits in CI linux incremental
kwankyu Feb 19, 2025
26304db
Make write-dockefile more robuns
kwankyu Feb 19, 2025
07b387c
Update the doc accordingly
kwankyu Feb 19, 2025
cd44c2c
Slight refactoring
kwankyu Feb 19, 2025
32f0ff4
Add archlinux-latest testenv
kwankyu Feb 19, 2025
a972d87
Remove redundant source-tree after retrofit in container
kwankyu Feb 20, 2025
138e281
Turn off failing jobs
kwankyu Feb 22, 2025
ff02cd0
Merge branch 'develop' into p/39009/p/add-comments-to-scripts
kwankyu Feb 22, 2025
f1fbed1
Fix a bug for logs artifact uploading
kwankyu Feb 27, 2025
4b82421
Fix a new bug in write-dockerfile.sh
kwankyu Feb 27, 2025
330fcd8
Always upload logs artifact
kwankyu Feb 27, 2025
a501144
maximal builds up to with-targets
kwankyu Feb 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ jobs:
targets_pre: all-sage-local python3-ensure tox-ensure sagelib-tox-sagepython-constraints_pkgs-norequirements
tox_packages_factors: >-
["standard"]
logs_artifact_postfix: "-constraints_pkgs"
max_parallel: 15

standard-sitepackages:
Expand Down Expand Up @@ -125,6 +126,7 @@ jobs:
"opensuse-tumbleweed-python3.10",
"opensuse-tumbleweed"]
docker_push_repository: ghcr.io/${{ github.repository }}/
logs_artifact_postfix: "-sitepackages"
max_parallel: 8

minimal:
Expand Down Expand Up @@ -173,6 +175,7 @@ jobs:
docker_targets: "with-targets-optional"
# We remove packages starting with _, in particular package _develop
targets_optional: '$(echo $(export PATH=build/bin:$PATH && sage-package list :optional: --has-file "spkg-install.in|spkg-install|requirements.txt" --no-file "huge|has_nonfree_dependencies" | grep -v sagemath_doc | grep -v ^_))'
logs_artifact_postfix: "-optional"

experimental:
if: ${{ success() || failure() }}
Expand All @@ -187,3 +190,4 @@ jobs:
["maximal"]
docker_targets: "with-targets-optional"
targets_optional: '$(echo $(export PATH=build/bin:$PATH && sage-package list :experimental: --has-file "spkg-install.in|spkg-install|requirements.txt" --no-file "huge|has_nonfree_dependencies" | grep -v sagemath_doc))'
logs_artifact_postfix: "-experimental"
145 changes: 95 additions & 50 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ on:
"centos-stream-9-python3.12",
"almalinux-8-python3.9",
"almalinux-9-python3.11",
"gentoo-python3.10",
"gentoo-python3.11",
"gentoo-python3.12",
"archlinux-latest",
"opensuse-15.5-gcc_11-python3.11",
"opensuse-tumbleweed-python3.10",
Expand Down Expand Up @@ -86,8 +83,13 @@ on:
default: 20000
type: number
logs_artifact:
description: 'Switch for uploading logs artifact'
default: true
type: boolean
logs_artifact_postfix:
description: 'Postfix (default: none) for logs artifact name'
default: ""
type: string
#
# Publishing to GitHub Packages
#
Expand Down Expand Up @@ -143,7 +145,7 @@ jobs:
tox_packages_factor: ${{ fromJson(inputs.tox_packages_factors) }}
env:
TOX_ENV: "docker-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }}${{ inputs.incremental && '-incremental' || '' }}"
LOGS_ARTIFACT_NAME: logs-commit-${{ github.sha }}-tox-docker-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }}
LOGS_ARTIFACT_NAME: logs-commit-${{ github.sha }}-tox-docker-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }}${{ inputs.logs_artifact_postfix }}
DOCKER_TARGETS: ${{ inputs.docker_targets }}
TARGETS_PRE: ${{ inputs.targets_pre }}
TARGETS: ${{ inputs.targets }}
Expand All @@ -166,63 +168,80 @@ jobs:
remove-docker-images: true
continue-on-error: true
if: inputs.free_disk_space

- name: Check out SageMath
uses: actions/checkout@v4
with:
repository: ${{ inputs.sage_repo }}
ref: ${{ inputs.sage_ref }}
fetch-depth: 10000

- name: Download upstream artifact
uses: actions/download-artifact@v4
with:
path: upstream
name: ${{ inputs.upstream_artifact }}
if: inputs.upstream_artifact

- name: Install test prerequisites
run: |
sudo DEBIAN_FRONTEND=noninteractive apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install tox
sudo apt-get clean
df -h

- name: Update Sage packages from upstream artifact
# Handle both the old and new location of write-dockerfile.sh,
# because docker.yml is a reusable workflow.
run: |
(export PATH=$(pwd)/build/bin:$PATH; (cd upstream && bash -x update-pkgs.sh) && sed -i.bak '/upstream/d' .dockerignore; for a in build/bin/write-dockerfile.sh .ci/write-dockerfile.sh; do if [ -r $a ]; then echo "/:toolchain:/i ADD upstream upstream" | sed -i.bak -f - $a; fi; done; git diff)
export PATH=$(pwd)/build/bin:$PATH
cd upstream && bash -x update-pkgs.sh
# Remove any lines containing 'upstream' from .dockerignore
sed -i.bak '/upstream/d' .dockerignore
# Handle both the old and new location of write-dockerfile.sh, because docker.yml is a reusable workflow
for script_path in build/bin/write-dockerfile.sh .ci/write-dockerfile.sh; do
if [ -r "$script_path" ]; then
# Add 'ADD upstream upstream' before the line containing ':toolchain:' in the script
echo "/:toolchain:/i ADD upstream upstream" | sed -i.bak -f - "$script_path"
fi
done
# Show the changes made to the repository for review
git diff
if: inputs.upstream_artifact

- name: Try to login to ghcr.io
if: inputs.docker_push_repository != ''
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
run: |
TOKEN="${{ secrets.DOCKER_PKG_GITHUB_TOKEN }}"
if [ -z "$TOKEN" ]; then
TOKEN="${{ secrets.GITHUB_TOKEN }}"
fi
if echo "$TOKEN" | docker login ghcr.io -u ${{ github.actor }} --password-stdin; then
echo "DOCKER_PUSH_REPOSITORY=$(echo ${{ inputs.docker_push_repository }} | tr "[:upper:]" "[:lower:]")" >> $GITHUB_ENV
echo "DOCKER_CONFIG_FILE=$HOME/.docker/config.json" >> $GITHUB_ENV
fi
TOKEN="${{ secrets.DOCKER_PKG_GITHUB_TOKEN }}"
if [ -z "$TOKEN" ]; then
TOKEN="${{ secrets.GITHUB_TOKEN }}"
fi
if echo "$TOKEN" | docker login ghcr.io -u ${{ github.actor }} --password-stdin; then
echo "DOCKER_PUSH_REPOSITORY=$(echo ${{ inputs.docker_push_repository }} | tr "[:upper:]" "[:lower:]")" >> $GITHUB_ENV
echo "DOCKER_CONFIG_FILE=$HOME/.docker/config.json" >> $GITHUB_ENV
fi

- name: Determine Docker tags to use
run: |
# This line needs to be run before the step "Merge CI fixes from sagemath/sage".
DOCKER_TAG="$(git describe --dirty --always)"
echo "DOCKER_TAG=$DOCKER_TAG" >> $GITHUB_ENV
# From the docker documentation via .ci/update-env.sh:
# "A tag name must be valid ASCII and may
# contain lowercase and uppercase letters, digits, underscores, periods and
# dashes. A tag name may not start with a period or a dash and may contain a
# maximum of 128 characters."
EXTRA_DOCKER_TAGS=`echo $GITHUB_REF_NAME | tr -d '[:space:]' | tr -c '[:alnum:]_.-' '-' | sed 's/^[-.]*//' | cut -c1-128`
shopt -s extglob
case "$GITHUB_REF_NAME" in
+([0-9]).+([0-9])?(.+([0-9])) )
EXTRA_DOCKER_TAGS="latest dev $EXTRA_DOCKER_TAGS";;
+([0-9]).+([0-9])?(.+([0-9]))?(.)@(a|alpha|b|beta|rc)+([0-9]) )
EXTRA_DOCKER_TAGS="dev $EXTRA_DOCKER_TAGS";;
esac
echo "EXTRA_DOCKER_TAGS=$EXTRA_DOCKER_TAGS" >> $GITHUB_ENV
# This line needs to be run before the step "Merge CI fixes from sagemath/sage".
#
DOCKER_TAG="$(git describe --dirty --always)"
echo "DOCKER_TAG=$DOCKER_TAG" >> $GITHUB_ENV
#
# From the docker documentation via .ci/update-env.sh:
# "A tag name must be valid ASCII and may
# contain lowercase and uppercase letters, digits, underscores, periods and
# dashes. A tag name may not start with a period or a dash and may contain a
# maximum of 128 characters."
#
EXTRA_DOCKER_TAGS=`echo $GITHUB_REF_NAME | tr -d '[:space:]' | tr -c '[:alnum:]_.-' '-' | sed 's/^[-.]*//' | cut -c1-128`
shopt -s extglob
case "$GITHUB_REF_NAME" in
+([0-9]).+([0-9])?(.+([0-9])) )
EXTRA_DOCKER_TAGS="latest dev $EXTRA_DOCKER_TAGS";;
+([0-9]).+([0-9])?(.+([0-9]))?(.)@(a|alpha|b|beta|rc)+([0-9]) )
EXTRA_DOCKER_TAGS="dev $EXTRA_DOCKER_TAGS";;
esac
echo "EXTRA_DOCKER_TAGS=$EXTRA_DOCKER_TAGS" >> $GITHUB_ENV

- name: Merge CI fixes from sagemath/sage
# This step needs to happen after the commit sha is put in DOCKER_TAG
Expand All @@ -237,43 +256,69 @@ jobs:
run: |
df -h
if: inputs.free_disk_space

- name: Configure and build Sage distribution within a Docker container
# The first command below is a self-destruct sequence,
# which preempts the GitHub Actions 6-hour job cancellation.
#
# Using "docker exec", we enter the temporary containers used by
# "docker build" and kill the "make" processes of the Sage distribution.
#
# The arcane "find" command is a replacement for "pkill make",
# which we use because pkill is not installed in the "minimal" package
# configuration on many platforms.
#
# The "sed" command strips away timestamps from "docker build" (buildkit)
# such as "#25 1211.0" at the beginning of each line. The timestamps are
# redundant because GH Actions provides timestamps for each line already.
# Stripping the timestamps from the beginnings of lines also allows
# GitHub Actions to recognize workflow commands such as ::error etc.
#
run: |
(sleep ${{ inputs.timeout }}; for id in $(docker ps -q); do docker exec $id find /proc -maxdepth 2 -name cmdline -exec bash -c "grep -l [m][a][k][e] {} | cut -d/ -f3 | xargs --no-run-if-empty kill" \;; done) &
set -o pipefail; EXTRA_DOCKER_BUILD_ARGS="--build-arg NUMPROC=9 --build-arg USE_MAKEFLAGS=\"-k V=0 SAGE_NUM_THREADS=5\"" tox -e $TOX_ENV -- $TARGETS 2>&1 | sed -E --unbuffered "s/^#[0-9]+ [0-9]+[.][0-9]+ //;/^configure: notice:/s|^|::warning file=artifacts/$LOGS_ARTIFACT_NAME/config.log::|;/^configure: warning:/s|^|::warning file=artifacts/$LOGS_ARTIFACT_NAME/config.log::|;/^configure: error:/s|^|::error file=artifacts/$LOGS_ARTIFACT_NAME/config.log::|;"
# The first command below is a self-destruct sequence,
# which preempts the GitHub Actions 6-hour job cancellation.
#
# Using "docker exec", we enter the temporary containers used by
# "docker build" and kill the "make" processes of the Sage distribution.
(
sleep ${{ inputs.timeout }}
for container_id in $(docker ps -q); do
#
# The arcane "find" command is a replacement for "pkill make",
# which we use because pkill is not installed in the "minimal" package
# configuration on many platforms.
#
docker exec "$container_id" find /proc -maxdepth 2 -name cmdline \
-exec bash -c 'grep -l "[m][a][k][e]" {} | cut -d/ -f3 | xargs --no-run-if-empty kill' \;
done
) &
# Set pipeline to fail if any command fails
set -o pipefail
#
EXTRA_DOCKER_BUILD_ARGS="--build-arg NUMPROC=9 --build-arg USE_MAKEFLAGS=\"-k V=0 SAGE_NUM_THREADS=5\""
#
# The tox command starts to build and test Sage within a Docker container.
#
# Adter the build, the sed command strips away timestamps from
# "docker build" (buildkit) such as "#25 1211.0" at the beginning of
# each line. The timestamps are redundant because GH Actions provides
# timestamps for each line already. Stripping the timestamps from
# the beginnings of lines also allows GitHub Actions to recognize
# workflow commands such as ::error etc. The other sed commands
# annotate configuration notices/warnings/errors as GitHub
# ::warning/::warning/::error respectively.
#
tox -e $TOX_ENV -- $TARGETS 2>&1 | sed -E --unbuffered "
s/^#[0-9]+ [0-9]+[.][0-9]+ //
/^configure: notice:/s|^|::warning file=artifacts/$LOGS_ARTIFACT_NAME/config.log::|
/^configure: warning:/s|^|::warning file=artifacts/$LOGS_ARTIFACT_NAME/config.log::|
/^configure: error:/s|^|::error file=artifacts/$LOGS_ARTIFACT_NAME/config.log::|
"

- name: Copy logs from the Docker image or build container
run: |
mkdir -p "artifacts/$LOGS_ARTIFACT_NAME"
cp -r .tox/$TOX_ENV/* "artifacts/$LOGS_ARTIFACT_NAME"
rm -rf "artifacts/$LOGS_ARTIFACT_NAME"/{bin,lib,pyvenv.cfg}
if: always()

- name: Upload logs artifact
uses: actions/upload-artifact@v4
with:
path: artifacts
name: ${{ env.LOGS_ARTIFACT_NAME }}
if: always() && inputs.logs_artifact

- name: Print out logs for immediate inspection
# and markup the output with GitHub Actions logging commands
run: |
.github/workflows/scan-logs.sh "artifacts/$LOGS_ARTIFACT_NAME"
if: always()

- name: List Docker images
run: |
if [ -n "$DOCKER_PUSH_REPOSITORY" -a -f .tox/$TOX_ENV/Dockertags.pushed ]; then
Expand Down
Loading
Loading