Skip to content

Commit

Permalink
Fix CI Image Tagging (#838)
Browse files Browse the repository at this point in the history
* Correct templated CI image name

* Pin pypy2.7 in image

* Fix up scripting
  • Loading branch information
TimPansino committed Jun 22, 2023
1 parent ab92daf commit 4422b95
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/containers/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ RUN echo 'eval "$(pyenv init -)"' >>$HOME/.bashrc && \
pyenv update

# Install Python
ARG PYTHON_VERSIONS="3.10 3.9 3.8 3.7 3.11 2.7 pypy2.7 pypy3.7"
ARG PYTHON_VERSIONS="3.10 3.9 3.8 3.7 3.11 2.7 pypy2.7-7.3.11 pypy3.7"
COPY --chown=1000:1000 --chmod=+x ./install-python.sh /tmp/install-python.sh
COPY ./requirements.txt /requirements.txt
RUN /tmp/install-python.sh && \
Expand Down
7 changes: 4 additions & 3 deletions .github/containers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
# limitations under the License.

# Repository root for mounting into container.
REPO_ROOT:=$(realpath $(dir $(realpath $(firstword $(MAKEFILE_LIST))))../../)
MAKEFILE_DIR:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
REPO_ROOT:=$(realpath $(MAKEFILE_DIR)../../)

.PHONY: default
default: test

.PHONY: build
build:
@# Perform a shortened build for testing
@docker build --build-arg='PYTHON_VERSIONS=3.10 2.7' . -t ghcr.io/newrelic/python-agent-ci:local
@docker build --build-arg='PYTHON_VERSIONS=3.10 2.7' $(MAKEFILE_DIR) -t ghcr.io/newrelic/newrelic-python-agent-ci:local

.PHONY: test
test: build
Expand All @@ -40,4 +41,4 @@ run: build
-e NEW_RELIC_HOST="${NEW_RELIC_HOST}" \
-e NEW_RELIC_LICENSE_KEY="${NEW_RELIC_LICENSE_KEY}" \
-e NEW_RELIC_DEVELOPER_MODE="${NEW_RELIC_DEVELOPER_MODE}" \
ghcr.io/newrelic/python-agent-ci:local /bin/bash
ghcr.io/newrelic/newrelic-python-agent-ci:local /bin/bash
15 changes: 1 addition & 14 deletions .github/containers/install-python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

set -e

SED=$(which gsed || which sed)

SCRIPT_DIR=$(dirname "$0")
PIP_REQUIREMENTS=$(cat /requirements.txt)

Expand All @@ -34,7 +32,7 @@ main() {
# Find all latest pyenv supported versions for requested python versions
PYENV_VERSIONS=()
for v in "${PYTHON_VERSIONS[@]}"; do
LATEST=$(pyenv latest -k "$v" || get_latest_patch_version "$v")
LATEST=$(pyenv latest -k "$v" || pyenv latest -k "$v-dev")
if [[ -z "$LATEST" ]]; then
echo "Latest version could not be found for ${v}." 1>&2
exit 1
Expand All @@ -55,15 +53,4 @@ main() {
pyenv exec pip install --upgrade $PIP_REQUIREMENTS
}

get_latest_patch_version() {
pyenv install --list | # Get all python versions
$SED 's/^ *//g' | # Remove leading whitespace
grep -E "^$1" | # Find specified version by matching start of line
grep -v -- "-c-jit-latest" | # Filter out pypy JIT versions
$SED -E '/(-[a-zA-Z]+$)|(a[0-9]+)|(b[0-9]+)|(rc[0-9]+)/!{s/$/_/}' | # Append trailing _ to any non development versions to place them lower when sorted
sort -V | # Sort using version sorting
$SED 's/_$//' | # Remove any added trailing underscores to correct version names
tail -1 # Grab last result as latest version
}

main
2 changes: 1 addition & 1 deletion .github/workflows/build-ci-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
images: ghcr.io/${{ github.repository }}-ci
flavor: |
prefix=
suffix=
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:

runs-on: ubuntu-20.04
container:
image: ghcr.io/newrelic/python-agent-ci:latest
image: ghcr.io/${{ github.repository }}-ci
timeout-minutes: 30

steps:
Expand Down Expand Up @@ -155,7 +155,7 @@ jobs:

runs-on: ubuntu-20.04
container:
image: ghcr.io/newrelic/python-agent-ci:latest
image: ghcr.io/${{ github.repository }}-ci
timeout-minutes: 30

steps:
Expand Down Expand Up @@ -193,7 +193,7 @@ jobs:

runs-on: ubuntu-20.04
container:
image: ghcr.io/newrelic/python-agent-ci:latest
image: ghcr.io/${{ github.repository }}-ci
timeout-minutes: 30

services:
Expand Down Expand Up @@ -246,7 +246,7 @@ jobs:

runs-on: ubuntu-20.04
container:
image: ghcr.io/newrelic/python-agent-ci:latest
image: ghcr.io/${{ github.repository }}-ci
timeout-minutes: 30

services:
Expand Down Expand Up @@ -302,7 +302,7 @@ jobs:

runs-on: ubuntu-20.04
container:
image: ghcr.io/newrelic/python-agent-ci:latest
image: ghcr.io/${{ github.repository }}-ci
timeout-minutes: 30

services:
Expand Down Expand Up @@ -353,7 +353,7 @@ jobs:

runs-on: ubuntu-20.04
container:
image: ghcr.io/newrelic/python-agent-ci:latest
image: ghcr.io/${{ github.repository }}-ci
timeout-minutes: 30

services:
Expand Down Expand Up @@ -406,7 +406,7 @@ jobs:

runs-on: ubuntu-20.04
container:
image: ghcr.io/newrelic/python-agent-ci:latest
image: ghcr.io/${{ github.repository }}-ci
timeout-minutes: 30

services:
Expand Down Expand Up @@ -457,7 +457,7 @@ jobs:

runs-on: ubuntu-20.04
container:
image: ghcr.io/newrelic/python-agent-ci:latest
image: ghcr.io/${{ github.repository }}-ci
timeout-minutes: 30

services:
Expand Down Expand Up @@ -581,7 +581,7 @@ jobs:

runs-on: ubuntu-20.04
container:
image: ghcr.io/newrelic/python-agent-ci:latest
image: ghcr.io/${{ github.repository }}-ci
timeout-minutes: 30

services:
Expand Down Expand Up @@ -632,7 +632,7 @@ jobs:

runs-on: ubuntu-20.04
container:
image: ghcr.io/newrelic/python-agent-ci:latest
image: ghcr.io/${{ github.repository }}-ci
timeout-minutes: 30

services:
Expand Down Expand Up @@ -685,7 +685,7 @@ jobs:

runs-on: ubuntu-20.04
container:
image: ghcr.io/newrelic/python-agent-ci:latest
image: ghcr.io/${{ github.repository }}-ci
timeout-minutes: 30

services:
Expand Down Expand Up @@ -739,7 +739,7 @@ jobs:

runs-on: ubuntu-20.04
container:
image: ghcr.io/newrelic/python-agent-ci:latest
image: ghcr.io/${{ github.repository }}-ci
timeout-minutes: 30

services:
Expand Down

0 comments on commit 4422b95

Please sign in to comment.