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

POC of using Github Actions for CI #17028

Draft
wants to merge 19 commits into
base: develop2
Choose a base branch
from
Empty file removed .ci/__init__.py
Empty file.
22 changes: 0 additions & 22 deletions .ci/bump_dev_version.py

This file was deleted.

184 changes: 0 additions & 184 deletions .ci/jenkins/testsv2.jenkins

This file was deleted.

85 changes: 85 additions & 0 deletions .github/workflows/ci-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: CI Pipeline

on:
push:
branches:
- '*'
pull_request:
branches:
- '*'

jobs:
build_container:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Calculate Dockerfile checksum
id: dockerfile_hash
run: |
DOCKERFILE_HASH=$(find ./ci/conan-unittests -type f -exec sha256sum {} \; | sha256sum | cut -d' ' -f1)
echo "hash=$DOCKERFILE_HASH" >> $GITHUB_OUTPUT

- name: Cache Docker image
id: cache_docker_image
uses: actions/cache@v3
with:
path: docker_image_cache
key: ${{ runner.os }}-docker-${{ steps.dockerfile_hash.outputs.hash }}

- name: Load Docker image from cache
if: steps.cache_docker_image.outputs.cache-hit == 'true'
run: docker load -i docker_image_cache/conan-unittests.tar

- name: Build Docker image (if not cached)
if: steps.cache_docker_image.outputs.cache-hit != 'true'
run: |
docker build -t ghcr.io/${{ github.repository_owner }}/conan-unittests:latest -f ./ci/conan-unittests .
mkdir -p docker_image_cache
docker save ghcr.io/${{ github.repository_owner }}/conan-unittests:latest -o docker_image_cache/conan-unittests.tar

- name: Push Docker image to GHCR
if: steps.cache_docker_image.outputs.cache-hit != 'true'
run: docker push ghcr.io/${{ github.repository_owner }}/conan-unittests:latest

linux_unittests:
needs: build_container
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository_owner }}/conan-unittests:latest
options: --user conan
strategy:
matrix:
python-version: ['3.8.6']
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
run: |
pyenv global ${{ matrix.python-version }}
python --version

- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements*.txt') }}

- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r conans/requirements.txt
pip install -r conans/requirements_dev.txt
pip install meson

- name: Run tests
run: pytest test/unittests --durations=20 -n 4
34 changes: 34 additions & 0 deletions ci/conan-unittests
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM ubuntu:24.04

LABEL maintainer="Conan.io <[email protected]>"

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y --no-install-recommends \
git curl make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget llvm \
libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev \
liblzma-dev python3-openssl ca-certificates sudo tar && \
rm -rf /var/lib/apt/lists/*

RUN useradd -m -s /bin/bash conan && \
echo 'conan ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

ENV HOME /home/conan
ENV PYENV_ROOT $HOME/.pyenv
ENV PATH $PYENV_ROOT/bin:$PYENV_ROOT/shims:/usr/bin:/bin:$PATH

RUN curl https://pyenv.run | bash

RUN pyenv install 3.8.6 && pyenv global 3.8.6

RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \
python get-pip.py && \
rm get-pip.py

RUN chown -R conan:conan $HOME

USER conan
WORKDIR $HOME

CMD ["/bin/bash"]
Loading