Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/taxonomy-editor-fron…
Browse files Browse the repository at this point in the history
…tend/decode-uri-component-0.2.2
  • Loading branch information
eric-nguyen-cs authored Oct 26, 2023
2 parents 7a45fa2 + de7eebf commit b774178
Show file tree
Hide file tree
Showing 74 changed files with 6,405 additions and 3,707 deletions.
15 changes: 15 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ TAXONOMY_EDITOR_EXPOSE=127.0.0.1:8091
# this one is needed only in dev, to tell nginx and fastapi, which port urls should include
# it must either start with : or be empty
PUBLIC_TAXONOMY_EDITOR_PORT=:8091
# this one is used to expose the websocket in dev and shoudl match PUBLIC_TAXONOMY_EDITOR_PORT but without leading ":"
WDS_SOCKET_PORT=8091
# API scheme is useful because, in prod, we have to proxy and already proxied request
# and loose the original scheme
API_SCHEME=http

# This is the PAT (Personal Access Token)
# to create PRs on openfoodfacts-server github project (must be able to read-write PRs)
Expand All @@ -24,3 +29,13 @@ REPO_URI=openfoodfacts/openfoodfacts-server
# eventually set this to your local user id to avoid permissions errors
# USER_UID=1000
# USER_GID=1000

# Neo4J configurations
NEO4J_BOLT_EXPOSE=127.0.0.1:7687
NEO4J_ADMIN_EXPOSE=127.0.0.1:7474
# note: in prod, heap_initial__size and max__size should match, but it's ok like that for dev
NEO4J_server_memory_heap_initial__size=512M
NEO4J_server_memory_heap_max__size=2G
NEO4J_server_memory_pagecache_size=1G
NEO4J_db_memory_transaction_total_max=512M

2 changes: 1 addition & 1 deletion .github/workflows/auto-assign-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
assign-author:
runs-on: ubuntu-latest
steps:
- uses: toshimaru/auto-author-assign@v1.6.1
- uses: toshimaru/auto-author-assign@v2.0.1
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/container-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Docker Image Build CI
on:
push:
branches:
- $default-branch
- main
- deploy-*
tags:
- v*.*.*
Expand All @@ -17,7 +17,7 @@ jobs:
- taxonomy_frontend
- taxonomy_api
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 1

Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
type=sha,format=long
- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: ${{ env.build_context }}
push: true
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/container-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
timeoutSeconds: 600 # 10m

- name: Do something if build isn't launched
if: steps.wait-build-frontend.outputs.conclusion == 'does not exist' || steps.wait-build-api.outputs.conclusion == 'does not exist'
if: steps.wait-build-frontend.outputs.conclusion == 'not found' || steps.wait-build-api.outputs.conclusion == 'not found'
run: echo job does not exist && true

- name: Do something if build fail
Expand Down Expand Up @@ -134,11 +134,19 @@ jobs:
echo "COMPOSE_FILE=docker-compose.yml;docker/prod.yml" >> .env
echo "DOCKER_TAG=sha-${{ github.sha }}" >> .env
# Neo4j configuration
echo "NEO4J_server_memory_heap_initial__size=3G" >> .env
echo "NEO4J_server_memory_heap_max__size=3G" >> .env
echo "NEO4J_server_memory_pagecache_size=2G" >> .env
# we don't want transaction to grow too big
echo "NEO4J_db_memory_transaction_total_max=1G" >> .env
# App environment variables
echo "TAXONOMY_EDITOR_EXPOSE=${{ env.TAXONOMY_EDITOR_EXPOSE }}" >> .env
echo "TAXONOMY_EDITOR_DOMAIN=${{ env.TAXONOMY_EDITOR_DOMAIN }}" >> .env
# should be blank in production
echo "PUBLIC_TAXONOMY_EDITOR_PORT=" >> .env
# we use https
echo "API_SCHEME=https" >> .env
# the PAT is environment dependant
# and must have write access to PRs on the target repo (see REPO_URI)
echo "GITHUB_PAT=${{ secrets.OFF_SERVER_GITHUB_PAT }}" >> .env
Expand Down Expand Up @@ -212,7 +220,7 @@ jobs:
cd ${{ matrix.env }}
docker system prune -af
- uses: frankie567/grafana-annotation-action@v1.0.2
- uses: frankie567/grafana-annotation-action@v1.0.3
if: ${{ always() }}
with:
apiHost: https://grafana.openfoodfacts.org
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: 'Dependency Review'
uses: actions/dependency-review-action@v3
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ jobs:
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
labeled: mockups available, needs mockup
label-operator: OR
- uses: actions/add-to-project@main
with:
project-url: https://github.com/orgs/openfoodfacts/projects/25 # Add issue to the documentation project
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
labeled: documentation
label-operator: OR
37 changes: 2 additions & 35 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,15 @@ on:
pull_request:

