Test github actions for Linux #23
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Linux tests | |
on: | |
push: | |
branches: | |
- develop2 | |
- release/* | |
pull_request: | |
branches: | |
- '*' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
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/docker/conan-tests -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-tests.tar | |
- name: Get Docker group GID | |
if: steps.cache_docker_image.outputs.cache-hit != 'true' | |
id: docker_gid | |
run: | | |
DOCKER_GID=$(getent group docker | cut -d: -f3) | |
echo "docker_gid=$DOCKER_GID" >> $GITHUB_OUTPUT | |
- name: Build Docker image (if not cached) | |
if: steps.cache_docker_image.outputs.cache-hit != 'true' | |
run: | | |
docker build \ | |
--build-arg DOCKER_GID=${{ steps.docker_gid.outputs.docker_gid }} \ | |
-t ghcr.io/${{ github.repository_owner }}/conan-tests:latest \ | |
-f ./.ci/docker/conan-tests . | |
mkdir -p docker_image_cache | |
docker save ghcr.io/${{ github.repository_owner }}/conan-tests:latest -o docker_image_cache/conan-tests.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-tests:latest | |
# linux: | |
# needs: build_container | |
# runs-on: ubuntu-latest | |
# container: | |
# image: ghcr.io/${{ github.repository_owner }}/conan-tests:latest | |
# options: --user conan | |
# strategy: | |
# matrix: | |
# python-version: ['3.12.3', '3.9.2', '3.8.6', '3.6.15'] | |
# test-type: ['unittests', 'integration', 'functional'] | |
# name: Python ${{ matrix.python-version }} - ${{ matrix.test-type }} | |
# 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 -r conans/requirements_server.txt | |
# pip install meson | |
# - name: Run tests | |
# shell: bash | |
# run: | | |
# if [ "${{ matrix.test-type }}" == "unittests" ]; then | |
# pytest test/unittests --durations=20 -n 4 -rs | |
# elif [ "${{ matrix.test-type }}" == "integration" ]; then | |
# pytest test/integration --durations=20 -n 4 -rs | |
# elif [ "${{ matrix.test-type }}" == "functional" ]; then | |
# pytest test/functional --durations=20 -n 4 -rs | |
# fi | |
linux_docker_tests: | |
needs: build_container | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/${{ github.repository_owner }}/conan-tests:latest | |
options: --user conan -v /var/run/docker.sock:/var/run/docker.sock | |
strategy: | |
matrix: | |
python-version: ['3.12.3'] | |
name: Docker Runner Tests - Python ${{ matrix.python-version }} | |
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: Pull Docker image | |
run: docker pull ghcr.io/${{ github.repository_owner }}/conan-tests:latest | |
- name: Install dependencies | |
run: | | |
pip install --upgrade pip | |
pip install -r conans/requirements.txt | |
pip install -r conans/requirements_dev.txt | |
pip install -r conans/requirements_server.txt | |
pip install meson | |
- name: Run tests | |
shell: bash | |
run: | | |
pytest -m docker_runner --durations=20 -rs |