Skip to content

Commit

Permalink
Merge pull request #42 from TelesCoop/fix-ci
Browse files Browse the repository at this point in the history
Enable CI
  • Loading branch information
ludovicdmt authored Feb 13, 2025
2 parents 0a98442 + 869bff9 commit f28083d
Show file tree
Hide file tree
Showing 18 changed files with 24,670 additions and 205,976 deletions.
89 changes: 60 additions & 29 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ name: Run basic checks
on:
push:
branches:
- dev
- main
pull_request:
branches: [main, dev]
types: # https://github.com/mistralai/mistral-common/blob/main/.github/workflows/lint_build_test.yaml
branches:
- dev
- main
types:
- opened
- reopened
- synchronize
- ready_for_review
# Run CI only when PR is ready for review or when commits are added

env:
TELESCOOP_DEV: true
IS_TESTING: true
Expand All @@ -20,63 +22,83 @@ jobs:
setup:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

- name: Install python
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
# https://github.com/actions/setup-python/blob/main/README.md#caching-packages-dependencies
- run: pip install -r back/requirements.txt

- name: Install front js dependencies
run: npm install
working-directory: ./front
- name: Create back/local_settings.conf
run: echo "${{ secrets.LOCAL_SETTINGS_CONF }}" > local_settings.conf
working-directory: ./back
- name: Cache Python dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('back/requirements.txt') }}

- name: Cache Node.js dependencies
uses: actions/cache@v3
with:
path: ./front/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('front/package-lock.json') }}

pre-commit:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
needs: setup
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
- name: Restore Python cache
uses: actions/cache@v3
# https://github.com/actions/setup-python/blob/main/README.md#caching-packages-dependencies
- run: pip install -r back/requirements.txt

- name: Set up PostGIS
uses: nyurik/action-setup-postgis@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('back/requirements.txt') }}
- name: Install python dependencies if not cached
if: steps.cache-python.outputs.cache-hit != 'true'
run: pip install -r back/requirements.txt
username: myuser
password: securepassword
database: mydatabase
port: 5432
id: postgres

- name: Create local_setting.ini
run: |
cat <<EOF > back/local_settings.ini
[database]
engine=postgresql
user=myuser
name=mydatabase
password=securepassword
EOF
- name: Restore Node.js cache
uses: actions/cache@v3
with:
path: ./front/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('front/package-lock.json') }}

- name: Install js dependencies if not cached
if: steps.cache-node.outputs.cache-hit != 'true'
run: npm install
working-directory: ./front

- name: Enforce pre-commit hook server side
env:
DATABASE_URL: "postgres://myuser:securepassword@localhost:5432/mydatabase"
PGSERVICE: ${{ steps.postgres.outputs.service-name }}
uses: pre-commit/[email protected]

node-setup:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
needs: setup
steps:
- uses: actions/checkout@v4
Expand All @@ -96,7 +118,7 @@ jobs:
working-directory: ./front

frontend-tests:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
needs: [setup, node-setup]
steps:
- uses: actions/checkout@v4
Expand All @@ -117,15 +139,24 @@ jobs:
- name: Run vitest
run: npm run test
working-directory: ./front
- name: Run cypress component tests
uses: cypress-io/github-action@v6
with:
component: true
working-directory: ./front

# - name: Run cypress component tests
# uses: cypress-io/github-action@v6
# with:
# component: true
# working-directory: ./front
doc-tests:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
needs: [setup]
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python doc
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
- run: pip install mkdocs mkdocs-material mkdocstrings[python] mkdocs-git-revision-date-localized-plugin mkdocs-minify-plugin pymdown-extensions

- name: Run documentation validation
run: mkdocs build
10 changes: 5 additions & 5 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ name: Run deploy prod
on:
push:
branches:
- main
- dev
# From https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#running-a-workflow-when-a-pull-request-is-approved
pull_request_review:
pull_request:
branches:
- main
- dev
types:
- submitted
- closed

jobs:
deploy-prod:
if: github.event.review.state == 'approved'
if: github.event.pull_request.merged == true
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand Down
17 changes: 2 additions & 15 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,14 @@ on:
push:
branches:
- main
- dev
jobs:
build:
if: "!contains(github.event.head_commit.message, '[no doc]')"
runs-on: ubuntu-22.04

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mkdocs
pip install -r requirements.txt # If you have additional dependencies
- name: Deploy doc
- name: Build and deploy doc
uses: dawidd6/action-ansible-playbook@v2
with:
playbook: docs.yml
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ mvt_files/*
media/*
back/site/*
site/*

back/.coverage
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ repos:
- args:
- --autofix
id: pretty-format-json
exclude: back/file_data/.*\.json$
repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
- hooks:
Expand Down Expand Up @@ -65,7 +66,7 @@ repos:
- hooks:
- id: python-safety-dependencies-check
repo: https://github.com/Lucas-C/pre-commit-hooks-safety
rev: v1.3.0
rev: v1.4.0
- hooks:
- id: beautysh
repo: https://github.com/bemeurer/beautysh.git
Expand Down
8 changes: 8 additions & 0 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fileignoreconfig:
- filename: back/iarbre_data/tests/test_data/parkingsurfacique.geojson
checksum: 66a6bee103123c599470c847555001aff5d7db6e7571e5904160f88b6d4ad0c0
- filename: back/iarbre_data/tests/test_data/espacepublic.geojson
checksum: 923eba4992fca9f4d232e3ecec353c4698f91f7a1578a51c81a0b1d01d32210b
- filename: back/iarbre_data/tests/test_data/communes_gl_2025.geojson
checksum: be406c3274b27238f1d5497edb83f0b4331ad92cab8d28bc77e151202663b9d0
version: ""
Loading

0 comments on commit f28083d

Please sign in to comment.