Skip to content

Commit f26e5d9

Browse files
Merge branch 'main' into fix/soilweb
2 parents d83b4f5 + 6c18bf0 commit f26e5d9

File tree

68 files changed

+66562
-25012
lines changed

Some content is hidden

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

68 files changed

+66562
-25012
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ max_line_length = 119
1717
# Makefiles always use tabs for indentation
1818
[Makefile]
1919
indent_style = tab
20+
21+
[*.yml]
22+
indent_size = 2
23+
quote_type = single

.github/dependabot.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55

66
version: 2
77
updates:
8-
- package-ecosystem: "pip"
9-
directory: "/"
8+
- package-ecosystem: 'pip'
9+
directory: '/'
1010
schedule:
11-
interval: "weekly"
11+
interval: 'weekly'
1212
allow:
1313
- dependency-type: all
1414

15-
- package-ecosystem: "github-actions"
16-
directory: "/"
15+
- package-ecosystem: 'github-actions'
16+
directory: '/'
1717
schedule:
18-
interval: "weekly"
18+
interval: 'weekly'
1919
allow:
2020
- dependency-type: all
21-

.github/workflows/auto-approve.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Auto approve
2+
3+
on: pull_request_target
4+
5+
permissions:
6+
pull-requests: write
7+
8+
jobs:
9+
auto-approve:
10+
runs-on: ubuntu-latest
11+
if: github.actor == 'dependabot[bot]'
12+
steps:
13+
- uses: hmarr/auto-approve-action@v4

.github/workflows/build.yml

Lines changed: 88 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,93 @@
11
name: build
22

33
on:
4-
workflow_dispatch:
5-
push:
6-
branches:
7-
- main
8-
pull_request:
9-
branches:
10-
- main
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
types:
10+
- opened
11+
- edited
12+
- synchronize
1113

1214
jobs:
13-
lint:
14-
runs-on: ubuntu-24.04
15-
16-
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v4
19-
20-
- name: Setup Python
21-
uses: actions/setup-python@v5
22-
with:
23-
python-version: "3.13.0"
24-
cache: pip
25-
cache-dependency-path: "requirements-dev.txt"
26-
27-
- name: Install Python dependencies
28-
run: make install-dev
29-
30-
- name: Run lint checks
31-
run: make lint
32-
33-
test:
34-
runs-on: ubuntu-24.04
35-
needs: lint
36-
37-
steps:
38-
- name: Checkout
39-
uses: actions/checkout@v4
40-
41-
- name: Update and install Linux packages
42-
run: |
43-
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
44-
sudo apt-get update
45-
sudo apt-get install libgdal-dev gdal-bin python3-gdal
46-
47-
- name: Setup Python
48-
uses: actions/setup-python@v5
49-
with:
50-
python-version: "3.13.0"
51-
cache: pip
52-
cache-dependency-path: |
53-
'requirements.txt'
54-
'requirements-dev.txt'
55-
56-
- name: Install Python dependencies
57-
run: |
58-
make install
59-
make install-dev
60-
61-
- name: Restore data cache
62-
uses: actions/cache@v4
63-
with:
64-
path: Data/
65-
key: ${{ runner.os }}-data-${{ hashFiles('Data/*') }}
66-
restore-keys: ${{ runner.os }}-data-
67-
68-
- name: Download data
69-
if: ${{ hashFiles('Data/*') == '' }}
70-
run: make download-soil-data
71-
72-
- name: Run tests
73-
run: make test
15+
lint:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v5
21+
22+
- name: Setup Python
23+
uses: actions/setup-python@v6
24+
with:
25+
python-version: '3.13.7'
26+
cache-dependency-path: 'requirements-dev.txt'
27+
28+
- name: Install uv
29+
uses: astral-sh/setup-uv@v6
30+
with:
31+
enable-cache: true
32+
cache-dependency-glob: 'requirements**.txt'
33+
34+
- name: Install Python dependencies
35+
run: make install-dev DC_ENV=ci
36+
37+
- name: Run lint checks
38+
run: make lint
39+
40+
test:
41+
runs-on: ubuntu-latest
42+
needs: lint
43+
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v5
47+
48+
- name: Update and install Linux packages
49+
run: |
50+
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
51+
sudo apt-get update
52+
sudo apt-get install libgdal-dev gdal-bin python3-gdal
53+
54+
- name: Setup Python
55+
uses: actions/setup-python@v6
56+
with:
57+
python-version: '3.13.7'
58+
cache-dependency-path: |
59+
'requirements.txt'
60+
'requirements-dev.txt'
61+
62+
- name: Install uv
63+
uses: astral-sh/setup-uv@v6
64+
with:
65+
enable-cache: true
66+
cache-dependency-glob: 'requirements**.txt'
67+
68+
- name: Install Python dependencies
69+
run: |
70+
make install DC_ENV=ci
71+
make install-dev DC_ENV=ci
72+
73+
- name: Restore data cache
74+
uses: actions/cache@v4
75+
with:
76+
path: Data/
77+
key: ${{ runner.os }}-data-${{ hashFiles('Data/*') }}
78+
restore-keys: ${{ runner.os }}-data-
79+
80+
- name: Download data
81+
if: ${{ hashFiles('Data/*') == '' }}
82+
run: make download-soil-data
83+
84+
- name: Start soil id DB
85+
run: docker compose up -d
86+
87+
- name: Run tests
88+
env:
89+
DB_NAME: soil_id
90+
DB_HOST: localhost
91+
DB_USERNAME: postgres
92+
DB_PASSWORD: postgres
93+
run: make test
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
name: check-commits
22

