Skip to content

Explore using Github Actions for CI #2

Explore using Github Actions for CI

Explore using Github Actions for CI #2

Workflow file for this run

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