From ba3ee6aecda0b5302607f661b3e4809ee5360dc4 Mon Sep 17 00:00:00 2001 From: Tobias Urdin Date: Thu, 9 Nov 2023 14:34:42 +0000 Subject: [PATCH] ci: get ci working This gets the CI working with Ubuntu 22.04 (Jammy) inside a docker container that runs on ubuntu-latest. --- .github/workflows/pifpaf-ci-image.yaml | 25 ++++++++++++ .github/workflows/pifpaf.yaml | 51 ++++++++++++++++++++++++ .github/workflows/python-app.yaml | 55 -------------------------- Dockerfile | 24 +++++------ tox.ini | 21 +++++++--- 5 files changed, 100 insertions(+), 76 deletions(-) create mode 100644 .github/workflows/pifpaf-ci-image.yaml create mode 100644 .github/workflows/pifpaf.yaml delete mode 100644 .github/workflows/python-app.yaml diff --git a/.github/workflows/pifpaf-ci-image.yaml b/.github/workflows/pifpaf-ci-image.yaml new file mode 100644 index 0000000..b76f3f4 --- /dev/null +++ b/.github/workflows/pifpaf-ci-image.yaml @@ -0,0 +1,25 @@ +name: Pifpaf CI Image + +on: + workflow_dispatch: + push: + paths: + - 'Dockerfile' + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ghcr.io/pifpaf/ci:latest diff --git a/.github/workflows/pifpaf.yaml b/.github/workflows/pifpaf.yaml new file mode 100644 index 0000000..d207214 --- /dev/null +++ b/.github/workflows/pifpaf.yaml @@ -0,0 +1,51 @@ +name: Pifpaf + +on: + pull_request: + +env: + INFLUXDB_VERSION: "0.13.0" + SCALA_VERSION: "2.12" + KAFKA_VERSION: "2.6.0" + ETCD_VERSION: "3.4.13" + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + env: + - py39 + - py310 + - pep8 + - build + steps: + - uses: actions/checkout@v4 + - run: sudo chown -R 1000:1000 $GITHUB_WORKSPACE + - uses: dorny/paths-filter@v2 + id: changes + with: + filters: | + ci_image: + - 'Dockerfile' + - uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + if: steps.changes.outputs.ci_image == 'false' + - run: docker pull ghcr.io/pifpaf/ci:latest + if: steps.changes.outputs.ci_image == 'false' + - uses: docker/build-push-action@v2 + with: + context: . + push: false + build-args: | + INFLUXDB_VERSION=${{ env.INFLUXDB_VERSION }} + SCALA_VERSION=${{ env.SCALA_VERSION }} + KAFKA_VERSION=${{ env.KAFKA_VERSION }} + ETCD_VERSION=${{ env.ETCD_VERSION }} + tags: ghcr.io/pifpaf/ci:latest + if: steps.changes.outputs.ci_image == 'true' + - name: Run tox + run: docker run --rm -v ${{ github.workspace }}:/home/pifpaf/pifpaf ghcr.io/pifpaf/ci:latest tox -e ${{ matrix.env }} diff --git a/.github/workflows/python-app.yaml b/.github/workflows/python-app.yaml deleted file mode 100644 index d2cbb1a..0000000 --- a/.github/workflows/python-app.yaml +++ /dev/null @@ -1,55 +0,0 @@ -name: Python application - -on: - push: - branches: - - master - pull_request: - -env: - INFLUXDB_VERSION: "0.13.0" - SCALA_VERSION: "2.12" - KAFKA_VERSION: "2.6.0" - ETCD_VERSION: "3.4.13" - -jobs: - test: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Cache Docker layers - uses: actions/cache@v3 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - - name: Build and push - uses: docker/build-push-action@v3 - with: - context: . - tags: pifpaf:latest - build-args: | - INFLUXDB_VERSION=${{ env.INFLUXDB_VERSION }} - SCALA_VERSION=${{ env.SCALA_VERSION }} - KAFKA_VERSION=${{ env.KAFKA_VERSION }} - ETCD_VERSION=${{ env.ETCD_VERSION }} - load: true - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - - - name: Run tox - run: docker run --init -t pifpaf:latest - - # Temp fix - # https://github.com/docker/build-push-action/issues/252 - # https://github.com/moby/buildkit/issues/1896 - - name: Move cache - run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 1a07827..bb9accc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,18 @@ -FROM ubuntu:focal +FROM ubuntu:22.04 ENV DEBIAN_FRONTEND=noninteractive ENV TZ=Etc/UTC -ENV PBR_VERSION=1.2.3 -ENV TOX_TESTENV_PASSENV=PBR_VERSION ARG INFLUXDB_VERSION=0.13.0 ARG SCALA_VERSION=2.12 ARG KAFKA_VERSION=2.6.0 ARG ETCD_VERSION=3.4.13 -RUN apt-get -qq update \ - && apt-get install -y mongodb-server mysql-server redis-server zookeeper mongodb nodejs npm ceph librados-dev \ - python3 python3-dev python3-pip gcc liberasurecode-dev liberasurecode1 postgresql libpq-dev python3-rados \ - git wget memcached \ +RUN apt-get update -y && apt-get install -qy gnupg software-properties-common +RUN add-apt-repository -y ppa:deadsnakes/ppa +RUN apt-get -qq update -y \ + && apt-get install -y mysql-server redis-server zookeeper nodejs npm ceph librados-dev \ + python3 python3-dev python3-pip python3.9 python3.9-dev python3.9-distutils \ + gcc liberasurecode-dev liberasurecode1 postgresql libpq-dev python3-rados git wget memcached \ && rm -rf /var/lib/apt/lists/* RUN wget https://dl.influxdata.com/influxdb/releases/influxdb_${INFLUXDB_VERSION}_amd64.deb \ @@ -34,12 +34,6 @@ RUN pip install -U tox RUN useradd -ms /bin/bash pifpaf USER pifpaf -RUN mkdir /home/pifpaf/pifpaf +RUN mkdir /home/pifpaf/tmpxattr +ENV TMP_FOR_XATTR=/home/pifpaf/tmpxattr WORKDIR /home/pifpaf/pifpaf -RUN mkdir tmpxattr - -COPY tox.ini pyproject.toml setup.py setup.cfg requirements.txt README.rst ./ -RUN tox -epy38,pep8 --sitepackages --notest - -COPY . ./ -CMD ["tox", "-epy38,pep8", "--sitepackages"] diff --git a/tox.ini b/tox.ini index 234d5ae..2164acb 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,12 @@ [tox] -envlist = py36,py37,py38,pep8,pypy +envlist = py310,pep8,pypy [testenv] usedevelop = True -sitepackages = False +sitepackages = True deps = .[test,ceph,gnocchi] + # TODO(tobias-urdin): Remove when Aodh supports it + SQLAlchemy<2 http://tarballs.openstack.org/aodh/aodh-master.tar.gz#egg=aodh[postgresql] gnocchi[postgresql,file,ceph,ceph_recommended_lib,s3] httpbin @@ -16,9 +18,16 @@ deps = .[test,ceph,gnocchi] # See also: https://github.com/pyca/pyopenssl/issues/1143 pyOpenSSL >= 22.0.0 passenv = TMPDIR_FOR_XATTR -allowlist_externals = env -commands = - env PYTHONPATH={envsitepackagesdir}:/usr/lib/python3/dist-packages/ stestr run {posargs} +setenv = + PYTHONPATH={envsitepackagesdir}:/usr/lib/python3/dist-packages/ +commands = stestr run {posargs} + +[testenv:venv] +commands = {posargs} + +[testenv:build] +deps = build +commands = python -m build [testenv:pep8] deps = flake8 @@ -31,7 +40,7 @@ deps = flake8 commands = flake8 [flake8] -basepython = python3.8 +basepython = python3 exclude = .tox,.eggs,doc show-source = true ignore = D100,D101,D102,D103,D104,G200,G201,W503,W504