jobs:
# Parser quality
parser-checks:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.10"
- "3.9"

steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3
- name: build docker
run: |
export USER_UID=$(id -u)
export USER_GID=$(id -g)
DOCKER_BUILDKIT=1 docker-compose build
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Packages
run: |
cd parser
pip install -r requirements-dev.txt
- name: Make checks
run: |
cd parser
make checks
# taxonomy editor quality
# taxonomy editor quality for frontend and backend
taxonomy-editor-checks:
runs-on: ubuntu-latest
steps:
#----------------------------------------------
# check-out repo
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Make checks
run: |
export USER_UID=$(id -u)
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Ready to contribute code? Here's how to set up Taxonomy Editor for local develop
```
git clone git@github.com:your_name_here/taxonomy-editor.git
```
3. Follow [install documentation](./docs/explanations/docker-compose-setup.md)
3. Follow [install documentation](./doc/introduction/setup-dev.md)

4. code!

Expand Down Expand Up @@ -96,4 +96,4 @@ Before you submit a pull request, check that it meets these guidelines:
2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring.


This contributing page was adapted from [Pyswarms documentation](https://github.com/ljvmiranda921/pyswarms/blob/master/CONTRIBUTING.rst).
This contributing page was adapted from [Pyswarms documentation](https://github.com/ljvmiranda921/pyswarms/blob/master/CONTRIBUTING.rst).
43 changes: 39 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# to suppress the path translation in Windows
export MSYS_NO_PATHCONV=1

ifeq ($(findstring cmd.exe,$(SHELL)),cmd.exe)
$(error "We do not suppport using cmd.exe on Windows, please run in a 'git bash' console")
endif

# use bash everywhere !
SHELL := /bin/bash
ENV_FILE ?= .env

Expand All @@ -13,22 +21,45 @@ export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1

DOCKER_COMPOSE=docker-compose --env-file=${ENV_FILE}
DOCKER_COMPOSE_TEST=COMPOSE_PROJECT_NAME=test_taxonomy docker-compose --env-file=${ENV_FILE}
# tweak some config to avoid port conflicts
DOCKER_COMPOSE_TEST=COMPOSE_PROJECT_NAME=test_taxonomy NEO4J_ADMIN_EXPOSE=127.0.0.1:7475 NEO4J_BOLT_EXPOSE=127.0.0.1:7688 docker-compose --env-file=${ENV_FILE}

.PHONY: tests

#------------#
# dev setup #
#------------#

build:
@echo "🍜 Building docker images"
${DOCKER_COMPOSE} build
@echo "🍜 Project setup done"

up:
@echo "🍜 Running project (ctrl+C to stop)"
${DOCKER_COMPOSE} up

dev: build up


#-----------#
# dev tools #
#-----------#


# lint code
lint: backend_lint
lint: backend_lint frontend_lint

backend_lint:
@echo "🍜 Linting python code"
${DOCKER_COMPOSE} run --rm taxonomy_api isort .
${DOCKER_COMPOSE} run --rm taxonomy_api black .

frontend_lint:
@echo "🍜 Linting react code"
${DOCKER_COMPOSE} run --rm taxonomy_node npx prettier -w src/


# check code quality
quality: backend_quality frontend_quality

Expand All @@ -40,15 +71,20 @@ backend_quality:

frontend_quality:
@echo "🍜 Quality checks JS"
${DOCKER_COMPOSE} run --rm taxonomy_node npx prettier -c src/
${DOCKER_COMPOSE} run --rm -e CI=true taxonomy_node npm run build
# restore the .empty file (if possible)
git checkout taxonomy-editor-frontend/build/.empty || true



tests: backend_tests

backend_tests:
@echo "🍜 Running python tests"
${DOCKER_COMPOSE_TEST} up -d neo4j
${DOCKER_COMPOSE_TEST} run --rm taxonomy_api pytest . /parser
${DOCKER_COMPOSE_TEST} run --rm taxonomy_api pytest /parser /parser
${DOCKER_COMPOSE_TEST} run --rm taxonomy_api pytest /code/tests
${DOCKER_COMPOSE_TEST} stop neo4j

checks: quality tests
Expand All @@ -61,4 +97,3 @@ checks: quality tests
create_external_volumes:
@echo "🍜 Creating external volumes (production only) …"
docker volume create ${COMPOSE_PROJECT_NAME}_neo4j-data

Loading

0 comments on commit b774178

Please sign in to comment.