Skip to content

add make to the docker image #93

add make to the docker image

add make to the docker image #93

Workflow file for this run

name: ci
on:
push:
branches:
- main
release:
pull_request:
env:
POETRY_HOME: /opt/poetry
POETRY_CACHE: /opt/poetry_cache
POETRY_VERSION: 1.7.1
jobs:
lint_and_test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event. Selected python version is ${{ matrix.python-version }}."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache deps install
id: cache-deps
uses: actions/cache@v3
with:
path: |
${{ env.POETRY_HOME }}
${{ env.POETRY_CACHE }}
key: cachepoetry-${{ hashFiles('poetry.lock', '.github/workflows/**') }}-${{ matrix.python-version }}
- name: Install poetry
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
python3 -m venv $POETRY_HOME
$POETRY_HOME/bin/pip install poetry==$POETRY_VERSION
- name: Fix github path
run: |
echo "$POETRY_HOME/bin" >> "$GITHUB_PATH"
- name: Configure poetry
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project false
poetry config cache-dir $POETRY_CACHE
poetry config virtualenvs.path $POETRY_CACHE/venv
- name: Install requirements
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
poetry install
- name: Run lint
run: |
poetry run make FIX=0 lint
- name: Run tests / coverage
run: |
poetry run make test
- name: Run doc
if: matrix.python-version == '3.12'
run: |
poetry run make doc
- name: Check modified files
if: matrix.python-version == '3.12'
run: |
git diff --exit-code
publish_pypi:
runs-on: ubuntu-latest
needs: lint_and_test
if: github.event_name == 'release' && github.event.action == 'created'
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install poetry
run: |
python3 -m venv $POETRY_HOME
$POETRY_HOME/bin/pip install poetry==$POETRY_VERSION
- name: Fix github path
run: |
echo "$POETRY_HOME/bin" >> "$GITHUB_PATH"
- name: Install requirements
run: |
poetry install
- name: Override BASEURL in README.md
env:
BASEURL: https://github.com/fabien-marty/jinja-tree/blob/main/
run: |
poetry run jinja-tree .
- name: Publish on Pypi
run: |
poetry config pypi-token.pypi "${{ secrets.PYPI_TOKEN }}"
VERSION=$(echo "${{ github.event.release.tag_name }}" | sed -e 's/^v//')
poetry version "${VERSION}"
poetry build
poetry publish
test_docker:
runs-on: ubuntu-latest
needs: lint_and_test
if: github.event_name != 'release'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
permissions:
contents: read
packages: write
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Build docker
run: |
make docker
publish_docker:
runs-on: ubuntu-latest
needs: publish_pypi
if: github.event_name == 'release' && github.event.action == 'created'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
permissions:
contents: read
packages: write
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: docker
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
labels: ${{ steps.meta.outputs.labels }}