From 3e38f23a8958df6d0912617697a050c5289905e4 Mon Sep 17 00:00:00 2001 From: Jacob Coffee Date: Thu, 10 Oct 2024 17:08:19 -0500 Subject: [PATCH 1/4] feat: import gitlab stuff --- .github/workflows/ci-images.yml | 72 ++++++++++++ cpython-ci/.gitignore | 1 + cpython-ci/Dockerfile | 42 +++++++ cpython-ci/LICENSE.txt | 202 ++++++++++++++++++++++++++++++++ cpython-ci/README.md | 75 ++++++++++++ cpython-ci/get-pythons.sh | 69 +++++++++++ cpython-ci/get_versions.py | 109 +++++++++++++++++ cpython-ci/test_pythons.py | 64 ++++++++++ 8 files changed, 634 insertions(+) create mode 100644 .github/workflows/ci-images.yml create mode 100644 cpython-ci/.gitignore create mode 100644 cpython-ci/Dockerfile create mode 100644 cpython-ci/LICENSE.txt create mode 100644 cpython-ci/README.md create mode 100755 cpython-ci/get-pythons.sh create mode 100755 cpython-ci/get_versions.py create mode 100755 cpython-ci/test_pythons.py diff --git a/.github/workflows/ci-images.yml b/.github/workflows/ci-images.yml new file mode 100644 index 0000000..3cf51c7 --- /dev/null +++ b/.github/workflows/ci-images.yml @@ -0,0 +1,72 @@ +name: CI/CD Pipeline + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + build: + runs-on: ubuntu-latest + steps: +# - uses: actions/checkout@v4 # I dont think this is needed given git context defaults in build-push-action? + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + file: ./cpython-ci/Dockerfile + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test + + test: + needs: build + runs-on: ubuntu-latest + steps: + - name: Pull Docker image + run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test + + - name: Run tests + run: | + docker run ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test /usr/local/bin/test_pythons.py + docker run ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test tox --version + docker run ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test mypy --version + docker run ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test pipx --version + + release: + needs: test + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + steps: + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Pull and re-tag Docker image + run: | + docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test + docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:active + docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main + + - name: Push Docker images + run: | + docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:active + docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main \ No newline at end of file diff --git a/cpython-ci/.gitignore b/cpython-ci/.gitignore new file mode 100644 index 0000000..79bb103 --- /dev/null +++ b/cpython-ci/.gitignore @@ -0,0 +1 @@ +/versions.txt diff --git a/cpython-ci/Dockerfile b/cpython-ci/Dockerfile new file mode 100644 index 0000000..f25d8b6 --- /dev/null +++ b/cpython-ci/Dockerfile @@ -0,0 +1,42 @@ +FROM ubuntu:24.04 +LABEL python.ci-image.authors="Barry Warsaw " + +ARG SERIES +ENV SERIES=${SERIES} + +# Enable source repositories so we can use `apt build-dep` to get all required +# build dependencies. +RUN sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources + +ADD get-pythons.sh /usr/local/bin/get-pythons.sh +ADD get_versions.py /usr/local/bin/get_versions.py +ADD test_pythons.py /usr/local/bin/test_pythons.py + +# Set Debian front-end to non-interactive so that apt doesn't ask for +# prompts later. +ENV DEBIAN_FRONTEND=noninteractive + +RUN useradd runner --create-home && \ + # Create and change permissions for builds directory. + mkdir /builds && \ + chown runner /builds && \ + export LC_ALL=C.UTF-8 && export LANG=C.UTF-8 + +# Use a new layer here so that these static changes are cached from above +# layer. Update Ubuntu and install the build-deps. +RUN apt -qq -o=Dpkg::Use-Pty=0 update && \ + apt -qq -o=Dpkg::Use-Pty=0 -y dist-upgrade && \ + # Use python3.12 build-deps for Ubuntu 22.04 + apt -qq -o=Dpkg::Use-Pty=0 build-dep -y python3.12 && \ + apt -qq -o=Dpkg::Use-Pty=0 install -y python3-pip python3-venv && \ + apt -qq -o=Dpkg::Use-Pty=0 install -y wget unzip git jq curl && \ + # Remove apt's lists to make the image smaller. + rm -rf /var/lib/apt/lists/* +# Get and install all versions of Python. +RUN ./usr/local/bin/get_versions.py && ./usr/local/bin/get-pythons.sh > /dev/null +RUN python3.12 -m pip install mypy codecov tox pipx +RUN mv versions.txt /usr/local/bin/versions.txt + +# Switch to runner user and set the workdir. +USER runner +WORKDIR /home/runner diff --git a/cpython-ci/LICENSE.txt b/cpython-ci/LICENSE.txt new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/cpython-ci/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/cpython-ci/README.md b/cpython-ci/README.md new file mode 100644 index 0000000..df903ff --- /dev/null +++ b/cpython-ci/README.md @@ -0,0 +1,75 @@ +# CI Images for Python + +This is an official Docker image containing various stable and in-development +Python releases. It is based on [Ubuntu 24.04 LTS](http://releases.ubuntu.com/24.04/). + +The `active` (a.k.a. `main`) image contains all of the currently maintained +versions of Python. None of the [EOL'd](https://endoflife.date/python) +versions are built or are available for testing purposes. Note that we +recommend against using `main` as it may soon be +[deprecated](https://gitlab.com/python-devs/ci-images/-/issues/20). These are +the current versions that are available: + + + +* [Python 3.14.0a0 - unreleased](https://github.com/python/cpython) +* [Python 3.13.0](https://www.python.org/downloads/release/python-3130/) +* [Python 3.12.7](https://www.python.org/downloads/release/python-3127/) +* [Python 3.11.10](https://www.python.org/downloads/release/python-31110/) +* [Python 3.10.15](https://www.python.org/downloads/release/python-31015/) +* [Python 3.9.20](https://www.python.org/downloads/release/python-3920/) + +# Python executables + +Each supported Python version can be invoked directly using the `pythonX.Y` executable, all of which live in +parallel in `/usr/local/bin` (generally on `$PATH`). For example: + +``` +$ python3.12 -V +``` + +As of Python 3.13, both the standard build and the [free-threading (a.k.a. "No +GIL")](https://py-free-threading.github.io/) binaries are available. The +free-threading binary has a `t` at the end, e.g. + +``` +$ python3.13t -V +``` + +# Using the image + +We are publishing this Docker image on +[GitLab](https://gitlab.com/python-devs/ci-images/container_registry). + +For example: + +``` +$ docker run registry.gitlab.com/python-devs/ci-images:active python3.11 -c "import sys; print(sys.version)" +``` + +You can pull the container with this command: + +``` +$ docker pull registry.gitlab.com/python-devs/ci-images:active +``` + +[//]: # (TODO: Reword for GH Actions) +If you want to use this image in your own CI pipelines (e.g. a +[.gitlab-ci.yml](https://gitlab.com/help/ci/yaml/README.md) file for a GitLab +shared runner), use this URL to refer to the image: + +``` +registry.gitlab.com/python-devs/ci-images:active +``` + +Here's [an example](https://gitlab.com/warsaw/gitlab-ci/-/blob/main/common-gitlab-ci.yml#L45). + +# Contributing + +Feel free to help us by submitting +[merge requests](https://gitlab.com/python-devs/ci-images/merge_requests) or +[issues](https://gitlab.com/python-devs/ci-images/issues). diff --git a/cpython-ci/get-pythons.sh b/cpython-ci/get-pythons.sh new file mode 100755 index 0000000..a774f65 --- /dev/null +++ b/cpython-ci/get-pythons.sh @@ -0,0 +1,69 @@ +#!/bin/sh + +set -ex + +cleanup_after_install () { + find /usr/local -depth -type d -a -name test -o -name tests -o -type f -a -name '*.pyc' -o -name '*.pyo' -exec rm -rf '{}' + + rm -rf /usr/src/python +} + + +get_install () { + # The line of input will include a single version number for all active release versions, but it will + # include two version numbers for pre-release Pythons. For the latter, we want the exact Python version + # for the source tarball and the MAJOR.MINOR.PATCH for the FTP directory the tarball will live in. + PY_VERSION=$1 + PY_DIR=${2:-$1} + # Now we want just the major and minor version numbers, because for all Pythons >= 3.13, we want to build + # both the standard build and the free-threading build. + MAJOR=$(echo "$PY_DIR" | cut -d. -f1) + MINOR=$(echo "$PY_DIR" | cut -d. -f2) + # Download the tarball, unpack it, configure, and build it. Then we can remove the downloaded artifacts. + cd /tmp + wget -q https://www.python.org/ftp/python/$PY_DIR/Python-$PY_VERSION.tar.xz + tar Jxf Python-$PY_VERSION.tar.xz + cd /tmp/Python-$PY_VERSION + # For Python's >= 3.13, also build the free-threading version. This will install /usr/local/bin/pythonX.Y + # *and* /usr/local/bin/pythonX.Yt where the 't' version is free-threaded. We have to do this first + # because we want the non-t version (i.e. the default build) to be available on /usr/local/bin/pythonX.Y + # which the latter build will overwrite. + if [ "$MAJOR" -gt 3 ] || { [ "$MAJOR" -eq 3 ] && [ "$MINOR" -ge 13 ]; }; then + ./configure -C --disable-gil && make -j4 && make -j4 altinstall + make distclean + fi + # Build the default build for all active versions. + ./configure -C && make -j4 && make -j4 altinstall + cd /tmp + rm Python-$PY_VERSION.tar.xz && rm -r Python-$PY_VERSION +} + + +# Install tagged Python releases. +while read ver; do + get_install $ver +done EOL date mapping + return { + release['cycle']: date.fromisoformat(release['eol']) + for release in res + } + + +def main(): + gh_response = get_tags_from_github() + all_versions = get_version_from_tags(gh_response) + latest_versions = get_latest_version(all_versions) + if PRE_RELEASE: + version = pkg_version.parse(PRE_RELEASE) + latest_versions[f'{version.major}.{version.minor}'] = version + + version_eols = get_version_eols() + + today = date.today() + + with open('versions.txt', 'w') as fd: + # Build latest to oldest, primarily for better testing of the new free-threading builds. + for key, value in reversed(latest_versions.items()): + if not value.is_prerelease: + if (eol := version_eols.get(key)) is None: + print(f'No EOL data for {key}... assume active') + elif today > eol: + continue + print(f'{key} Series: {value}') + if value.is_prerelease: + # pre-releases are under directory which skips the pre-release + # markers, so print the directory path. + print(f'{value} {value.major}.{value.minor}.{value.micro}', + file=fd) + else: + print(value, file=fd) + + +if __name__ == "__main__": + main() diff --git a/cpython-ci/test_pythons.py b/cpython-ci/test_pythons.py new file mode 100755 index 0000000..0d74eee --- /dev/null +++ b/cpython-ci/test_pythons.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 + +import sys +import pprint +import subprocess + + +testables = {} + +with open('/usr/local/bin/versions.txt', encoding='utf-8') as fp: + # Each line will contain either one entry, in which case that's the exact + # version and series to use, or two lines where the first word is the + # exact version and the second word is the series. This latter is mostly + # to handle pre-release versions. E.g. + # + # 3.X.Y + # 3.X.YbZ 3.X.Y + # + # What we want is the major.minor version so we can invoke the + # interpreter, and the value that will be returned by `pythonX.Y -V`. + # We'll use those to compare in the test. + for line in fp.read().splitlines(): + words = line.split() + if len(words) == 1: + version = series = words[0] + else: + assert len(words) == 2 + version, series = words + major, minor = series.split('.')[:2] + testables[f'python{major}.{minor}'] = f'Python {version}' + + +FAIL = [] +PASS = [] +OUTPUTS = {} +VERSIONS = {} + + +for exe, output in testables.items(): + proc = subprocess.run([exe, '-V'], capture_output=True, text=True) + version = proc.stdout.strip() + if proc.returncode != 0: + FAIL.append(exe) + OUTPUTS[exe] = version + elif version != output: + FAIL.append(exe) + OUTPUTS[exe] = version + else: + PASS.append(exe) + VERSIONS[exe] = version + + +print(f'PASS: {PASS}') +print(f'FAIL: {FAIL}') + +print('Python versions built:') +for b_exe, b_version in VERSIONS.items(): + print(f' {b_exe:10} == {b_version}') + +if len(FAIL) > 0: + pprint.pprint(testables) + pprint.pprint(OUTPUTS) + +sys.exit(len(FAIL)) From bb55a1604eab39277750d2d1daebd6c11a3dca57 Mon Sep 17 00:00:00 2001 From: Jacob Coffee Date: Thu, 10 Oct 2024 17:09:06 -0500 Subject: [PATCH 2/4] ci: allow manual runs with button --- .github/workflows/ci-images.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-images.yml b/.github/workflows/ci-images.yml index 3cf51c7..9d3bd1d 100644 --- a/.github/workflows/ci-images.yml +++ b/.github/workflows/ci-images.yml @@ -7,6 +7,7 @@ on: pull_request: branches: - main + workflow_dispatch: jobs: env: From cc7569264032216b0bf446f25ad93f6c604679c3 Mon Sep 17 00:00:00 2001 From: Jacob Coffee Date: Thu, 10 Oct 2024 17:23:37 -0500 Subject: [PATCH 3/4] ci: add gitlab publishing --- .github/workflows/ci-images.yml | 53 ++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci-images.yml b/.github/workflows/ci-images.yml index 9d3bd1d..15d3644 100644 --- a/.github/workflows/ci-images.yml +++ b/.github/workflows/ci-images.yml @@ -11,43 +11,51 @@ on: jobs: env: - REGISTRY: ghcr.io + GITHUB_REGISTRY: ghcr.io + GITLAB_REGISTRY: ${{ secrets.GITLAB_REGISTRY }} IMAGE_NAME: ${{ github.repository }} build: runs-on: ubuntu-latest steps: -# - uses: actions/checkout@v4 # I dont think this is needed given git context defaults in build-push-action? - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY }} + registry: ${{ env.GITHUB_REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Login to GitLab Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.GITLAB_REGISTRY }} + username: ${{ secrets.GITLAB_USERNAME }} + password: ${{ secrets.GITLAB_TOKEN }} + - name: Build and push Docker image uses: docker/build-push-action@v6 with: file: ./cpython-ci/Dockerfile push: true - tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test + tags: | + ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test + ${{ env.GITLAB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test test: needs: build runs-on: ubuntu-latest steps: - name: Pull Docker image - run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test + run: docker pull ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test - name: Run tests run: | - docker run ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test /usr/local/bin/test_pythons.py - docker run ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test tox --version - docker run ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test mypy --version - docker run ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test pipx --version + docker run ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test /usr/local/bin/test_pythons.py + docker run ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test tox --version + docker run ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test mypy --version + docker run ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test pipx --version release: needs: test @@ -57,17 +65,28 @@ jobs: - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY }} + registry: ${{ env.GITHUB_REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Pull and re-tag Docker image + - name: Login to GitLab Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.GITLAB_REGISTRY }} + username: ${{ secrets.GITLAB_USERNAME }} + password: ${{ secrets.GITLAB_TOKEN }} + + - name: Pull and re-tag Docker images run: | - docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test - docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:active - docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main + docker pull ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test + docker tag ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:active + docker tag ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:main + docker tag ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test ${{ env.GITLAB_REGISTRY }}/${{ env.IMAGE_NAME }}:active + docker tag ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test ${{ env.GITLAB_REGISTRY }}/${{ env.IMAGE_NAME }}:main - name: Push Docker images run: | - docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:active - docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main \ No newline at end of file + docker push ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:active + docker push ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:main + docker push ${{ env.GITLAB_REGISTRY }}/${{ env.IMAGE_NAME }}:active + docker push ${{ env.GITLAB_REGISTRY }}/${{ env.IMAGE_NAME }}:main From 91b4cda49768a870bcb182977de5191b0d8a4065 Mon Sep 17 00:00:00 2001 From: Jacob Coffee Date: Thu, 10 Oct 2024 17:35:53 -0500 Subject: [PATCH 4/4] chore: rename --- .github/workflows/ci-images.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-images.yml b/.github/workflows/ci-images.yml index 15d3644..1870290 100644 --- a/.github/workflows/ci-images.yml +++ b/.github/workflows/ci-images.yml @@ -1,4 +1,4 @@ -name: CI/CD Pipeline +name: Build CI Images on: push: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy