Skip to content

Commit

Permalink
[ADD] custom coverage conf
Browse files Browse the repository at this point in the history
  • Loading branch information
zamberjo committed Nov 6, 2023
1 parent 411de16 commit 4b03855
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 24 deletions.
15 changes: 15 additions & 0 deletions copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,21 @@ github_enable_codecov:
help: GitHub action runs codecov/codecov-action?
when: *ci_is_github

github_enable_customtests:
type: bool
default: no
help: Custom tests? as performance, stress tests... see nubearentcar
when: *ci_is_github

github_customtests_extra_env:
type: yaml
default: {}
help: |
Any extra environment variables to inject into the custom tests
Example: {"KEY": "VALUE"}
when: *github_enable_customtests

github_enable_makepot:
type: bool
default: yes
Expand Down
36 changes: 15 additions & 21 deletions src/.github/workflows/au_exportpot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,36 @@

set -x

# "[INFO] Installing click-odoo-contrib..."
pip install click-odoo-contrib;

# "[INFO] Init test database..."
oca_wait_for_postgres
ADDONS=$(manifestoo --select-addons-dir ${ADDONS_DIR} list-depends --separator=,)
if [ -n "${ADDONS}" ]; then
ADDONS="$ADDONS,${1}"
else
ADDONS=="${1}"
if [[ "${MAKECOVERAGE}" = "false" ]];then
pip install click-odoo-contrib;
oca_wait_for_postgres
ADDONS=$(manifestoo --select-addons-dir ${ADDONS_DIR} list-depends --separator=,)
if [ -n "${ADDONS}" ]; then
ADDONS="$ADDONS,${1}"
else
ADDONS=="${1}"
fi
unbuffer coverage run --include "${ADDONS_DIR}/*" --branch \
$(which odoo || which openerp-server) \
-d ${PGDATABASE} \
-i ${ADDONS:-base} \
--max-cron-threads=0 \
--stop-after-init;
fi

unbuffer coverage run --include "${ADDONS_DIR}/*" --branch \
$(which odoo || which openerp-server) \
-d ${PGDATABASE} \
-i ${ADDONS:-base} \
--max-cron-threads=0 \
--stop-after-init;

# "[INFO] Export POT for module ${1}..."
click-odoo-makepot \
--modules ${1} \
--addons-dir ${ADDONS_DIR} \
-d ${PGDATABASE} \
--msgmerge-if-new-pot \
--log-level=info;

# "[INFO] Reset module/repo structure..."
mv ./${1}/* ./ && rmdir ./${1}

# "[INFO] Config git..."
git config --global --add safe.directory $(pwd)
git config user.name aurestic-ci
git config user.email aurestic-ci@aurestic.es

# "[INFO] Commit && push..."
rm test-requirements.txt;
git status;
git add i18n/${1}.pot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ jobs:
name: test with OCB
{%- endif %}
makepot: "{{ github_enable_makepot | bool | lower }}"
makecoverage: "{{ github_enable_codecov | bool | lower }}"
customtests: "{{ github_enable_customtests | bool | lower }}"
{%- endfor %}
{%- if odoo_test_flavor in ["Odoo", "Both"] %}
- container: {{ IMAGES["odoo"][odoo_version] }}
Expand All @@ -81,6 +83,8 @@ jobs:
name: test with OCB
{%- endif %}
makepot: "{{ github_enable_makepot | bool | lower }}"
makecoverage: "{{ github_enable_codecov | bool | lower }}"
customtests: "{{ github_enable_customtests | bool | lower }}"
{%- else %}
{#- If all modules can get along, we test and generate .pot all at once #}
include:
Expand All @@ -93,6 +97,8 @@ jobs:
name: test with OCB
{%- endif %}
makepot: "{{ github_enable_makepot | bool | lower }}"
makecoverage: "{{ github_enable_codecov | bool | lower }}"
customtests: "{{ github_enable_customtests | bool | lower }}"
{%- endif %}
services:
postgres:
Expand Down Expand Up @@ -148,17 +154,44 @@ jobs:
{%- endif %}
- name: Initialize test db
run: oca_init_test_database
if: {{ "${{" }} github.event_name != 'push' {{ "}}" }}
if: {{ "${{" }} github.event_name != 'push' || matrix.makecoverage == 'true' {{ "}}" }}
- name: Run tests
run: oca_run_tests
if: {{ "${{" }} github.event_name != 'push' {{ "}}" }}
if: {{ "${{" }} github.event_name != 'push' || matrix.makecoverage == 'true' {{ "}}" }}
{%- if github_enable_customtests %}
- name: Run custom project tests
id: custom_tests
run: ./.github/workflows/au_run_tests.sh {{ "${{" }} github.event.repository.name {{ "}}" }} {{ "${{" }} github.event_name {{ "}}" }}
env:
GIT_PUSH_TOKEN: {{ "${{" }} secrets.GIT_PUSH_TOKEN {{ "}}" }}
{%- for key, value in github_customtests_extra_env.items() %}
{{ key }}: {{ value|to_json }}
{%- endfor %}
if: {{ "${{" }} matrix.customtests == 'true' && github.repository_owner == 'aurestic' {{ "}}" }}
{%- endif %}
{%- if github_enable_codecov %}
- uses: codecov/codecov-action@v1
- name: Exporting coverage report
run: coverage xml -o coverage.xml
- name: Undo coverage.xml structure directories
run: sed -i "s,{{ "${{" }} github.event.repository.name {{ "}}" }}/,,g" coverage.xml
{%- endif %}
{% raw -%}
- name: Update .pot files
run: ./.github/workflows/au_exportpot.sh ${{ github.event.repository.name }} https://x-access-token:${{ secrets.GIT_PUSH_TOKEN }}@github.com/${{ github.repository }}
env:
GIT_PUSH_TOKEN: ${{ secrets.GIT_PUSH_TOKEN }}
MAKECOVERAGE: ${{ matrix.makecoverage == 'true' }}
{%- endraw %}
if: {{ "${{" }} matrix.makepot == 'true' && github.event_name == 'push' && github.repository_owner == '{{ org_slug }}' {{ "}}" }}
{%- if github_enable_codecov %}
- name: Moving all on new folder
run: mv ./{{ "${{" }} github.event.repository.name {{ "}}" }}/* ./ &&
rmdir ./{{ "${{" }} github.event.repository.name {{ "}}" }} &&
rm test-requirements.txt
if: {{ "${{" }} matrix.makepot != 'true' || github.event_name != 'push' && github.repository_owner == 'aurestic' {{ "}}" }}
- uses: codecov/codecov-action@v3
with:
token: {{ "${{" }} secrets.CODECOV_TOKEN {{ "}}" }}
files: ./coverage.xml
{# verbose: true #}
{%- endif %}

0 comments on commit 4b03855

Please sign in to comment.