Skip to content

Commit

Permalink
Merge pull request #1237 from Amsterdam/update/action
Browse files Browse the repository at this point in the history
Initial commit
  • Loading branch information
remyvdwereld authored Jul 23, 2024
2 parents ecd29b2 + 40826cb commit 21b368c
Show file tree
Hide file tree
Showing 37 changed files with 411 additions and 445 deletions.
5 changes: 2 additions & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ DATABASE_USER=zaken
DATABASE_PASSWORD=insecure
DATABASE_HOST=database
DATABASE_PORT=5432
SENTRY_DSN=https://[email protected]/0
LOCAL_DEVELOPMENT_AUTHENTICATION=False
LOGGING_LEVEL=WARNING # To prevent flooding the logging in local development. Default is DEBUG.
LOCAL_DEVELOPMENT_AUTHENTICATION=True
LOGGING_LEVEL=WARNING # To prevent flooding the logging in local development. Default is DEBUG. WARNING
SECRET_KEY_TOP_ZAKEN=SECRET_KEY_TOP_ZAKEN
SECRET_KEY_TON_ZAKEN=SECRET_KEY_TON_ZAKEN
BELASTING_API_URL=https://api-acc.belastingen.centric.eu/bel/inn/afne/vora/v1/vorderingenidentificatienummer/
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/bpmn.workflow.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Validate BPMN'
name: 'BPMN validation'
on:
push:
branches: [ main ]
Expand All @@ -11,11 +11,11 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js for BPMN Linting
uses: actions/setup-node@v3.1.1
uses: actions/setup-node@v4
with:
node-version: '12.x'
node-version: '16.x'
- name: Install dependencies for BPMN Linting
run: npm install -g bpmnlint
- name: Linting BPMN models
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "Discovering vulnerabilities using CodeQL"
name: "CodeQL analysis for vulnerabilities "

on:
push:
Expand All @@ -35,12 +35,13 @@ jobs:

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

- name: Set up Python
uses: actions/setup-python@v3.1.2
uses: actions/setup-python@v5
with:
python-version: '3.9.16'
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -54,7 +55,7 @@ jobs:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# Override the default behavior so that the action doesn't attempt
Expand All @@ -68,7 +69,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -82,4 +83,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v3
20 changes: 13 additions & 7 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# action.yml
name: "Run Integration test"
name: "Run e2e-tests"
on:
push:
branches:
Expand All @@ -14,7 +14,7 @@ jobs:
###################################################

- name: Checkout backend
uses: actions/checkout@v3
uses: actions/checkout@v4

###################################################
# BACKEND
Expand All @@ -23,6 +23,7 @@ jobs:
- run: docker network create zaken_network
- run: docker network create top_and_zaak_backend_bridge
- run: docker-compose -f docker-compose.local.yml up --detach
# - run: docker-compose -f docker-compose.tests.yml up
- run: sleep 30
- run: bash bin/setup_credentials.sh
- run: ./e2e-tests/fix_models.sh
Expand All @@ -31,15 +32,20 @@ jobs:
# TEST
###################################################

- run: sudo apt-get install python3.9
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'

# Test version
- run: python --version
- name: Test version
run: python --version

- run: python3 -m pip install -r requirements.txt
- name: Install requirements
run: python3 -m pip install -r requirements.txt
working-directory: e2e-tests

- run: API_HOST=http://127.0.0.1:8080/api/v1 python3 -m unittest
- name: Run tests
run: API_HOST=http://127.0.0.1:8080/api/v1 python3 -m unittest
working-directory: e2e-tests

###################################################
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/git revert --no-commit f1c30cb2e2fd0d3bd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
git revert --no-commit f1c30cb2e2fd0d3bd0d865ec86e8b7546aa91d2e..HEAD
6 changes: 3 additions & 3 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# action.yml
name: 'Start frontend'
name: 'Run integration-tests'
on: pull_request
jobs:
main:
Expand All @@ -9,13 +9,13 @@ jobs:
# CHECKOUT
###################################################
- name: Checkout frontend
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: frontend
repository: amsterdam/zaken-frontend

- name: Checkout backend
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: backend

Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/main.workflow.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Install, lint, test & build'
name: 'Main, lint, build & manage.py test'
on:
push:
branches: [ main ]
Expand All @@ -9,20 +9,20 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3.1.2
uses: actions/setup-python@v5
with:
python-version: 3.9.16
python-version: '3.10'
- name: Linting
run: bash bin/cleanup_pre_commit.sh
- name: Build Docker image
run: docker-compose build -f docker-compose.local.yml
run: docker-compose -f docker-compose.local.yml build
- name: Create Docker network
run: docker network create zaken_network
- name: Create TOP and Zaken Docker network
run: docker network create top_and_zaak_backend_bridge
- name: Start images
run: docker-compose -f docker-compose.local.yml up -d
run: docker-compose -f docker-compose.local.yml up -d
- name: Run Tests
run: docker-compose exec -T zaak-gateway python manage.py test
run: docker-compose -f docker-compose.local.yml exec -T zaak-gateway python manage.py test
53 changes: 34 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,38 +53,52 @@ docker-compose -f docker-compose.local.yml up

To create all necessary credentials run the following command:

```
```bash
bash bin/setup_credentials.sh
```

This will create superuser admin account with the following credentials

```
```bash
email: [email protected]
password: admin
password: insecure
```

Visit the Admin at http://localhost:8080/admin/

Check the health page to see if all services are up and running:
http://localhost:8080/health

To create all necessary user groups run the following command:

```bash
bash bin/setup_user_groups.sh
```

