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

Changes for NR CSEC module support #819

Open
wants to merge 124 commits into
base: develop-k2-integration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
b5711e3
initial changes for k2 integration
AnupamJuniwal Sep 21, 2022
20d5117
minor fix
AnupamJuniwal Sep 21, 2022
dfbcf0a
k2 agent would now init without any args
AnupamJuniwal Sep 22, 2022
f399c3a
initial implementation of securty config, removal of switch based k2 …
AnupamJuniwal Sep 27, 2022
c3232c9
minor fix with incorrect value for configuration mapper
AnupamJuniwal Sep 28, 2022
206160e
changes corresponding to latest k2 agent changes
AnupamJuniwal Sep 29, 2022
dd7bd2d
minor fixes
AnupamJuniwal Sep 29, 2022
7578dc0
updated integration source for k2
AnupamJuniwal Sep 30, 2022
857f3f9
Added customer id
AnupamJuniwal Sep 30, 2022
f0c30a1
initial changes for application id propagation
AnupamJuniwal Oct 1, 2022
42d621a
minor fix in application_id extraction
AnupamJuniwal Oct 1, 2022
e700fb2
minor fix
AnupamJuniwal Oct 1, 2022
1d5964b
guid propagation instead of application_id
AnupamJuniwal Oct 2, 2022
a2da1ba
Merge branch 'feature/k2_integration' into k2_integration
AnupamJuniwal Oct 2, 2022
163645b
This implements propagation of all possible k2 config in NR's config
AnupamJuniwal Oct 2, 2022
52e59e2
changes to populate dictionary of policy and changes to reflect secur…
AnupamJuniwal Oct 3, 2022
a609df8
This contains changes for policy propagation to k2
AnupamJuniwal Oct 6, 2022
30a280a
Merge branch 'feature/k2i/policy_propagation' into k2_integration
AnupamJuniwal Oct 6, 2022
a5dd418
updated config for logs upload and exception handling in security mod…
AnupamJuniwal Oct 7, 2022
5f226e8
Merge branch 'feature/k2i/logs_config_propagation' into k2_integration
AnupamJuniwal Oct 9, 2022
6d515e8
Changes for setting the trasnsaction id catcher by handing over a lam…
AnupamJuniwal Oct 9, 2022
34d610b
changes to send trace metadata long with transaction id from metadata…
AnupamJuniwal Oct 10, 2022
e02eacf
Merge 'feature/k2i/logs_config_propagation' into k2_integration
AnupamJuniwal Oct 10, 2022
385b966
This contains multiple changes:
AnupamJuniwal Oct 12, 2022
ded8f48
minor change to reflect k2 module changes
AnupamJuniwal Oct 12, 2022
5298430
Merge branch 'feature/k2i/add_linking_metadata_deprecate_old_k2_auth_…
AnupamJuniwal Oct 12, 2022
a2f385e
Addition of enforce flag
AnupamJuniwal Oct 26, 2022
2f46837
Merge branch 'main' into k2_integration
AnupamJuniwal Oct 26, 2022
a8a7a88
Addition of account id in linking metadata
AnupamJuniwal Dec 21, 2022
d925658
Temp changes
AnupamJuniwal Dec 23, 2022
a741c2d
Let the connect be called with refresh (When linking metadata is avai…
AnupamJuniwal Dec 23, 2022
0ec4fe4
agent would not connect with startup
AnupamJuniwal Dec 28, 2022
f5a98ba
removal of rest server endpoint config, use of SingletonAgentConfig i…
AnupamJuniwal Jan 25, 2023
524b315
removal of all security agent initialization logic
AnupamJuniwal Jan 25, 2023
46637fe
updates to newrelic config for security module
AnupamJuniwal Mar 14, 2023
5be1836
minor fix
AnupamJuniwal Mar 23, 2023
ac7e712
point to nr_adaptation with updated newrelic_security package
AnupamJuniwal Apr 17, 2023
a028082
updated to latest csec statup update
AnupamJuniwal Apr 17, 2023
49d7a99
Merge remote-tracking branch 'nr-public/main' into feature/nr_adaptation
AnupamJuniwal Apr 17, 2023
28d789a
Refactoring and relocation of security settings in core config
AnupamJuniwal Apr 28, 2023
1f780c2
initialising security agent before configuring nr apm hooks
AnupamJuniwal May 4, 2023
f0505f8
Merge branch 'main' into feature/nr_adaptation
AnupamJuniwal May 10, 2023
5fb7a42
fixes in config default values for security config for python 2.7 sup…
AnupamJuniwal May 17, 2023
11c0049
Will use dev branch for security agent
AnupamJuniwal May 26, 2023
1313de9
Merge branch 'k2io/nr-python-agent/develop' into develop-k2-integration
AnupamJuniwal Jun 1, 2023
093fd3a
Updated remote for pulling newrelic_security module
AnupamJuniwal Jun 1, 2023
88cb32e
Update install requires line.
umaannamalai Jun 1, 2023
7a43a7f
[Mega-Linter] Apply linters fixes
umaannamalai Jun 1, 2023
33b51fc
Testing install requires.
umaannamalai Jun 1, 2023
0c2cbbc
Merge conflicts.
umaannamalai Jun 1, 2023
7041783
Fixed k2 reference to Security Agent
AnupamJuniwal Jun 12, 2023
f192c24
Fix Testing Failures (#828)
TimPansino Jun 12, 2023
3def8b0
Fix pytest test filtering when running tox (#823)
hmstepanek Jun 12, 2023
90ccb4c
Validator transfer p3 (#745)
lrafeei Jun 14, 2023
668b0a9
Fix set output warning using new GHA syntax (#833)
TimPansino Jun 21, 2023
abb6405
Remove Python 2.7 and pypy2 testing (#835)
lrafeei Jun 21, 2023
ab92daf
Containerized CI Pipeline (#836)
TimPansino Jun 22, 2023
4422b95
Fix CI Image Tagging (#838)
TimPansino Jun 22, 2023
4da4612
Temporarily Restore Old CI Pipeline (#841)
TimPansino Jun 22, 2023
658f818
Rework CI Pipeline (#839)
TimPansino Jun 22, 2023
57720fd
Fix Tests on New CI (#843)
TimPansino Jun 23, 2023
a7dfe33
Instrument Redis waitaof (#851)
TimPansino Jun 26, 2023
33aa111
Ignore patched hooks files. (#849)
umaannamalai Jun 26, 2023
e707cc0
Fix local scoped package reporting (#837)
hmstepanek Jun 26, 2023
ab590a2
MSSQL Testing (#852)
TimPansino Jun 27, 2023
db07523
Exclude command line functionality from test coverage (#855)
lrafeei Jun 27, 2023
c2fd5e3
FIX: resilient environment settings (#825)
aaeabdo Jun 27, 2023
9883c2b
Replace drop_transaction logic by using transaction context manager (…
lrafeei Jun 28, 2023
998b035
Upgrade to Pypy38 for TypedDict (#861)
lrafeei Jun 30, 2023
66c2e19
Add profile_trace testing (#858)
umaannamalai Jun 30, 2023
e663c36
Add Transaction API Tests (#857)
lrafeei Jun 30, 2023
3bdb013
Add tests for jinja2. (#842)
umaannamalai Jun 30, 2023
6644846
Add tests for newrelic/config.py (#860)
hmstepanek Jun 30, 2023
ee92363
Fix starlette testing matrix for updated behavior. (#869)
TimPansino Jul 14, 2023
53fc51a
Correct Serverless Distributed Tracing Logic (#870)
TimPansino Jul 14, 2023
2f580af
Fix Kafka CI (#863)
TimPansino Jul 14, 2023
a7080e9
Change image tag to latest (#871)
hmstepanek Jul 17, 2023
56ea815
Add full version for pypy3.8 to tox (#872)
lrafeei Jul 18, 2023
a248688
Instrument RedisCluster (#809)
hmstepanek Jul 27, 2023
08eec5e
Ignore Django instrumentation from older versions (#859)
lrafeei Jul 28, 2023
4b3768b
Modify postgresql tests to include WITH query (#885)
lrafeei Aug 2, 2023
17f8937
Develop redis addons (#888)
lrafeei Aug 10, 2023
8ebe9a3
Add google firestore instrumentation (#893)
umaannamalai Aug 10, 2023
238b64d
Base Devcontainer on CI Image (#873)
TimPansino Aug 10, 2023
dc87bd3
Add support for redis v5. (#895)
umaannamalai Aug 15, 2023
7d76243
Use importlib.metadata first to avoid deprecation warnings (#878)
renanivo Aug 16, 2023
f1a673e
Fix Normalization Rules (#894)
TimPansino Aug 16, 2023
6a6228f
Fix database instance metric bug (#905)
hmstepanek Aug 18, 2023
62abb45
Add check for both path and file (#907)
hmstepanek Aug 21, 2023
399c81f
Update structlog instrumentation. (#865)
umaannamalai Aug 23, 2023
3988ecc
GraphQL Async Instrumentation Support (#908)
umaannamalai Aug 28, 2023
0baf8d5
Develop swap redis asyncio commits (#913)
lrafeei Aug 28, 2023
faaccd0
Increase days until stale. (#909)
umaannamalai Aug 28, 2023
b1be563
Pin anyio version to below 4.0.0 (#916)
lrafeei Sep 1, 2023
e371b02
Add redis.asyncio.Connection instrumentation (#919)
lrafeei Sep 12, 2023
eff66b5
Update testing matrix for supported packages. (#904)
umaannamalai Sep 14, 2023
17cd48d
Add sklearn instrumentation and ML model feature support (#921)
umaannamalai Sep 25, 2023
eef6916
Pin flask version for flask restx tests. (#931)
umaannamalai Oct 9, 2023
d577a69
Ignore new redis methods. (#932)
umaannamalai Oct 9, 2023
13e9891
Update CI Image (#930)
TimPansino Oct 9, 2023
43160af
Only get package version once (#928)
hmstepanek Oct 9, 2023
cc3e285
Cache Package Version Lookups (#946)
TimPansino Oct 19, 2023
5996de6
Fix Redis Generator Methods (#947)
TimPansino Oct 19, 2023
4721025
Automatic RPM System Updates (#948)
TimPansino Oct 23, 2023
2191684
Drop python 3.7 tests for Hypercorn (#954)
lrafeei Oct 30, 2023
b2512eb
Fix pyenv installation for devcontainer (#936)
TimPansino Nov 2, 2023
b12f7be
Remove duplicate kafka import hook (#956)
lrafeei Nov 2, 2023
b2e9e74
Handle 0.32.0.post1 version in tests (#963)
hmstepanek Nov 6, 2023
72aa6e8
Fix botocore tests (#973)
hmstepanek Nov 13, 2023
f939014
Package Version Performance Regression (#970)
TimPansino Nov 13, 2023
5cba84e
Merge remote-tracking branch 'refs/remotes/newrelic-public-fork/devel…
AnupamJuniwal Nov 14, 2023
a7e4870
Merge branch 'main' into develop-k2-integration
AnupamJuniwal Nov 14, 2023
3980127
Synthetics Info Header Support (#896)
TimPansino Nov 16, 2023
5eb1095
Fix CI Image Permissions for Non-Root Users (#969)
TimPansino Nov 16, 2023
fdaa4be
Add package_capturing.enabled setting (#982)
hmstepanek Nov 16, 2023
1986366
Revert "Synthetics Info Header Support (#896)" (#983)
TimPansino Nov 16, 2023
b6a9121
Remove accidental quote from api keys (#985)
TimPansino Nov 16, 2023
374bc67
Synthetics Info Header Support (#984)
TimPansino Nov 29, 2023
6e0b12e
Docker CGroups v2 Utilization Support (#980)
TimPansino Nov 30, 2023
55144b1
Testing for supported frameworks in Python 3.12 (#897)
lrafeei Nov 30, 2023
007be52
Remove all references to NR staging (#989)
TimPansino Dec 4, 2023
cd74bc4
Fix bug with Structlog CallsiteParameter processor (#990)
umaannamalai Dec 6, 2023
030cfc9
Update wrapt (#993)
TimPansino Dec 6, 2023
140bb54
Merge branch 'main' into develop-k2-integration
AnupamJuniwal Dec 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 19 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
ARG IMAGE=ghcr.io/newrelic-experimental/pyenv-devcontainer:latest

# To target other architectures, change the --platform directive in the Dockerfile.
FROM --platform=linux/amd64 ${IMAGE}
ARG IMAGE_TAG=latest
FROM ghcr.io/newrelic/newrelic-python-agent-ci:${IMAGE_TAG}

# Setup non-root user
USER root
ARG UID=1000
ARG GID=${UID}
ENV HOME /home/vscode
RUN mkdir -p ${HOME} && \
groupadd --gid ${GID} vscode && \
useradd --uid ${UID} --gid ${GID} --home ${HOME} vscode && \
chown -R ${UID}:${GID} /home/vscode

# Fix pyenv installation
RUN echo 'eval "$(pyenv init -)"' >>${HOME}/.bashrc && \
chown -R vscode:vscode ${PYENV_ROOT}

# Set user
USER ${UID}:${GID}
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// To target other architectures, change the --platform directive in the Dockerfile.
"dockerfile": "Dockerfile",
"args": {
"IMAGE": "ghcr.io/newrelic-experimental/pyenv-devcontainer:latest"
"IMAGE_TAG": "latest"
}
},
"remoteUser": "vscode",
Expand Down
50 changes: 0 additions & 50 deletions .github/actions/setup-python-matrix/action.yml

This file was deleted.

69 changes: 69 additions & 0 deletions .github/actions/update-rpm-config/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: "update-rpm-config"
description: "Set current version of agent in rpm config using API."
inputs:
agent-language:
description: "Language agent to configure (eg. python)"
required: true
default: "python"
agent-version:
description: "3-4 digit agent version number (eg. 1.2.3) with optional leading v (ignored)"
required: true
dry-run:
description: "Dry Run"
required: true
default: "false"
production-api-key:
description: "API key for New Relic Production"
required: false

runs:
using: "composite"
steps:
- name: Trim potential leading v from agent version
shell: bash
run: |
AGENT_VERSION=${{ inputs.agent-version }}
echo "AGENT_VERSION=${AGENT_VERSION#"v"}" >> $GITHUB_ENV

- name: Generate Payload
shell: bash
run: |
echo "PAYLOAD='{ \"system_configuration\": { \"key\": \"${{ inputs.agent-language }}_agent_version\", \"value\": \"${{ env.AGENT_VERSION }}\" } }'" >> $GITHUB_ENV

- name: Generate Content-Type
shell: bash
run: |
echo "CONTENT_TYPE='Content-Type: application/json'" >> $GITHUB_ENV

- name: Update system configuration page
shell: bash
if: ${{ inputs.dry-run == 'false' }}
run: |
curl -X POST 'https://api.newrelic.com/v2/system_configuration.json' \
-H "X-Api-Key:${{ inputs.production-api-key }}" -i \
-H ${{ env.CONTENT_TYPE }} \
-d ${{ env.PAYLOAD }}

- name: Verify system configuration update
shell: bash
if: ${{ inputs.dry-run == 'false' }}
run: |
PROD_VERSION=$(curl -X GET 'https://api.newrelic.com/v2/system_configuration.json' \
-H "X-Api-Key:${{ inputs.production-api-key }}" \
-H "${{ env.CONTENT_TYPE }}" | jq ".system_configurations | from_entries | .${{inputs.agent-language}}_agent_version")

if [ "${{ env.AGENT_VERSION }}" != "$PROD_VERSION" ]; then
echo "Version mismatch: $PROD_VERSION"
exit 1
fi

- name: (dry-run) Update system configuration page
shell: bash
if: ${{ inputs.dry-run != 'false' }}
run: |
cat << EOF
curl -X POST 'https://api.newrelic.com/v2/system_configuration.json' \
-H "X-Api-Key:**REDACTED**" -i \
-H ${{ env.CONTENT_TYPE }} \
-d ${{ env.PAYLOAD }}
EOF
107 changes: 107 additions & 0 deletions .github/containers/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@

# Copyright 2010 New Relic, Inc.
#
# 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.

FROM ubuntu:20.04

# Install OS packages
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get install -y \
bash \
build-essential \
curl \
expat \
fish \
fontconfig \
freetds-common \
freetds-dev \
gcc \
git \
libbz2-dev \
libcurl4-openssl-dev \
libffi-dev \
libgmp-dev \
libkrb5-dev \
liblzma-dev \
libmpfr-dev \
libncurses-dev \
libpq-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
locales \
make \
odbc-postgresql \
openssl \
python2-dev \
python3-dev \
python3-pip \
sudo \
tzdata \
unixodbc-dev \
unzip \
vim \
wget \
zip \
zlib1g \
zlib1g-dev \
zsh && \
rm -rf /var/lib/apt/lists/*

# Build librdkafka from source
ARG LIBRDKAFKA_VERSION=2.1.1
RUN cd /tmp && \
wget https://github.com/confluentinc/librdkafka/archive/refs/tags/v${LIBRDKAFKA_VERSION}.zip -O ./librdkafka.zip && \
unzip ./librdkafka.zip && \
rm ./librdkafka.zip && \
cd ./librdkafka-${LIBRDKAFKA_VERSION} && \
./configure && \
make all install && \
cd /tmp && \
rm -rf ./librdkafka-${LIBRDKAFKA_VERSION}

# Setup ODBC config
RUN sed -i 's|Driver=psqlodbca.so|Driver=/usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so|g' /etc/odbcinst.ini && \
sed -i 's|Driver=psqlodbcw.so|Driver=/usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so|g' /etc/odbcinst.ini && \
sed -i 's|Setup=libodbcpsqlS.so|Setup=/usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so|g' /etc/odbcinst.ini

# Set the locale
RUN locale-gen --no-purge en_US.UTF-8
ENV LANG=en_US.UTF-8 \ LANGUAGE=en_US:en \ LC_ALL=en_US.UTF-8
ENV TZ="Etc/UTC"
RUN ln -fs "/usr/share/zoneinfo/${TZ}" /etc/localtime && \
dpkg-reconfigure -f noninteractive tzdata

# Use root user
ENV HOME /root
WORKDIR "${HOME}"

# Install pyenv
ENV PYENV_ROOT="/usr/local/pyenv"
RUN curl https://pyenv.run/ | /bin/bash
ENV PATH="${PYENV_ROOT}/bin:${PYENV_ROOT}/shims:${PATH}"
RUN echo 'eval "$(pyenv init -)"' >>${HOME}/.bashrc && \
pyenv update

# Install Python
ARG PYTHON_VERSIONS="3.11 3.10 3.9 3.8 3.7 3.12 2.7 pypy2.7-7.3.12 pypy3.8-7.3.11"
COPY --chown=1000:1000 --chmod=+x ./install-python.sh /tmp/install-python.sh
RUN /tmp/install-python.sh && \
rm /tmp/install-python.sh

# Install dependencies for main python installation
COPY ./requirements.txt /tmp/requirements.txt
RUN pyenv exec pip install --upgrade -r /tmp/requirements.txt && \
rm /tmp/requirements.txt
71 changes: 71 additions & 0 deletions .github/containers/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright 2010 New Relic, Inc.
#
# 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.

# Override constants
PLATFORM_OVERRIDE:=
PYTHON_VERSIONS_OVERRIDE:=

# Computed variables
IMAGE_NAME:=ghcr.io/newrelic/newrelic-python-agent-ci
MAKEFILE_DIR:=$(dir $(realpath $(firstword ${MAKEFILE_LIST})))
REPO_ROOT:=$(realpath ${MAKEFILE_DIR}../../)
UNAME_P:=$(shell uname -p)
PLATFORM_AUTOMATIC:=$(if $(findstring arm,${UNAME_P}),linux/arm64,linux/amd64)
PLATFORM:=$(if ${PLATFORM_OVERRIDE},${PLATFORM_OVERRIDE},${PLATFORM_AUTOMATIC})
PYTHON_VERSIONS_AUTOMATIC:=3.10 2.7
PYTHON_VERSIONS:=$(if ${PYTHON_VERSIONS_OVERRIDE},${PYTHON_VERSIONS_OVERRIDE},${PYTHON_VERSIONS_AUTOMATIC})

.PHONY: default
default: test

.PHONY: build
build:
@docker build ${MAKEFILE_DIR} \
--platform=${PLATFORM} \
-t ${IMAGE_NAME}:local \
--build-arg='PYTHON_VERSIONS=${PYTHON_VERSIONS}'

# Run the local tag as a container.
.PHONY: run
run: run.local

# Run a specific tag as a container.
# Usage: make run.<tag>
# Defaults to run.local, but can instead be run.latest or any other tag.
.PHONY: run.%
run.%:
# Build image if local was specified, else pull latest
@if [[ "$*" = "local" ]]; then cd ${MAKEFILE_DIR} && $(MAKE) build; else docker pull ${IMAGE_NAME}:$*; fi
@docker run --rm -it \
--platform=${PLATFORM} \
--mount type=bind,source="${REPO_ROOT}",target=/home/github/python-agent \
--workdir=/home/github/python-agent \
--add-host=host.docker.internal:host-gateway \
-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}" \
-e GITHUB_ACTIONS="true" \
${IMAGE_NAME}:$* /bin/bash

# Ensure python versions are usable. Cannot be automatically used with PYTHON_VERSIONS_OVERRIDE.
.PHONY: test
test: build
@docker run --rm \
--platform=${PLATFORM} \
ghcr.io/newrelic/python-agent-ci:local \
/bin/bash -c '\
python3.10 --version && \
python2.7 --version && \
touch tox.ini && tox --version && \
echo "Success! Python versions installed."'
50 changes: 50 additions & 0 deletions .github/containers/install-python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
# Copyright 2010 New Relic, Inc.
#
# 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.

set -eo pipefail

main() {
# Coerce space separated string to array
if [[ ${#PYTHON_VERSIONS[@]} -eq 1 ]]; then
PYTHON_VERSIONS=($PYTHON_VERSIONS)
fi

if [[ -z "${PYTHON_VERSIONS[@]}" ]]; then
echo "No python versions specified. Make sure PYTHON_VERSIONS is set." 1>&2
exit 1
fi

# Find all latest pyenv supported versions for requested python versions
PYENV_VERSIONS=()
for v in "${PYTHON_VERSIONS[@]}"; do
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
fi
PYENV_VERSIONS+=($LATEST)
done

# Install each specific version
for v in "${PYENV_VERSIONS[@]}"; do
pyenv install "$v" &
done
wait

# Set all installed versions as globally accessible
pyenv global ${PYENV_VERSIONS[@]}
}

main
9 changes: 9 additions & 0 deletions .github/containers/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
bandit
black
flake8
isort
pip
setuptools
tox
virtualenv<20.22.0
wheel
Loading
Loading