Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
WIP: restructuring files for mono repo
Browse files Browse the repository at this point in the history
- refactor dependabot
- refactor test workflow
- refactor release-npm.yml
- refactor release-iamge.yml
- move .gitignore
- refactor .editorconfig
- move LICENSE
- refactor CODEOWNERS
- refactor docker-compose
- move Makefile
- WIP: husky
- refactor CONTRIBUTING
- refactor README
  • Loading branch information
trowik committed Mar 15, 2024
1 parent 22c5ba2 commit c795ef8
Show file tree
Hide file tree
Showing 28 changed files with 170 additions and 896 deletions.
3 changes: 3 additions & 0 deletions frontend/.editorconfig → .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ insert_final_newline = false

[*.{diff,md}]
trim_trailing_whitespace = false

[*.py]
indent_size = 4
38 changes: 38 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: "weekly"
day: "friday"
time: "12:00"
timezone: "Europe/Zurich"
- package-ecosystem: npm
directory: "/frontend"
schedule:
interval: "weekly"
day: "friday"
time: "12:00"
timezone: "Europe/Zurich"
open-pull-requests-limit: 10
versioning-strategy: increase
- package-ecosystem: pip
directory: "/backend"
schedule:
interval: weekly
day: friday
time: "12:00"
timezone: "Europe/Zurich"
commit-message:
prefix: chore
include: scope
- package-ecosystem: docker
directory: "/"
schedule:
interval: weekly
day: friday
time: "12:00"
timezone: "Europe/Zurich"
commit-message:
prefix: chore
include: scope
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release ghcr image
name: Release ghcr images

on:
release:
Expand All @@ -7,6 +7,9 @@ on:
jobs:
container:
runs-on: ubuntu-latest
strategy:
matrix:
target: [frontend, backend]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -15,11 +18,11 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/adfinis/timed-frontend
images: ghcr.io/adfinis/timed-${{ matrix.target }}
flavor: |
latest=auto
labels: |
org.opencontainers.image.title=${{ github.event.repository.name }}
org.opencontainers.image.title=${{ github.event.repository.name }}-${{ matrix.target }}
org.opencontainers.image.description=${{ github.event.repository.description }}
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
Expand All @@ -38,7 +41,7 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
file: ./${{ matrix.target }}/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Release npm package

on: workflow_dispatch

env:
frontend-dir: ./frontend

jobs:
release:
name: Release
Expand All @@ -24,9 +27,11 @@ jobs:

- name: Install dependencies
run: pnpm install
working-directory: ${{ env.frontend-dir }}

- name: Release on NPM
run: pnpm semantic-release
working-directory: ${{ env.frontend-dir }}
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
34 changes: 31 additions & 3 deletions frontend/.github/workflows/test.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ on:

env:
NODE_VERSION: 18
frontend-dir: ./frontend
backend-dir: ./backend

jobs:
lint:
lint-frontend:
name: Lint
runs-on: [ubuntu-latest]
timeout-minutes: 5
Expand All @@ -39,13 +41,15 @@ jobs:

- name: Install dependencies
run: pnpm install --no-frozen-lockfile
working-directory: ${{ env.frontend-dir }}

- name: Lint ${{ matrix.target }}
run: pnpm lint:${{ matrix.target }}
working-directory: ${{ env.frontend-dir }}

test:
test-frontend:
name: Tests
needs: [lint]
needs: [lint-frontend]
runs-on: [ubuntu-latest]
timeout-minutes: 10

Expand All @@ -64,13 +68,37 @@ jobs:

- name: Install dependencies
run: pnpm install --no-frozen-lockfile
working-directory: ${{ env.frontend-dir }}

- name: Run tests
run: pnpm test
working-directory: ${{ env.frontend-dir }}
env:
COVERAGE: true

- name: upload coverage report to codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage/lcov.info

