Skip to content

Commit 3c679a8

Browse files
authored
Merge pull request #26 from IGNF/dev
Merge dev to main for version 0.0.1
2 parents 82c24b7 + 93270a9 commit 3c679a8

File tree

100 files changed

+5802
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+5802
-0
lines changed

.env_example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DB_UNI_USER='TO_BE_DEFINED'
2+
DB_UNI_PASSWORD='TO_BE_DEFINED'

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 119

.github/workflows/ci.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: ci
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- dev
8+
9+
jobs:
10+
build_and_test:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
16+
steps:
17+
# cf https://samuelsson.dev/access-private-submodules-in-github-actions/ for submodule fetching
18+
- name: Checkout branch
19+
uses: actions/checkout@v4
20+
with:
21+
ssh-key: ${{ secrets.SUBMODULE_PULL_KEY }}
22+
submodules: 'recursive'
23+
24+
# See https://github.com/marketplace/actions/setup-micromamba
25+
- name: Install conda env
26+
uses: mamba-org/[email protected]
27+
with:
28+
environment-file: environment.yml
29+
environment-name: lidro # activate the environment
30+
cache-environment: true
31+
cache-downloads: true
32+
generate-run-shell: true
33+
- name: Unit test
34+
shell: micromamba-shell {0}
35+
run: |
36+
cp .env_example .env
37+
python -m pytest -m "not returnfile and not bduni" -s --log-cli-level INFO

.github/workflows/cicd_deploy.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: cicd_deploy
2+
3+
on:
4+
push:
5+
# Run deployment tests on every new version tag and every push to main and dev:
6+
# Run actual deploymment only on push to main and tags
7+
branches: [ "main", "dev" ]
8+
tags:
9+
- v*.*.*
10+
11+
env:
12+
IMAGE_NAME: ${{ github.repository }}
13+
REGISTRY: ghcr.io
14+
TEST_TAG: ${{ github.repository }}:test
15+
16+
jobs:
17+
deploy_docker:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
packages: write
22+
23+
steps:
24+
# cf https://samuelsson.dev/access-private-submodules-in-github-actions/ for submodule fetching
25+
- name: Checkout branch
26+
uses: actions/checkout@v4
27+
with:
28+
ssh-key: ${{ secrets.SUBMODULE_PULL_KEY }}
29+
submodules: 'recursive'
30+
31+
# build the image
32+
- name: Build Docker image for tests
33+
id: build
34+
uses: docker/build-push-action@v5
35+
with:
36+
context: . # cf https://github.com/docker/build-push-action/issues/638
37+
load: true
38+
tags: ${{ env.TEST_TAG }}
39+
40+
- name: Run tests in docker
41+
run: >
42+
docker run -v $(pwd)/data:/lidro/data --ipc=host ${{ env.TEST_TAG }}
43+
python -m pytest test -m "not returnfile and not bduni" -s --log-cli-level INFO
44+
45+
- name: Set version number
46+
run: |
47+
echo "VERSION=v$(python -m lidro._version)" >> $GITHUB_ENV
48+
49+
- name: Check tag and version number consistency
50+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
51+
run: |
52+
if [[ ${{ github.ref_name }} == ${{ env.VERSION }} ]]
53+
then
54+
echo "OK: Tag name and _version.py (${{ env.VERSION }}) version number (${{ github.ref_name }}) match"
55+
else
56+
echo "NOK: Tag name and _version.py (${{ env.VERSION }}) version number (${{ github.ref_name }}) don't match"
57+
exit 1
58+
fi
59+
60+
# Login against a Docker registry except on dev branch
61+
# https://github.com/docker/login-action
62+
- name: Log into registry ${{ env.REGISTRY }}
63+
uses: docker/login-action@v2
64+
if: ${{ github.ref_name != 'dev' }}
65+
with:
66+
registry: ${{ env.REGISTRY }}
67+
username: ${{ github.actor }}
68+
password: ${{ secrets.GITHUB_TOKEN }}
69+
70+
# Extract metadata (tags, labels) for Docker except on dev branch
71+
# https://github.com/docker/metadata-action
72+
- name: Extract Docker metadata
73+
id: metadata
74+
if: ${{ github.ref_name != 'dev' }}
75+
uses: docker/metadata-action@v5
76+
with:
77+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
78+
79+
# Build and push Docker image with Buildx except on dev branch
80+
# https://github.com/docker/build-push-action
81+
- name: Build and push Docker image
82+
id: build-and-push
83+
if: ${{ github.ref_name != 'dev' }}
84+
uses: docker/build-push-action@v5
85+
with:
86+
context: .
87+
push: true
88+
tags: ${{ steps.metadata.outputs.tags }}
89+
labels: ${{ steps.metadata.outputs.labels }}

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
**/__pycache__
2+
tmp
3+
**.log
4+
5+
.env
6+
7+
outputs/

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "data"]
2+
path = data
3+
url = [email protected]:IGNF/lidro-data.git

