Skip to content

CI

CI #177

Workflow file for this run

name: CI
on:
# This trigger is required by fastapi-mvc automation to dispatch this concrete workflow
# from fastapi-mvc 'CI workflow' (https://github.com/fastapi-mvc/cookiecutter/actions/workflows/main.yml),
# and await its result. NOTE! This is not included in the template.
workflow_dispatch:
inputs:
distinct_id:
required: true
description: "Input required by codex-/return-dispatch@v1"
push:
branches:
- master
pull_request:
branches:
- master
env:
POETRY_HOME: /opt/poetry
POETRY_CONFIG_DIR: /opt/poetry
POETRY_CACHE_DIR: /opt/poetry/cache
POETRY_VIRTUALENVS_PATH: /opt/poetry/store
DEFAULT_PYTHON: '3.10'
jobs:
meta:
runs-on: ubuntu-latest
steps:
# This echo is required by codex-/return-dispatch@v1 in order to identify dispatched workflow.
# NOTE! This is not included in the template.
- name: echo distinct ID ${{ github.event.inputs.distinct_id }}
run: echo ${{ github.event.inputs.distinct_id }}
# This job checks if an identical workflow is being triggered by different
# event and skips it. For instance there is no need to run the same pipeline
# twice for pull_request and push for identical commit sha.
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5.3.0
with:
skip_after_successful_duplicate: 'true'
concurrent_skipping: same_content
do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]'
install:
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.8', '3.9', '3.10', '3.11' ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Init Poetry cache
id: cached-poetry
uses: actions/cache@v3
with:
path: ${{ env.POETRY_HOME }}
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('./pyproject.toml') }}-${{ hashFiles('./poetry.lock') }}
- name: Install package
run: make install
if: steps.cached-poetry.outputs.cache-hit != 'true'
build:
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Load Poetry cache
uses: actions/cache@v3
with:
path: ${{ env.POETRY_HOME }}
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-${{ hashFiles('./pyproject.toml') }}-${{ hashFiles('./poetry.lock') }}
- name: Build wheel
run: make build
- name: Archive build artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ format('fastapi_mvc-{0}', github.sha) }}
path: dist
retention-days: 60
metrics:
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Load Poetry cache
uses: actions/cache@v3
with:
path: ${{ env.POETRY_HOME }}
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-${{ hashFiles('./pyproject.toml') }}-${{ hashFiles('./poetry.lock') }}
- name: Run metrics checks
run: make metrics
unit-tests:
needs: install
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ '3.8', '3.9', '3.10', '3.11' ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Load Poetry cache
uses: actions/cache@v3
with:
path: ${{ env.POETRY_HOME }}
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('./pyproject.toml') }}-${{ hashFiles('./poetry.lock') }}
- name: Run unit tests
run: make unit-test
integration-tests:
needs: install
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ '3.8', '3.9', '3.10', '3.11' ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Load Poetry cache
uses: actions/cache@v3
with:
path: ${{ env.POETRY_HOME }}
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('./pyproject.toml') }}-${{ hashFiles('./poetry.lock') }}
- name: Run integration tests
run: make integration-test
coverage:
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Load Poetry cache
uses: actions/cache@v3
with:
path: ${{ env.POETRY_HOME }}
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-${{ hashFiles('./pyproject.toml') }}-${{ hashFiles('./poetry.lock') }}
- name: Run coverage
run: make coverage
mypy:
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Load Poetry cache
uses: actions/cache@v3
with:
path: ${{ env.POETRY_HOME }}
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-${{ hashFiles('./pyproject.toml') }}-${{ hashFiles('./poetry.lock') }}
- name: Run mypy checks
run: make mypy