Skip to content

Commit

Permalink
dev: ci/cd
Browse files Browse the repository at this point in the history
  • Loading branch information
neudinger committed Sep 5, 2021
2 parents 9484d16 + d221718 commit 7dc03e1
Show file tree
Hide file tree
Showing 63 changed files with 2,806 additions and 177 deletions.
85 changes: 85 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
FROM debian:bullseye-slim as devroot

LABEL MAINTAINER="Barre Kevin"
LABEL VERSION="1.0"
LABEL SRC=https://github.com/neudinger/ \
DESCRIPTION="PDIC Container"


ARG USERNAME=pdi
ARG USER_UID=1000
ENV PATH /bin:/sbin:/usr/bin:$PATH
ENV DEBIAN_FRONTEND=noninteractive

ENV LOGGING_LEVEL=INFO
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 HOME=/home/${USERNAME}
ENV PATH=/usr/sbin:/bin:/sbin:/usr/bin:${HOME}/.local/bin:/usr/local/bin
ENV USER_NAME=$USERNAME
ENV CONDA_DIR=/opt/conda
ENV PATH=${CONDA_DIR}/bin:${PATH}

RUN set -eux && \
apt update -y && apt install -y --no-install-recommends \
curl ca-certificates tar build-essential sudo git binutils-gold \
libtool libtool-bin zlib1g-dev libssl-dev \
libncursesw5 libpthread-stubs0-dev \
clang-format clang-tidy clang-tools clang clangd libc++-dev \
libc++1 libc++abi-dev libc++abi1 libclang-dev libclang1 liblldb-dev \
libllvm-ocaml-dev libomp-dev libomp5 lld lldb llvm-dev llvm-runtime llvm python-clang
RUN update-alternatives --install "/usr/bin/ld" "ld" `which ld.gold` 10

SHELL ["/bin/bash", "-c"]

USER root

WORKDIR $HOME

RUN groupadd --gid $USER_UID $USERNAME; \
useradd -s /bin/bash --uid $USER_UID --gid $USER_UID -m $USERNAME

RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME
RUN chmod 0440 /etc/sudoers.d/$USERNAME
RUN apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false

WORKDIR ${HOME}

ENV APP_HOME ${HOME}/app/
RUN set -eux;\
mkdir -p ${APP_HOME} && \
chown -R ${USERNAME}:${USERNAME} ${HOME}

SHELL ["/bin/bash", "-c"]

WORKDIR $HOME
# MiniConda

RUN set -eux && \
curl --progress-bar -L \
https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh -o Miniforge3.sh && \
bash Miniforge3.sh -b -p ${CONDA_DIR} && \
rm Miniforge3.sh

RUN set -eux && \
curl --progress-bar -L \
https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-pypy3-$(uname)-$(uname -m).sh -o Mambaforge.sh && \
bash Mambaforge.sh -b -u ${CONDA_DIR} && \
rm Mambaforge.sh

COPY requirement.yml ${HOME}

RUN set -eux; \
conda env create --name pdic-env -f requirement.yml && \
conda init bash && \
rm requirement.yml

ENV PATH=$HOME/miniconda/envs/pdic-env/bin:${PATH}
RUN echo "PATH=${PATH}" >> ~/.bashrc
WORKDIR $APP_HOME
SHELL ["/bin/bash", "-c"]
RUN echo "conda activate pdic-env" >> ~/.bashrc
COPY --chown=${USER_NAME}:${USER_NAME} entrypoint.sh ${HOME}
RUN chown -R ${USER_NAME}:${USER_NAME} /home
ENTRYPOINT ["/bin/bash", "/home/pdi/entrypoint.sh"]
CMD ["bash"]
# USER root
USER $USERNAME
11 changes: 11 additions & 0 deletions .devcontainer/conda-github-requirement.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
channels:
- defaults
- conda-forge
dependencies:
- python=3.9
- pip
- twine
- mkdocs-material
- ninja
- pip:
- "pdoc3"
9 changes: 9 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "PDIC container dev",
"dockerFile": "Dockerfile",
"extensions": [
"ms-python.python",
"austin.code-gnu-global",
"ms-vscode.cmake-tools"
]
}
14 changes: 14 additions & 0 deletions .devcontainer/dockross.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# https://github.com/dockcross/dockcross