33
on:
4-
pull_request:
5-
branches:
6-
- main
7-
types:
8-
- opened
9-
- edited
10-
- synchronize
4+
pull_request:
5+
branches:
6+
- main
7+
types:
8+
- opened
9+
- edited
10+
- synchronize
1111

1212
jobs:
13-
check-for-cc:
14-
runs-on: ubuntu-latest
15-
steps:
16-
- name: Checkout
17-
uses: actions/checkout@v4
13+
check-for-cc:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v5
1818

19-
- name: Check for Conventional Commits
20-
uses: agenthunt/[email protected]
19+
- name: Check for Conventional Commits
20+
uses: agenthunt/[email protected]

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
__pycache__/
33
*.py[cod]
44
*$py.class
5+
.ipynb_checkpoints/
6+
*.ipynb
57

68
# Build files
79
.rebuild
@@ -25,5 +27,6 @@ prof/
2527

2628
# reference and output files
2729
Data/
30+
bulk_test_result*
2831

2932
get-pip.py*

.pre-commit-config.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
default_install_hook_types:
2+
- pre-commit
3+
- commit-msg
4+
5+
repos:
6+
- repo: https://gitlab.com/vojko.pribudic.foss/pre-commit-update
7+
rev: v0.8.0
8+
hooks:
9+
- id: pre-commit-update
10+
11+
- repo: https://github.com/astral-sh/ruff-pre-commit
12+
rev: v0.14.0
13+
hooks:
14+
- id: ruff-check
15+
args: [--fix]
16+
- id: ruff-format
17+
18+
- repo: https://github.com/compilerla/conventional-pre-commit
19+
rev: v4.2.0
20+
hooks:
21+
- id: conventional-pre-commit
22+
stages: [commit-msg]
23+
args: []

Dockerfile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Stage 1: Build database with preloaded data
2+
FROM postgis/postgis:16-3.5 as builder
3+
4+
ARG POSTGRES_DB=soil_id
5+
ARG POSTGRES_USER=postgres
6+
ARG POSTGRES_PASSWORD=postgres
7+
ARG DATABASE_DUMP_FILE=Data/soil_id_db.dump
8+
9+
ENV POSTGRES_DB=${POSTGRES_DB}
10+
ENV POSTGRES_USER=${POSTGRES_USER}
11+
ENV POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
12+
13+
# Copy dump into builder stage
14+
COPY ${DATABASE_DUMP_FILE} /tmp/soil_id_db.dump
15+
16+
# Initialize database and preload it
17+
RUN mkdir -p /var/lib/postgresql/data \
18+
&& chown -R ${POSTGRES_USER}:${POSTGRES_USER} /var/lib/postgresql
19+
20+
USER ${POSTGRES_USER}
21+
22+
# Initialize database system
23+
RUN /usr/lib/postgresql/16/bin/initdb -D /var/lib/postgresql/data
24+
25+
# Start database in background, preload dump, shut it down
26+
RUN pg_ctl -D /var/lib/postgresql/data -o "-c listen_addresses=''" -w start \
27+
&& createdb -U ${POSTGRES_USER} ${POSTGRES_DB} \
28+
&& psql -U ${POSTGRES_USER} -d ${POSTGRES_DB} -c "CREATE EXTENSION postgis;" \
29+
&& pg_restore -U ${POSTGRES_USER} -d ${POSTGRES_DB} /tmp/soil_id_db.dump \
30+
&& psql -U ${POSTGRES_USER} -d ${POSTGRES_DB} -c "CLUSTER hwsd2_segment USING hwsd2_segment_shape_idx;" \
31+
&& psql -U ${POSTGRES_USER} -d ${POSTGRES_DB} -c "ANALYZE;" \
32+
&& pg_ctl -D /var/lib/postgresql/data -m fast -w stop
33+
34+
# Stage 2: Final image with loaded data
35+
FROM postgis/postgis:16-3.5
36+
37+
COPY --from=builder /var/lib/postgresql/data /var/lib/postgresql/data
38+
39+
# Create a Docker-friendly pg_hba.conf
40+
USER root
41+
RUN echo "local all all trust" > /var/lib/postgresql/data/pg_hba.conf \
42+
&& echo "host all all 127.0.0.1/32 trust" >> /var/lib/postgresql/data/pg_hba.conf \
43+
&& echo "host all all ::1/128 trust" >> /var/lib/postgresql/data/pg_hba.conf \
44+
&& echo "host all all 0.0.0.0/0 trust" >> /var/lib/postgresql/data/pg_hba.conf \
45+
&& chown ${POSTGRES_USER}:${POSTGRES_USER} /var/lib/postgresql/data/pg_hba.conf
46+
47+
ENV POSTGRES_DB=${POSTGRES_DB}
48+
ENV POSTGRES_USER=${POSTGRES_USER}
49+
ENV POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
50+
51+
USER ${POSTGRES_USER}

0 commit comments

Comments
 (0)