## Running tests

Set LOCAL_DEVELOPMENT_AUTHENTICATION environment variable to True (default)

Run unit tests locally with:

```
docker compose run --rm zaak-gateway python manage.py test
```bash
docker compose -f docker-compose.local.yml run --rm zaak-gateway python manage.py test
```

To run tests for a specific module, add a path:

```bash
docker compose -f docker-compose.local.yml run --rm zaak-gateway python manage.py test apps/cases

```
docker compose run --rm zaak-gateway python manage.py test apps/cases

Or a specific test:

```bash
docker-compose -f docker-compose.local.yml exec -T zaak-gateway python manage.py test apps.addresses.tests.tests_models.AddressModelTest.test_can_create_address_with_bag_result_without_stadsdeel
```


## API documentation (Swagger)

You can access the documentation at:
Expand All @@ -105,24 +119,25 @@ Create a `.env.local` file, on the root of your project, and override the variab

Start your project with the newly created environment variables, like so:

```
docker compose --env-file .env.local up
```bash
docker compose -f docker-compose.local.yml --env-file .env.local up
```

## Enabling Keycloak authentication for a locally run zaken-frontend

Set LOCAL_DEVELOPMENT_AUTHENTICATION environment variable to False
Set `LOCAL_DEVELOPMENT_AUTHENTICATION` environment variable to False

## Generating Mock Data

You can generate mock data easily (from the API swagger environment) by executing the /api/v1/generate-mock/ GET request.
You can generate mock data easily (from the API swagger environment) by executing the `/api/v1/generate-mock/` GET request.

## Update fixtures

Generate new fixtures json file:

```
docker-compose run --rm zaak-gateway python manage.py dumpdata --indent 2 -o temp_fixture.json [app_name]
```bash
docker compose -f docker-compose.local.yml run --rm zaak-gateway python manage.py dumpdata --indent 2 -o temp_fixture.json [app_name]

```

Now manually copy changes you need to the corresponding fixtures file.
Expand All @@ -131,13 +146,13 @@ Now manually copy changes you need to the corresponding fixtures file.

You can add pre-commit hooks for checking and cleaning up your changes:

```
```bash
bash bin/install_pre_commit.sh
```

You can also run the following command to ensure all files adhere to coding conventions:

```
```bash
bash bin/cleanup_pre_commit.sh
```

Expand Down Expand Up @@ -167,7 +182,7 @@ Note that the apps and models should be updated whenever applications and models

For changes to the model you have to migrate the DB.

```python
```bash
python manage.py makemigrations --name <name_of_your_migration> <name_of_apps>

python manage.py migrate
Expand All @@ -193,14 +208,14 @@ Try the online modeler for BPMN-models: https://bpmn.io/. This is a lightweight

Clone the bpmn-io Github repo for editing: https://github.com/bpmn-io/bpmn-js-examples.

```
```bash
git clone [email protected]:bpmn-io/bpmn-js-examples.git
```

If you'd like to use Camunda Platform execution related properties, include the camunda-bpmn-moddle dependency which tells the modeler about camunda:XXX extension properties: https://github.com/bpmn-io/bpmn-js-examples/tree/master/properties-panel#camunda-platform

Follow next steps:
```
```bash
cd bpmn-js-examples

cd properties-panel
Expand Down Expand Up @@ -265,7 +280,7 @@ So if you think existing cases will get stuck in the model, just create a new ve

Example: `housing_corporation` has a new minor version model and the latest version was `5.0.0` but `debrief` has latest version `6.0.0`. Then the new minor version of `housing_corporation` will be `6.1.0`.

```
```json
bpmn_models/default/
├─ debrief/
│ ├─ 0.1.0/
Expand All @@ -280,7 +295,7 @@ bpmn_models/default/

- Add the new version to `WORKFLOW_SPEC_CONFIG` in `settings.py`:

```python
```json
"housing_corporation": {
"versions": {
"5.0.0": {},
Expand Down
18 changes: 12 additions & 6 deletions app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM amsterdam/python:3.9-buster
LABEL maintainer="[email protected]"
FROM python:3.10-bullseye

ENV REQUESTS_CA_BUNDLE /etc/ssl/certs/ca-certificates.crt

Expand All @@ -10,11 +9,16 @@ RUN chmod 644 /usr/local/share/ca-certificates/adp_rootca.crt \

ENV PYTHONUNBUFFERED 1

RUN apt-get update && apt-get install -y
# RUN pip install --upgrade pip
RUN pip install uwsgi
# Update and install necessary packages including GDAL
RUN apt-get update && apt-get install -y \
gdal-bin \
libgdal-dev \
graphviz \
graphviz-dev \
postgresql-client

RUN apt-get install graphviz graphviz-dev -y
RUN pip install --upgrade pip
RUN pip install uwsgi
RUN pip install pygraphviz

RUN echo "10.240.5.72 acc.api.data.amsterdam.nl" >> /etc/hosts || echo "Could not write to /etc/hosts"
Expand All @@ -30,6 +34,8 @@ RUN chmod +x /app/wait-for.sh
RUN chmod +x /app/celery.sh
RUN chmod +x /app/deploy/docker-entrypoint.sh

# Set the GDAL_LIBRARY_PATH environment variable
ENV GDAL_LIBRARY_PATH /usr/lib/libgdal.so

ENTRYPOINT ["/app/deploy/docker-entrypoint.sh"]
CMD ["uwsgi", "--ini", "/app/deploy/config.ini"]
Loading

0 comments on commit 21b368c

Please sign in to comment.