Skip to content

Commit

Permalink
add devcontainer (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasgerstmayr authored Mar 10, 2024
1 parent 796f680 commit e9f0ba9
Show file tree
Hide file tree
Showing 18 changed files with 7,470 additions and 5,502 deletions.
7 changes: 7 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM ubuntu:23.10
RUN apt-get update && apt-get install -y zsh python3-setuptools pipenv npm

# chromium dependencies
RUN apt-get install -y fonts-noto-color-emoji libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libxkbcommon0 libxdamage1 libpango-1.0-0 libcairo2 libasound2

USER ubuntu
12 changes: 12 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"build": {
"dockerfile": "Dockerfile"
},
"customizations": {
"vscode": {
"extensions": ["editorconfig.editorconfig", "ms-python.python", "Lencerf.beancount"]
}
},
"postCreateCommand": "make deps",
"forwardPorts": [5000]
}
25 changes: 4 additions & 21 deletions .github/workflows/continuous-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install dependencies
run: |
sudo pip3 install black
sudo npm install -g prettier
- name: Build frontend
run: make build

- name: Install fava-portfolio-returns
run: pip3 install .

- name: Start Fava
run: cd example; fava example.beancount &

- name: Run HTML tests
run: cd frontend; npm run test -- -t HTML

- name: Run formatter
run: |
make format
git diff --exit-code
- name: Build and run dev container task
uses: devcontainers/[email protected]
with:
runCmd: make ci
40 changes: 26 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
frontend/node_modules: frontend/package-lock.json
cd frontend; npm install
touch -m frontend/node_modules
deps-js:
cd frontend; npm install && npx puppeteer browsers install chrome

.PHONY: build
build: frontend/node_modules
deps-py:
cd example; pipenv install -d

deps: deps-js deps-py

build-js:
cd frontend; npm run build

.PHONY: watch
watch: frontend/node_modules
watch-js:
cd frontend; npm run watch

.PHONY: test
test: frontend/node_modules
cd frontend; npm run test
test-js:
cd frontend; LANG=en npm run test

test-js-update:
cd frontend; LANG=en npm run test -- -u

run:
cd example; pipenv run fava example.beancount

.PHONY: format
format:
prettier -w frontend src/fava_portfolio_returns/templates/*.css
black src/fava_portfolio_returns/__init__.py
find example -name '*.beancount' -exec bean-format -c 59 -o "{}" "{}" \;
cd frontend; npx prettier -w . ../src/fava_portfolio_returns/templates/*.css
cd example; pipenv run black ../src/fava_portfolio_returns/__init__.py
cd example; find . -name '*.beancount' -exec pipenv run bean-format -c 59 -o "{}" "{}" \;

ci:
make run &
make test-js
make format
git diff --exit-code
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Fava Portfolio Returns
[![Continuous Integration](https://github.com/andreasgerstmayr/fava-portfolio-returns/actions/workflows/continuous-integration.yaml/badge.svg)](https://github.com/andreasgerstmayr/fava-portfolio-returns/actions/workflows/continuous-integration.yaml)
[![Open in Dev Containers](https://img.shields.io/static/v1?label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/andreasgerstmayr/fava-portfolio-return)

fava-portfolio-returns shows portfolio returns in the [Fava](https://github.com/beancount/fava) web interface. It leverages [beangrow](https://github.com/beancount/beangrow) to calculate the portfolio returns.

[![Overview](frontend/tests/e2e/__image_snapshots__/report_overview.png)](frontend/tests/e2e/__image_snapshots__/report_overview.png)
Expand Down
1 change: 1 addition & 0 deletions example/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ name = "pypi"
fava-portfolio-returns = {editable = true, path = "./.."}

[dev-packages]
black = "*"

[requires]
python_version = "3.11"
1,540 changes: 854 additions & 686 deletions example/Pipfile.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions frontend/jest-puppeteer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ module.exports = {
height: 1000,
},
headless: "new",
// chrome sandbox does not work inside container
args: ["--no-sandbox"],
},
};
Loading

0 comments on commit e9f0ba9

Please sign in to comment.