Skip to content

Commit

Permalink
Merge pull request #183 from Tecnativa/devel
Browse files Browse the repository at this point in the history
Prepare release
  • Loading branch information
joao-p-marques authored Nov 26, 2020
2 parents 4c1c4b8 + 6315685 commit 3ca4c8a
Show file tree
Hide file tree
Showing 17 changed files with 876 additions and 431 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Generate cache key CACHE
run:
echo "::set-env name=CACHE::${{ secrets.CACHE_DATE }} ${{ runner.os }}
$(python -VV | sha256sum | cut -d' ' -f1) ${{ hashFiles('pyproject.toml') }}
${{ hashFiles('poetry.lock') }} ${{ hashFiles('.pre-commit-config.yaml') }}"
echo "CACHE=${{ secrets.CACHE_DATE }} ${{ runner.os }} $(python -VV |
sha256sum | cut -d' ' -f1) ${{ hashFiles('pyproject.toml') }} ${{
hashFiles('poetry.lock') }} ${{ hashFiles('.pre-commit-config.yaml') }}" >>
$GITHUB_ENV
- uses: actions/[email protected]
with:
path: |
Expand All @@ -65,7 +66,7 @@ jobs:
key: venv ${{ env.CACHE }}
- run: pip install poetry
- name: Patch $PATH
run: echo "::set-env name=PATH::$HOME/.local/bin:$PATH"
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- run: poetry install
# Precreate shared networks to avoid race conditions
- run: docker network create inverseproxy_shared
Expand All @@ -74,7 +75,13 @@ jobs:
- run: git config --global user.name CI
- run: git config --global user.email CI@GITHUB
# Run all tests, which includes linters
# Non concurrent first (in parallel)
- run: poetry run invoke test
env:
DOCKER_TEST: 1
SELECTED_ODOO_VERSIONS: ${{ matrix.odoo-version }}
# Concurrent tests (isolated)
- run: poetry run invoke test --sequential
env:
DOCKER_TEST: 1
SELECTED_ODOO_VERSIONS: ${{ matrix.odoo-version }}
9 changes: 4 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ repos:
rev: v2.7.2
hooks:
- id: pyupgrade
args:
- --keep-percent-format
- repo: https://github.com/timothycrosley/isort
rev: 5.5.1
hooks:
Expand All @@ -34,11 +36,8 @@ repos:
hooks:
- id: flake8
additional_dependencies: [flake8-bugbear==20.1.4]
# TODO Migrate to new prettier pre-commit repo after fixed:
# HACK https://github.com/prettier/pre-commit/pull/17
# HACK https://github.com/prettier/pre-commit/pull/18
- repo: https://github.com/prettier/prettier
rev: 2.1.2
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.1.2
hooks:
- id: prettier
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
11 changes: 6 additions & 5 deletions .pre-commit-config.yaml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,23 @@ repos:
rev: v2.7.2
hooks:
- id: pyupgrade
args:
- --keep-percent-format
- repo: https://github.com/timothycrosley/isort
rev: 5.5.1
hooks:
- id: isort
name: isort except __init__.py
args: [--settings, .]
exclude: /__init__\.py$
# TODO Migrate to new prettier pre-commit repo after fixed:
# HACK https://github.com/prettier/pre-commit/pull/17
# HACK https://github.com/prettier/pre-commit/pull/18
- repo: https://github.com/prettier/prettier
rev: 2.1.2
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.1.2
hooks:
- id: prettier
name: prettier + plugin-xml
additional_dependencies:
# HACK https://github.com/prettier/pre-commit/issues/16#issuecomment-713474520
- [email protected]
- "@prettier/[email protected]"
args:
- --plugin=@prettier/plugin-xml
Expand Down
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"recommendations": [
"actboy168.tasks",
"dbaeumer.vscode-eslint",
"dchanco.vsc-invoke",
"EditorConfig.editorconfig",
Expand Down
1 change: 0 additions & 1 deletion .vscode/settings.json.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
],
"python.linting.pylintEnabled": true,
"restructuredtext.confPath": "",
"search.followSymlinks": false,
"search.useIgnoreFiles": false,