FROM dockcross/base

ENV DEFAULT_DOCKCROSS_IMAGE pdic_cross_build
RUN set -eux && \
apt update -y && apt install -y --no-install-recommends \
curl ca-certificates tar build-essential sudo git binutils-gold \
libtool libtool-bin zlib1g-dev libssl-dev \
libncursesw5 libpthread-stubs0-dev \
clang-format clang-tidy clang-tools clang clangd libc++-dev \
libc++1 libc++abi-dev libc++abi1 libclang-dev libclang1 liblldb-dev \
libllvm-ocaml-dev libomp-dev libomp5 lld lldb llvm-dev llvm-runtime llvm python-clang
RUN pip install pdoc3 twine pyaml
4 changes: 4 additions & 0 deletions .devcontainer/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# !/bin/bash --login
# activate conda environment and let the following process take over
source ~/.bashrc
exec "$@"
14 changes: 14 additions & 0 deletions .devcontainer/requirement.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
channels:
- defaults
- conda-forge
dependencies:
- python=3.9
- pip
- cmake=3.21.2
- scikit-build
- ninja
- twine
- pytest
- pyyaml
- pip:
- "pdoc3"
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
llvm-project-llvmorg-12.0.1/
build/
docs/_build
tests/bin
Testing/
CMakeFiles/
dist/
html/
.pytest_cache/
_skbuild/
.vscode
129 changes: 129 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: Build pdic
on:
push:
tags:
- "*"
jobs:
create_release:
if: contains(github.ref, 'v')
name: Create release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
id: ${{ steps.create_release.outputs.id }}
steps:
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
build:
name: Build ${{ matrix.os }}
needs: create_release
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-20.04] # , macOS-10.15, windows-2019
if: contains(github.ref, 'v')
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get the version
id: get_version
run: |
echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3)
- name: Install system requirement
if: ${{ matrix.os == 'ubuntu-20.04' }}
run: |
sudo apt update && sudo apt install -y \
ca-certificates sudo git
id: checkout
- name: Conda activate
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
activate-environment: pdic-env
- name: Install conda dependencies
shell: bash -l {0}
id: installation
run: |
set -eux; conda env update --name pdic-env --file .devcontainer/conda-github-requirement.yml
- name: Deploy mkdocs
if: ${{ contains(github.ref, 'p') && matrix.os != 'windows-2019'}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash -l {0}
run: |
mkdocs gh-deploy --force
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Docker image
run: docker build . -f .devcontainer/Dockerfile -t pdic:latest
- name: Build in Docker image
id: builder
shell: bash -l {0}
run: |
version=${{ steps.get_version.outputs.VERSION }}
export version=${version//[!0-9.]/}
echo ::set-output name=PYVERSION::$(echo ${version})
sudo chmod -R a+w `pwd`
docker run -e version=${version} -v `pwd`:/home/pdi/app pdic python3 setup.py build
docker run -e version=${version} -v `pwd`:/home/pdi/app pdic python3 setup.py bdist_wheel --plat-name manylinux1_x86_64 -j `nproc`
docker run -e version=${version} -v `pwd`:/home/pdi/app pdic python3 setup.py bdist_wheel --plat-name manylinux2010_x86_64 -j `nproc`
docker run -e version=${version} -v `pwd`:/home/pdi/app pdic python3 setup.py build_ext --inplace -j `nproc`
docker run -v `pwd`:/home/pdi/app pdic cmake -S . -DBINARY:BOOL=ON -B build
docker run -v `pwd`:/home/pdi/app pdic cmake --build build -- -j `nproc`
docker run -v `pwd`:/home/pdi/app pdic cmake -S . -DTEST:BOOL=ON -B build
docker run -v `pwd`:/home/pdi/app pdic cmake --build build -- -j `nproc`
docker run -v `pwd`:/home/pdi/app pdic /bin/bash -c "pip install dist/pdic-${version}-cp39-cp39-manylinux1_x86_64.whl && pytest"
docker run -v `pwd`:/home/pdi/app pdic ctest --test-dir build
docker run -v `pwd`:/home/pdi/app pdic /bin/bash -c "pip install dist/pdic-${version}-cp39-cp39-manylinux1_x86_64.whl && pdoc3 pdic --pdf > dist/pdic-pdoc3-${version}.md && pdoc3 pdic --html -o dist/"
sudo chown -R $USER `pwd`
mv build/pdic.static dist/
mv ./docs_format/*.ttf .
- name: Build pandoc documentation
uses: docker://pandoc/latex
with:
args: >- # allows you to break string into multiple lines
--metadata=title:"PDIC: (IDL) Transpiler Source-to-source compiler C/C++ to YAML Description based on clang "
--variable=documentclass:"extarticle"
--variable=mainfont:"Roboto"
--variable=mainfontoptions:"Extension=.ttf, UprightFont=*-Regular, BoldFont=*-Bold, ItalicFont=*-Italic, BoldItalicFont=*-BoldItalic"
--variable=fontsize:"10pt"
--variable=geometry:"margin=1.5cm,a4paper"
--metadata=author:"BARRE kevin"
--from=markdown+abbreviations+tex_math_single_backslash
--pdf-engine=xelatex
--toc --toc-depth=4
--output=dist/pdic-pdoc3-${{ steps.builder.outputs.PYVERSION }}.pdf
dist/pdic-pdoc3-${{ steps.builder.outputs.PYVERSION }}.md
- name: Upload Releases Assets
id: upload-release-assets
uses: dwenegar/upload-release-assets@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ needs.create_release.outputs.id }}
assets_path: ./dist/
- name: Deploy to PyPI ${{ matrix.os }}
if: ${{ contains(github.ref, 'p') && matrix.os != 'windows-2019'}}
shell: bash -l {0}
env:
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload -u __token__ -p $TWINE_PASSWORD dist/*.whl
- name: Deploy to PyPI windows-2019
if: ${{ contains(github.ref, 'p') && matrix.os == 'windows-2019'}}
run: |
pip install twine
twine upload -u __token__ -p ${{ secrets.PYPI_PASSWORD }} dist/*.whl
77 changes: 73 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,76 @@
llvm-project-llvmorg-12.0.1/
dockerfiles/
#
# File: .gitignore
# Project: pdic
# File Created: Thursday, 22nd July 2021 11:05:12 pm
# Author: kbarre (kevin.barre@epitech.eu)
# -----
# Last Modified: Friday, 30th July 2021 6:04:17 pm
# Modified By: kbarre (kevin.barre@epitech.eu>)
# -----
# Licenses: EUPL
# -----
# Copyright 2021 - 2021 neudinger
#

# Build directory
build/
llvm-project-llvmorg-12.0.1/
docs/_build
tests/bin
Testing/
CMakeFiles/
dist/
html/
.pytest_cache/
_skbuild/

# Python
*.egg-info
__pycache__
.eggs
*.pyc

# VS Code
.vscode

# Prerequisites
*.yml
*.tar*
documentation/
!examples/expected/*.yml
!_config.yml
!mkdocs.yml
!.github/workflows/ci-cd.yml
!examples/expected/*.yml
!.devcontainer/*.yml
!requirement.yml
__version__.py

# Compiled Object files
*.slo
*.lo
*.o
*.obj
CMakeCache*
Makefile

# Precompiled Headers
*.gch
*.pch

# Compiled python files
core

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app
Loading

0 comments on commit 7dc03e1

Please sign in to comment.