.pre-commit-config.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# See https://dev.to/m1yag1/how-to-setup-your-project-with-pre-commit-black-and-flake8-183k
2+
# for pre-commits setup
3+
# See https://pre-commit.com for more information
4+
# See https://pre-commit.com/hooks.html for more hooks
5+
repos:
6+
- repo: https://github.com/pycqa/isort
7+
rev: 5.13.2
8+
hooks:
9+
- id: isort
10+
name: isort (python)
11+
- repo: https://github.com/ambv/black
12+
rev: 24.2.0
13+
hooks:
14+
- id: black
15+
language_version: python3.11
16+
- repo: https://github.com/pre-commit/pre-commit-hooks
17+
rev: v2.0.0
18+
hooks:
19+
- id: flake8

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# v0.1.0
2+
- Correction du bug au moment de la jonction entre les parties du squelette qui créait des
3+
interpolations imprévues entre des extrémités de branches qui ne devraient pas être reliées.
4+
cf. https://github.com/IGNF/lidro/pull/21
5+
6+
# v0.0.1
7+
- Création du Dockerfile pour faire fonctionner le projet Lidro
8+
9+
# v0.0.0
10+
- Première version de Lidro sans recette

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM mambaorg/micromamba:latest
2+
3+
USER root
4+
5+
WORKDIR /lidro
6+
7+
# # Set up the Conda environment: cf https://github.com/mamba-org/micromamba-docker
8+
COPY environment.yml /tmp/env.yaml
9+
COPY requirements.txt /tmp/requirements.txt
10+
RUN chown $MAMBA_USER:$MAMBA_USER /tmp/env.yaml
11+
RUN micromamba install -y -n base -f /tmp/env.yaml && \
12+
micromamba clean --all --yes
13+
14+
ENV ENV=base
15+
ARG MAMBA_DOCKERFILE_ACTIVATE=1
16+
17+
COPY lidro lidro
18+
COPY configs configs
19+
COPY test test

Makefile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Makefile to manage main tasks
2+
# cf. https://blog.ianpreston.ca/conda/python/bash/2020/05/13/conda_envs.html#makefile
3+
4+
# Oneshell means I can run multiple lines in a recipe in the same shell, so I don't have to
5+
# chain commands together with semicolon
6+
.ONESHELL:
7+
SHELL = /bin/bash
8+
install:
9+
pip install -e .
10+
11+
install-precommit:
12+
pre-commit install
13+
14+
mamba-env-create:
15+
mamba env create -n lidro -f environment.yml
16+
17+
mamba-env-update:
18+
mamba env update -n lidro -f environment.yml
19+
20+
##############################
21+
# Docker
22+
##############################
23+
24+
REGISTRY=ghcr.io
25+
IMAGE_NAME=lidro
26+
NAMESPACE=ignf
27+
VERSION=`python -m lidro._version`
28+
FULL_IMAGE_NAME=${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}:${VERSION}
29+
DATA_DIR= `realpath ./data`
30+
31+
32+
docker-build:
33+
docker build --no-cache -t ${IMAGE_NAME}:${VERSION} -f Dockerfile .
34+
35+
docker-test:
36+
docker run -v ${DATA_DIR}:/lidro/data --rm -it ${IMAGE_NAME}:${VERSION} python -m pytest -s test
37+
38+
docker-remove:
39+
docker rmi -f `docker images | grep ${IMAGE_NAME} | tr -s ' ' | cut -d ' ' -f 3`
40+
docker rmi -f `docker images -f "dangling=true" -q`
41+
42+
docker-deploy:
43+
docker tag ${IMAGE_NAME}:${VERSION} ${FULL_IMAGE_NAME}
44+
docker push ${FULL_IMAGE_NAME}
45+

0 commit comments

Comments
 (0)