// Language-specific configurations
Expand Down
6 changes: 5 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ else here: issues and pull requests.

## General Discussion

Follow the same instructions as for [issues](#issues).
Please make use of [Doodba discussions](https://github.com/Tecnativa/doodba/discussions)
to share knowledge, ideas or make questions.

There's one concrete
[channel for stuff specifically related to this template](https://github.com/Tecnativa/doodba/discussions?discussions_q=category%3A%22Doodba+-+The+template%22).

## Issues

Expand Down
10 changes: 8 additions & 2 deletions copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ _exclude:
- /poetry.lock
- /pyproject.toml
- /scripts
- /tasks_downstream.py
- /tests
- /vendor

Expand Down Expand Up @@ -380,7 +381,7 @@ smtp_relay_host:
smtp_relay_port:
type: int
default: 587
when: &has_smtp "{{ smtp_relay_host is string and smtp_relay_host != '' }}"
when: &has_smtp "{{ smtp_relay_host and true }}"
help: >-
Indicate the port to connect in the SMTP server you just defined.
Expand Down Expand Up @@ -445,6 +446,7 @@ backup_dst:
backup_email_from:
type: str
when: &backup_present "{{ backup_dst and true }}"
help: >-
The backup container will send email reports if the SMTP relay is properly
configured.
Expand All @@ -453,12 +455,14 @@ backup_email_from:
backup_email_to:
type: str
when: *backup_present
help: >-
Where to send those backup reports?
backup_deletion:
default: false
type: bool
when: *backup_present
help: >-
If you're using S3, you probably want to delete outdated backups using bucket
lifecycle rules. If you use other storage backend, then you probably want to enable
Expand All @@ -469,6 +473,7 @@ backup_deletion:
backup_tz:
type: str
default: UTC
when: *backup_present
help: >-
Set the timezone used by the backup cron for reports.
Expand All @@ -479,7 +484,7 @@ backup_aws_access_key_id:
secret: true
type: str
default: null
when: &backup_aws "{{ 's3:' in backup_dst }}"
when: &backup_aws "{{ 's3:' in backup_dst|string }}"
help: >-
If you're using AWS S3 to store backups, provide here your access key ID.
Expand All @@ -495,6 +500,7 @@ backup_passphrase:
secret: true
type: str
default: example-backup-passphrase
when: *backup_present
help: >-
⚠️ This passphrase is critical for security, so keep it safe. You will need it to
restore backups.
Expand Down
69 changes: 16 additions & 53 deletions devel.yaml.jinja
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{%- import "_macros.jinja" as macros -%}
{% set whitelisted_hosts = (
"cdnjs.cloudflare.com",
"fonts.googleapis.com",
"fonts.gstatic.com",
"www.google.com",
"www.googleapis.com",
"www.gravatar.com",
) -%}
version: "2.4"

services:
Expand Down Expand Up @@ -47,12 +55,10 @@ services:
- ./odoo/custom:/opt/odoo/custom:ro,z
- ./odoo/auto:/opt/odoo/auto:rw,z
depends_on:
- cdnjs_cloudflare_proxy
- db
- fonts_googleapis_proxy
- fonts_gstatic_proxy
- google_proxy
- gravatar_proxy
{% for host in whitelisted_hosts -%}
- proxy_{{ host|replace(".", "_") }}
{% endfor -%}
- smtp
- wdb
command:
Expand Down Expand Up @@ -106,61 +112,18 @@ services:
init: true

# Whitelist outgoing traffic for tests, reports, etc.
cdnjs_cloudflare_proxy:
{%- for host in whitelisted_hosts %}
proxy_{{ host|replace(".", "_") }}:
image: tecnativa/whitelist
networks:
default:
aliases:
- cdnjs.cloudflare.com
- {{ host }}
public:
environment:
TARGET: cdnjs.cloudflare.com
TARGET: {{ host }}
PRE_RESOLVE: 1

fonts_googleapis_proxy:
image: tecnativa/whitelist
networks:
default:
aliases:
- fonts.googleapis.com
public:
environment:
TARGET: fonts.googleapis.com
PRE_RESOLVE: 1

fonts_gstatic_proxy:
image: tecnativa/whitelist
networks:
default:
aliases:
- fonts.gstatic.com
public:
environment:
TARGET: fonts.gstatic.com
PRE_RESOLVE: 1

google_proxy:
image: tecnativa/whitelist
networks:
default:
aliases:
- www.google.com
public:
environment:
TARGET: www.google.com
PRE_RESOLVE: 1

gravatar_proxy:
image: tecnativa/whitelist
networks:
default:
aliases:
- www.gravatar.com
public:
environment:
TARGET: www.gravatar.com
PRE_RESOLVE: 1

{% endfor %}
networks:
default:
internal: true
Expand Down
36 changes: 36 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Maybe not so frequent, but interesting anyway. 🤷
- [Why do I get a "Connection Refused" error when trying to lauch the VSCode Chrome JS Debugger?](#why-do-i-get-a-connection-refused-error-when-trying-to-lauch-the-vscode-chrome-js-debugger)
- [Why can't Firefox load the page after I start a debugging session?](#why-cant-firefox-load-the-page-after-i-start-a-debugging-session)
- [Why won't my program stop on the specified breakpoints when using Firefox?](#why-wont-my-program-stop-on-the-specified-breakpoints-when-using-firefox)
- [When upgrading from an old template, prettier fails badly. How to update?](#when-upgrading-from-an-old-template-prettier-fails-badly-how-to-update)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->
<!-- prettier-ignore-end -->
Expand Down Expand Up @@ -540,3 +541,38 @@ correct URL. However, if you need to log in, you loose that URL. To avoid that,
sure you are not losing your cookies each time you reload a debugging session. (See
[Why don't I see my Firefox extensions while debugging?](#Why-don't-I-see-my-Firefox-extensions-while-debugging?)
for how to set up your Firefox debugging profile)

## When upgrading from an old template, prettier fails badly. How to update?

Whether it was prettier, npm, nodejs or whoever else, the fact is that
[recently there happened a prettiermageddon](https://github.com/prettier/prettier/issues/9459).

When you're updating from an older template to a newer, Copier will try to produce a
vanilla project with the old template before updating it, to be able to extract a smart
diff and apply the required changes to your subproject.

Since old versions of the template are broken due to this prettier problem, you cannot
update anymore. Well, here's the workaround:

1. Indicate to [nodeenv](http://ekalinin.github.io/nodeenv/) that your default nodejs
version is 14.14.0 by creating a file in `~/.nodeenvrc` with the following contents.
This will avoid the problem of prettier being unable to install:

```ini
[nodeenv]
node = 14.14.0
```

1. Update to latest template
[skipping `prettier` hook](https://pre-commit.com/#temporarily-disabling-hooks).
This will avoid the problem of prettier + plugin-xml being unable to execute, even
if properly installed:

```bash
env SKIP=prettier copier update
```

Once all your doodba subprojects are on template v2.5.0 or later, you won't need the
`~/.nodeenvrc` anymore (hopefully) and you can safely delete it, as node version is
pinned there and we install prettier from
[their new specific pre-commit repo](https://github.com/prettier/pre-commit).
2 changes: 1 addition & 1 deletion odoo/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ARG ODOO_VERSION
FROM tecnativa/doodba:${ODOO_VERSION}-onbuild
FROM ghcr.io/tecnativa/doodba:${ODOO_VERSION}-onbuild
16 changes: 12 additions & 4 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,22 @@ def lint(c, verbose=False):


@task(develop)
def test(c, verbose=False):
"""Test project."""
flags = ["-n", "auto", "--color=yes"]
def test(c, verbose=False, sequential=False):
"""Test project.
Add --sequential to run only sequential tests, with parallelization disabled.
"""
flags = ["--color=yes"]
if verbose:
flags.append("-vv")
if sequential:
flags.extend(["-m", "sequential"])
else:
flags.extend(["-n", "auto", "-m", '"not sequential"'])
flags = " ".join(flags)
cmd = f"poetry run pytest {flags} tests"
with c.cd(str(TEMPLATE_ROOT)):
c.run(f"poetry run pytest {flags} tests")
c.run(cmd)


@task(develop)
Expand Down
Loading

0 comments on commit 3ca4c8a

Please sign in to comment.