test-backend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v3
with:
path: .venv
key: poetry-${{ hashFiles('poetry.lock')}}
restore-keys: |
peotry-
- name: Build the project
run: |
echo "ENV=dev" > .env
docker-compose up -d --build backend
- name: Lint the code
run: |
docker-compose exec -T backend black --check .
docker-compose exec -T backend flake8
docker-compose exec -T backend python manage.py makemigrations --check --dry-run --no-input
- name: Run pytest
run: docker-compose exec -T backend pytest --no-cov-on-fail --cov --create-db -vv
14 changes: 12 additions & 2 deletions backend/.gitignore → .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.


# VSCode
.vscode/

# PyCharm
.idea/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -73,5 +82,6 @@ target/
# pytest
.pytest_cache

# PyCharm
.idea
# dependencies
/node_modules
/bower_components
3 changes: 3 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Code owners for the Timed backend.
* @adfinis/dev-backend
* @adfinis/dev-frontend
18 changes: 9 additions & 9 deletions backend/CONTRIBUTING.md → CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Contributing

Contributions to Timed backend are very welcome! Best have a look at the open [issues](https://github.com/adfinis/timed-backend)
and open a [GitHub pull request](https://github.com/adfinis/timed-backend/compare). See instructions below how to setup development
Contributions to Timed are very welcome! Best have a look at the open [issues](https://github.com/adfinis/timed)
and open a [GitHub pull request](https://github.com/adfinis/timed/compare). See instructions below how to setup development
environment. Before writing any code, best discuss your proposed change in a GitHub issue to see if the proposed change makes sense for the project.

## Setup development environment

### Clone

To work on Timed backend you first need to clone
To work on Timed you first need to clone

```bash
git clone https://github.com/adfinis/timed-backend.git
cd timed-backend
git clone https://github.com/adfinis/timed.git
cd timed
```

### Open Shell
Expand All @@ -32,13 +32,13 @@ etc.

```bash
# linting
flake8
poetry run flake8
# format code
black .
poetry run black .
# running tests
pytest
poetry run pytest
# create migrations
python manage.py makemigrations
poetry run python manage.py makemigrations
```

Writing of code can still happen outside the docker container of course.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
36 changes: 35 additions & 1 deletion backend/README.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,17 @@ DJANGO_OIDC_USERNAME_CLAIM=preferred_username
```

The test data includes 3 users admin, fritzm and alexs with you can log into [http://timed.local](http://timed.local)
You can initialize the test data using the following command:

```bash
make loaddata
```

The username and password are identical.

To access the Django admin interface you will have to change the admin password in Django directly:

```console
```bash
$ make bash
root@0a036a10f3c4:/app# poetry run python manage.py changepassword admin
Changing password for user 'admin'
Expand All @@ -68,6 +73,29 @@ Password changed successfully for user 'admin'

Then you'll be able to login in the Django admin interface [http://timed.local/admin/](http://timed.local/admin/).

## Work locally with Ember

```bash
cd frontend
pnpm i
```

## Running / Development

```bash
ember server
```
- Visit your app at [http://localhost:4200](http://localhost:4200).

If you have a running [backend](https://github.com/adfinis/timed-backend) you need to run

```bash
ember server --proxy=http://localhost:8000
```
or
```bash
pnpm start
```

### Adding a user

Expand All @@ -78,6 +106,12 @@ You should see that new user in the `Employment -> Users`.
Click on the user and scroll down to the `Employments` section to set a `Location`.
Save the user and you should now see the _Timed_ interface correctly under that account.


### Sending emails
In development mode, the apllication is configured to send all email to a Mailhog instance running in the same docker-compose setup. No emails will be sent out from the development environment, unless you specify something else.

You can access the Mailhog interface at [http://timed.local/mailhog/](http://timed.local/mailhog/). All emails sent from the application will be visible there.

## Configuration

Following options can be set as environment variables to configure Timed backend in documented [format](https://github.com/joke2k/django-environ#supported-types)
Expand Down
17 changes: 0 additions & 17 deletions backend/.editorconfig

This file was deleted.

22 changes: 0 additions & 22 deletions backend/.github/dependabot.yml

This file was deleted.

51 changes: 0 additions & 51 deletions backend/.github/workflows/release.yaml

This file was deleted.

Loading

0 comments on commit c795ef8

Please sign in to comment.