Skip to content

✨ Afegir coordenades al CUPS #2449

✨ Afegir coordenades al CUPS

✨ Afegir coordenades al CUPS #2449

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: SOM_ERP
on:
pull_request:
branches: [ main ]
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
env:
POSTGRES_USER: erp
POSTGRES_PASSWORD: erp
jobs:
get-pr-modified-files:
name: Get PR modified files
runs-on: ubuntu-latest
outputs:
module_list: ${{ steps.output_modules.outputs.stdout }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- uses: ruslandulina/compare-basehead-commits@v1
id: output_files
with:
# Format of the steps output context.
# Can be 'space-delimited', 'csv', or 'json'.
# Default: 'space-delimited'
format: 'json'
- uses: jannekem/run-python-script-action@v1
id: output_modules
with:
script: |
import os
def detect_module(path):
"""Detect if a path is part of a openerp module or not
:param path: to examine
:return: None if is not a module or the module name
"""
stack = path.split(os.path.sep)
if not stack[0]:
stack[0] = os.path.sep
stack = [x for x in stack if x]
while stack:
path = os.path.join(*stack)
module = stack.pop()
if not os.path.isdir(path):
continue
files = os.listdir(path)
if '__terp__.py' in files:
return module
return None
modules_to_test = []
for path in ${{ steps.output_files.outputs.all }}:
module = detect_module(path)
if module and module not in modules_to_test:
modules_to_test.append(module)
if len(modules_to_test) > 0:
output = modules_to_test[0]
for module in modules_to_test[1:]:
output += ' -m {}'.format(module)
print(output)
set-erp-branch:
name: Set ERP Branch
runs-on: ubuntu-latest
outputs:
erp_branch: ${{ steps.set_erp_branch.outputs.erpbranch }}
steps:
- name: Set ERP Branch
id: set_erp_branch
env:
PR_LABEL_LIST: ${{ toJson(github.event.pull_request.labels.*.name) }}
run: |
json_tags='${{ env.PR_LABEL_LIST }}'
array_tags=$(echo "$json_tags" | jq -r '.[]')
branch="rolling_erp01" # default branch
for tag in $array_tags; do
if [[ $tag == GHA_branch_* ]]; then
branch=${tag#GHA_branch_}
break
fi
done
echo "Using ERP branch $branch"
echo "erpbranch=$branch" >> $GITHUB_OUTPUT
erp-tests-module:
name: Run test PR
if: ${{needs.get-pr-modified-files.outputs.module_list}}
uses: ./.github/workflows/reusable_workflow.yml
needs: [get-pr-modified-files, set-erp-branch]
with:
module: ${{needs.get-pr-modified-files.outputs.module_list}}
erpbranch: ${{needs.set-erp-branch.outputs.erp_branch}}
secrets: inherit