Skip to content

Commit

Permalink
ci improvements (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
okigan authored Apr 27, 2023
1 parent ce21a33 commit 013466c
Show file tree
Hide file tree
Showing 14 changed files with 131 additions and 104 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
pip install -r requirements.txt
pip install -r requirements-test.txt
pip install pytest
pip install tox tox-gh-actions
# - name: Lint with flake8
# run: |
# pip install flake8
Expand All @@ -45,6 +44,6 @@ jobs:
pycodestyle -v awscurl
- name: Test with pytest
run: |
python --version
pytest -v --cov=awscurl --cov-fail-under=77 --cov-report html
- name: Test with tox
run: tox -vv
15 changes: 0 additions & 15 deletions ci-in-docker.sh

This file was deleted.

8 changes: 0 additions & 8 deletions ci.sh

This file was deleted.

28 changes: 15 additions & 13 deletions ci/ci-alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@ ENV PATH="/root/.pyenv/bin:$PATH"
RUN eval "$(pyenv init -)" && \
eval "$(pyenv virtualenv-init -)"

COPY .python-version .python-version
RUN cat .python-version | xargs -n 1 /root/.pyenv/bin/pyenv install

RUN /root/.pyenv/versions/3.8*/bin/python -m venv /root/venv

RUN bash -c "source /root/venv/bin/activate && pip install tox"

COPY awscurl dd/awscurl
COPY tox.ini dd/tox.ini
COPY requirements.txt dd/requirements.txt
COPY requirements-test.txt dd/requirements-test.txt
COPY tests dd/tests

RUN bash -c "source /root/venv/bin/activate && cd dd && tox --recreate"
WORKDIR /root/workdir
COPY .python-version .python-version
RUN for version in $(cat .python-version); do \
/root/.pyenv/bin/pyenv install $version; \
done

COPY setup.cfg setup.cfg
COPY awscurl awscurl
COPY setup.py setup.py
COPY scripts/ci.sh scripts/ci.sh
COPY requirements.txt requirements.txt
COPY requirements-test.txt requirements-test.txt
COPY tests tests

# RUN bash -c "source /root/venv/bin/activate && cd dd && tox --recreate"
29 changes: 15 additions & 14 deletions ci/ci-centos/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@ RUN yum install -y libffi-devel readline-devel zlib-devel bzip2-devel sqlite-dev
RUN curl https://pyenv.run | bash

ENV PATH="/root/.pyenv/bin:$PATH"

RUN eval "$(pyenv init -)" && \
eval "$(pyenv virtualenv-init -)"

COPY .python-version .python-version
RUN cat .python-version | xargs -n 1 /root/.pyenv/bin/pyenv install

RUN /root/.pyenv/versions/3.8*/bin/python -m venv /root/venv

RUN bash -c "source /root/venv/bin/activate && pip install tox"

COPY awscurl dd/awscurl
COPY tox.ini dd/tox.ini
COPY requirements.txt dd/requirements.txt
COPY requirements-test.txt dd/requirements-test.txt
COPY tests dd/tests

RUN bash -c "source /root/venv/bin/activate && cd dd && tox --recreate"
WORKDIR /root/workdir
COPY .python-version .python-version
RUN for version in $(cat .python-version); do \
/root/.pyenv/bin/pyenv install $version; \
done

COPY setup.cfg setup.cfg
COPY awscurl awscurl
COPY setup.py setup.py
COPY scripts/ci.sh scripts/ci.sh
COPY requirements.txt requirements.txt
COPY requirements-test.txt requirements-test.txt
COPY tests tests

# RUN bash -c "source /root/venv/bin/activate && cd dd && tox --recreate"
29 changes: 15 additions & 14 deletions ci/ci-ubuntu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,22 @@ RUN apt install -y curl git \
RUN curl https://pyenv.run | bash

ENV PATH="/root/.pyenv/bin:$PATH"

RUN eval "$(pyenv init -)" && \
eval "$(pyenv virtualenv-init -)"

COPY .python-version .python-version
RUN cat .python-version | xargs -n 1 /root/.pyenv/bin/pyenv install

RUN /root/.pyenv/versions/3.8*/bin/python -m venv /root/venv

RUN bash -c "source /root/venv/bin/activate && pip install tox"

COPY awscurl dd/awscurl
COPY tox.ini dd/tox.ini
COPY requirements.txt dd/requirements.txt
COPY requirements-test.txt dd/requirements-test.txt
COPY tests dd/tests

RUN bash -c "source /root/venv/bin/activate && cd dd && tox --recreate"
WORKDIR /root/workdir
COPY .python-version .python-version
RUN for version in $(cat .python-version); do \
/root/.pyenv/bin/pyenv install $version; \
done

COPY setup.cfg setup.cfg
COPY awscurl awscurl
COPY setup.py setup.py
COPY scripts/ci.sh scripts/ci.sh
COPY requirements.txt requirements.txt
COPY requirements-test.txt requirements-test.txt
COPY tests tests

# RUN bash -c "source /root/venv/bin/activate && cd dd && tox --recreate"
6 changes: 5 additions & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
pycodestyle
mock
pytest
pytest-cov
pytest-cov
wheel
setuptools
setuptools-rust
build
18 changes: 18 additions & 0 deletions scripts/ci-in-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -o errexit
set -o pipefail
set -o nounset
set -o xtrace

docker_run() {
local image_type=$1
local script_file=$2
echo building "${image_type}" image -- first time it could take a few minutes
docker build -t awscurl-ci-"$image_type" -f ./ci/ci-"$image_type"/Dockerfile . && \
docker run -t awscurl-ci-"$image_type" bash -c "$script_file"
}

docker_run "ubuntu" "./scripts/ci.sh"
docker_run "alpine" "./scripts/ci.sh"
docker_run "centos" "./scripts/ci.sh"
52 changes: 52 additions & 0 deletions scripts/ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

DETOX_ROOT_DIR=./build/detox

grep -v '^ *#' < .python-version | while IFS= read -r PYENV_VERSION
do
# echo PYENV_VERSION="$PYENV_VERSION"
# echo SHELL="$SHELL"
# echo $PATH
# pyenv install -sv "${PYENV_VERSION}"
# https://github.com/pyenv/pyenv/issues/1819#issuecomment-780803524
# /root/.pyenv/bin/pyenv shell "${PYENV_VERSION}"
export PYENV_VERSION="$PYENV_VERSION"
eval "$(pyenv init -)"

PER_VER_DIR=${DETOX_ROOT_DIR}/v${PYENV_VERSION}
VENV_DIR=${PER_VER_DIR}/venv${PYENV_VERSION}
(
echo "##### NEW DETOX ENV: " "$(uname) " "${PER_VER_DIR}" " #####"
python3 -m venv "${VENV_DIR}"
source "${VENV_DIR}"/bin/activate

echo which python="$(which python)"
echo python --version="$(python --version)"
echo pip --version="$(pip --version)"

PS4='[$(date "+%Y-%m-%d %H:%M:%S")] '
set -o errexit -o pipefail -o nounset -o xtrace

pip -q -q install --upgrade pip
# python -m ensurepip --upgrade
# pip install -r requirements.txt
pip -q -q install -r requirements-test.txt

pycodestyle .

# python -m build .
pip -q install .

export AWS_ACCESS_KEY_ID=MOCK_AWS_ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY=MOCK_AWS_SECRET_ACCESS_KEY
export AWS_SESSION_TOKEN=MOCK_AWS_SESSION_TOKEN

pytest \
--cov=awscurl \
--cov-fail-under=77 \
--cov-report html \
--cov-report=html:"${PER_VER_DIR}"/htmlcov \
--durations=2 \
--strict-config
)
done
1 change: 0 additions & 1 deletion install.sh → scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,3 @@ grep -v '^ *#' < .python-version | while IFS= read -r line
do
pyenv install -s "${line}"
done
pip install tox
File renamed without changes.
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
count = False
max-line-length = 120
statistics = True
ignore = E501,W291,E225,E123,E266,W504
exclude = build,venv,venv3.6.15,venv3.8.16,.tox
13 changes: 7 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

from setuptools import setup


with open("requirements.txt", "r", encoding="utf-8") as f:
requirements = f.read().splitlines()

# https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html#summary

setup(
name='awscurl',
version='0.27',
Expand All @@ -20,12 +26,7 @@
],
},
zip_safe=False,
install_requires=[
'requests',
'configargparse',
'configparser',
'urllib3[secure]'
],
install_requires=requirements,
extras_require={
'awslibs': ["botocore"]
}
Expand Down
29 changes: 0 additions & 29 deletions tox.ini

This file was deleted.

0 comments on commit 013466c

Please sign in to comment.