Skip to content

Commit

Permalink
Integrate webpack and jinja
Browse files Browse the repository at this point in the history
  • Loading branch information
berrydenhartog committed Aug 26, 2024
1 parent 3bbfb64 commit 2abbd09
Showing 43 changed files with 2,613 additions and 3,729 deletions.
4 changes: 3 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -29,7 +29,9 @@
"ms-vsliveshare.vsliveshare",
"wholroyd.jinja",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
"esbenp.prettier-vscode",
"stylelint.vscode-stylelint",
"pranaygp.vscode-css-peek"
],
"settings": {
"editor.formatOnPaste": false,
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -7,3 +7,4 @@ pyproject.toml
.github/workflows/*
.devcontainer/devcontainer.json
.pre-commit-config.yaml
package.json
62 changes: 56 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -36,8 +36,15 @@ jobs:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"

- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: "npm"

- name: Install dependencies
run: poetry install
run: |
poetry install
npm install
- name: run ruff
run: poetry run ruff check --output-format=github
@@ -48,6 +55,12 @@ jobs:
- name: Run pyright
run: poetry run pyright

- name: Run eslint
run: npm run lint

- name: Run prettier
run: npm run prettier:check

security:
runs-on: ubuntu-latest
steps:
@@ -83,6 +96,8 @@ jobs:
- run: docker compose build
- run: docker compose down -v --remove-orphans
- run: docker compose up -d
- name: test frontend
run: docker compose run amt-test npm run test
- name: test app
run: docker compose run amt-test poetry run pytest -m 'not slow' --db postgresql
- name: db downgrade test
@@ -91,7 +106,23 @@ jobs:
run: docker compose exec -T amt alembic upgrade head
- run: docker compose down -v --remove-orphans

test-local:
test-local-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: "npm"

- name: Install dependencies
run: npm install

- name: Run tests
run: npm run test

test-local-backend:
runs-on: ubuntu-latest
strategy:
matrix:
@@ -111,8 +142,15 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: "poetry"

- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: "npm"

- name: Install dependencies
run: poetry install
run: |
poetry install
npm install
- name: Install Playwright browsers
run: poetry run playwright install --with-deps
@@ -123,6 +161,10 @@ jobs:
poetry run alembic downgrade -1
poetry run alembic upgrade head
- name: Generate required files
run: |
npm run build
- name: Run pytest
run: TZ=UTC poetry run coverage run -m pytest

@@ -161,7 +203,7 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

build:
needs: [test-local, test-compose]
needs: [test-local-frontend, test-local-backend, test-compose]
if: ${{ !github.event.act }}
runs-on: ubuntu-latest
permissions:
@@ -313,8 +355,16 @@ jobs:

notifyMattermost:
runs-on: ubuntu-latest
eeds: [lint, security, test-local, test-compose, build]
if: ${{ always() && contains(needs.*.result, 'failure') && !github.event.act}}
needs:
[
lint,
security,
test-local-backend,
test-local-frontend,
test-compose,
build,
]
if: ${{ always() && contains(needs.*.result, 'failure') }}
steps:
- uses: mattermost/action-mattermost-notify@master
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -48,3 +48,6 @@ node_modules/

# ignore tsc generated files
amt/site/static/js/*

# ignore webpack build files
amt/site/templates/layouts/base.html.j2
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
npx lint-staged
npm run typecheck
npm run stylecheck
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
()v22.6.0
v20.16.0
12 changes: 12 additions & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "stylelint-config-standard",
"rules": {
"declaration-block-no-redundant-longhand-properties": null
},
"ignoreFiles": [
"amt/site/static/css/*cols.css",
"amt/site/static/css/col.css",
"amt/site/static/css/html5reset.css",
"htmlcov/*.css"
]
}
4 changes: 3 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -13,6 +13,8 @@
"ms-vsliveshare.vsliveshare",
"wholroyd.jinja",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
"esbenp.prettier-vscode",
"stylelint.vscode-stylelint",
"pranaygp.vscode-css-peek"
]
}
30 changes: 28 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@
},
{
"label": "Ruff format",
"detail": "format code.",
"detail": "format code ruff.",
"type": "shell",
"command": "poetry run ruff format",
"group": "test",
@@ -37,6 +37,18 @@
},
"problemMatcher": []
},
{
"label": "prettier",
"detail": "format code prettier.",
"type": "shell",
"command": "npm run prettier",
"group": "test",
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Code Coverage",
"detail": "Generate code coverage report.",
@@ -51,7 +63,7 @@
},
{
"label": "PyTest",
"detail": "test all code",
"detail": "test all backend code",
"type": "shell",
"command": "poetry run coverage run -m pytest",
"group": {
@@ -63,6 +75,20 @@
"panel": "new"
},
"problemMatcher": []
},
{
"label": "npm test",
"detail": "test all frontend code",
"type": "shell",
"command": "npm run test",
"group": {
"kind": "test"
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
}
]
}
65 changes: 45 additions & 20 deletions BUILD.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,69 @@
# Buiding AMT

Before you can build AMT you first need to clone the git repository:

```
git clone https://github.com/MinBZK/amt.git
cd amt/
```

There are several ways to build and run AMT.

1. Poetry
1. Poetry & NPM
2. Container

## Building AMT with Poetry
## Building with Poetry & NPM

AMT uses 2 build systems within its project. One for the frontend (NPM) and one for the backend (Poetry).

Poetry is a Python package and dependency manager. Before you can install Poetry you first need to install Python. Please follow [these](https://github.com/pyenv/pyenv?amt=readme-ov-file#installation) instructions.

Once you have Python available you can install Poetry. See [here](https://python-poetry.org/docs/#installation).

Once you have Poetry and Python installed you can start installing the dependencies with the following shell command.
NPM (Node package manager) is a node package and dependency manager. Before you can use NPM we recommend you install NVM (node version manager). Please follow[these](https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-and-updating) instructions.

once NVM is install you can execute the following commands to install node and NPM

```bash
nvm install
nvm use
```

Note that the .nvmrc is used to determine the version that is being installed for this project.

Once you have Poetry and NPM installed you can start installing the dependencies with the following shell commands.

```shell
npm install
poetry install
```

When poetry is done installing all dependencies you can start using the tool.
When poetry and npm are done installing all dependencies you can start using the tool. you need to start 2 processes

```shell
npm start
```

```shell
poetry run python -m uvicorn amt.server:app --log-level warning
```

## Building AMT with Containers

Containers allows to package software, make it portable, and isolated. Before you can run a container you first need a container runtime. There are several available, but al lot of users use [docker desktop](https://www.docker.com/products/docker-desktop/).

After installing a Docker runtime like Docker Desktop you can start building the applications with this command:

```shell
docker compose build
```

To run the application you use this command:

```shell
docker compose up
```

### Suggested development ENVIRONMENT settings

To use a development environment during local development, you can use the following environment options.
@@ -49,22 +90,6 @@ to upgrade to the latest version of the database schema use
alembic upgrade head
```

## Building AMT with Containers

Containers allows to package software, make it portable, and isolated. Before you can run a container you first need a container runtime. There are several available, but al lot of users use [docker desktop](https://www.docker.com/products/docker-desktop/).

After installing a Docker runtime like Docker Desktop you can start building the applications with this command:

```shell
docker compose build
```

To run the application you use this command:

```shell
docker compose up
```

## Language support

We use babel for translations and a custom yaml for dynamic translations. Babel does not support Frysian, so we added a custom piece of code to support this. To generate, update or compile the language files, use the script in ./script/translate.
Loading

0 comments on commit 2abbd09

Please sign in to comment.