|
| 1 | +name: Generate analysis files |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + from_version: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + from_version_requirements: |
| 10 | + default: 'gevent==22.10.2 greenlet==2.0.2' |
| 11 | + type: string |
| 12 | + from_version_requirements_sed: |
| 13 | + default: '/^gevent\>/d; /^greenlet\>/d' |
| 14 | + type: string |
| 15 | + to_version: |
| 16 | + required: true |
| 17 | + type: string |
| 18 | + to_version_requirements: |
| 19 | + default: 'gevent==22.10.2 greenlet==2.0.2' |
| 20 | + type: string |
| 21 | + to_version_requirements_sed: |
| 22 | + default: '/^gevent\>/d; /^greenlet\>/d' |
| 23 | + type: string |
| 24 | + python_version: |
| 25 | + default: "3.10" |
| 26 | + type: string |
| 27 | + postgres_version: |
| 28 | + default: "14" |
| 29 | + type: string |
| 30 | + |
| 31 | +jobs: |
| 32 | + generate-analysis: |
| 33 | + name: Generate analysis ${{ inputs.to_version }} |
| 34 | + runs-on: ubuntu-latest |
| 35 | + env: |
| 36 | + PGHOST: "localhost" |
| 37 | + PGPASSWORD: "odoo" |
| 38 | + PGUSER: "odoo" |
| 39 | + FROM_VERSION: "${{ inputs.from_version }}" |
| 40 | + TO_VERSION: "${{ inputs.to_version }}" |
| 41 | + services: |
| 42 | + postgres: |
| 43 | + image: postgres:${{ inputs.postgres_version }} |
| 44 | + env: |
| 45 | + POSTGRES_USER: odoo |
| 46 | + POSTGRES_PASSWORD: odoo |
| 47 | + ports: |
| 48 | + - 5432:5432 |
| 49 | + steps: |
| 50 | + - name: Set up Python |
| 51 | + uses: actions/setup-python@v4 |
| 52 | + with: |
| 53 | + python-version: "${{ inputs.python_version }}" |
| 54 | + - name: Install required packages |
| 55 | + run: | |
| 56 | + sudo apt update |
| 57 | + sudo apt install \ |
| 58 | + expect \ |
| 59 | + expect-dev \ |
| 60 | + libevent-dev \ |
| 61 | + libldap2-dev \ |
| 62 | + libsasl2-dev \ |
| 63 | + libxml2-dev \ |
| 64 | + libxslt1-dev \ |
| 65 | + nodejs \ |
| 66 | + python3-lxml \ |
| 67 | + python3-passlib \ |
| 68 | + python3-psycopg2 \ |
| 69 | + python3-serial \ |
| 70 | + python3-simplejson \ |
| 71 | + python3-werkzeug \ |
| 72 | + python3-yaml \ |
| 73 | + unixodbc-dev |
| 74 | + - name: Checkout previous OpenUpgrade |
| 75 | + uses: actions/checkout@v4 |
| 76 | + with: |
| 77 | + ref: "${{ env.FROM_VERSION }}" |
| 78 | + path: openupgrade-${{ env.FROM_VERSION }} |
| 79 | + - name: Checkout OpenUpgrade from current branch |
| 80 | + if: github.event_name != 'schedule' && startsWith(github.ref_name, env.TO_VERSION) |
| 81 | + uses: actions/checkout@v4 |
| 82 | + with: |
| 83 | + path: openupgrade-${{ env.TO_VERSION }} |
| 84 | + - name: Checkout current OpenUpgrade |
| 85 | + if: github.event_name == 'schedule' || !startsWith(github.ref_name, env.TO_VERSION) |
| 86 | + uses: actions/checkout@v4 |
| 87 | + with: |
| 88 | + ref: "${{ env.TO_VERSION }}" |
| 89 | + path: openupgrade-${{ env.TO_VERSION }} |
| 90 | + - name: Install previous Odoo |
| 91 | + run: | |
| 92 | + wget -q -O- https://github.com/oca/ocb/archive/refs/heads/$FROM_VERSION.tar.gz | tar -xz |
| 93 | + wget -q -O- https://github.com/oca/server-tools/archive/refs/heads/$FROM_VERSION.tar.gz | tar -xz |
| 94 | + python -mvenv env-$FROM_VERSION |
| 95 | + . env-$FROM_VERSION/bin/activate |
| 96 | + pip install ${{ inputs.from_version_requirements }} |
| 97 | + sed -iE '${{ inputs.from_version_requirements_sed }}' OCB-$FROM_VERSION/requirements.txt |
| 98 | + pip install -r OCB-$FROM_VERSION/requirements.txt |
| 99 | + pip install ./OCB-$FROM_VERSION |
| 100 | + pip install -r server-tools-$FROM_VERSION/requirements.txt |
| 101 | + pip install -r openupgrade-$FROM_VERSION/requirements.txt |
| 102 | + # this is for l10n_eg_edi_eta which crashes without it |
| 103 | + pip install asn1crypto |
| 104 | + odoo -s -c odoo-$FROM_VERSION.cfg --addons-path server-tools-$FROM_VERSION,openupgrade-$FROM_VERSION --stop-after-init |
| 105 | + - name: Install current Odoo |
| 106 | + run: | |
| 107 | + wget -q -O- https://github.com/oca/ocb/archive/refs/heads/$TO_VERSION.tar.gz | tar -xz |
| 108 | + wget -q -O- https://github.com/oca/server-tools/archive/refs/heads/$TO_VERSION.tar.gz | tar -xz |
| 109 | + python -mvenv env-$TO_VERSION |
| 110 | + . env-$TO_VERSION/bin/activate |
| 111 | + pip install ${{ inputs.to_version_requirements }} |
| 112 | + sed -iE '${{ inputs.to_version_requirements_sed }}' OCB-$TO_VERSION/requirements.txt |
| 113 | + pip install -r OCB-$TO_VERSION/requirements.txt |
| 114 | + pip install ./OCB-$TO_VERSION |
| 115 | + pip install -r server-tools-$TO_VERSION/requirements.txt |
| 116 | + pip install -r openupgrade-$TO_VERSION/requirements.txt |
| 117 | + # this is for l10n_eg_edi_eta which crashes without it |
| 118 | + pip install asn1crypto |
| 119 | + odoo -s -c odoo-$TO_VERSION.cfg --addons-path server-tools-$TO_VERSION,openupgrade-$TO_VERSION --stop-after-init |
| 120 | + - name: Create previous Odoo database |
| 121 | + env: |
| 122 | + ODOO: env-${{ env.FROM_VERSION }}/bin/odoo -c odoo-${{ env.FROM_VERSION }}.cfg -d ${{ env.FROM_VERSION }} |
| 123 | + ODOO_SHELL: env-${{ env.FROM_VERSION }}/bin/odoo shell -c odoo-${{ env.FROM_VERSION }}.cfg -d ${{ env.FROM_VERSION }} |
| 124 | + run: | |
| 125 | + $ODOO --without-demo=all -i upgrade_analysis --stop-after-init |
| 126 | + $ODOO_SHELL <<EOF |
| 127 | + install_wizard = env['upgrade.install.wizard'].create({}) |
| 128 | + install_wizard.select_odoo_modules() |
| 129 | + install_wizard.install_modules() |
| 130 | + env.cr.commit() |
| 131 | + EOF |
| 132 | + $ODOO_SHELL <<EOF |
| 133 | + env['upgrade.generate.record.wizard'].create({}).generate() |
| 134 | + env.cr.commit() |
| 135 | + EOF |
| 136 | + - name: Create current Odoo database |
| 137 | + env: |
| 138 | + ODOO: env-${{ env.TO_VERSION }}/bin/odoo -c odoo-${{ env.TO_VERSION }}.cfg -d ${{ env.TO_VERSION }} |
| 139 | + ODOO_SHELL: env-${{ env.TO_VERSION }}/bin/odoo shell -c odoo-${{ env.TO_VERSION }}.cfg -d ${{ env.TO_VERSION }} |
| 140 | + run: | |
| 141 | + $ODOO --without-demo=all -i upgrade_analysis --stop-after-init |
| 142 | + $ODOO_SHELL <<EOF |
| 143 | + install_wizard = env['upgrade.install.wizard'].create({}) |
| 144 | + install_wizard.select_odoo_modules() |
| 145 | + install_wizard.install_modules() |
| 146 | + env.cr.commit() |
| 147 | + EOF |
| 148 | + $ODOO_SHELL <<EOF |
| 149 | + env['upgrade.generate.record.wizard'].create({}).generate() |
| 150 | + env.cr.commit() |
| 151 | + EOF |
| 152 | + - name: Delete all files to be generated from repository |
| 153 | + env: |
| 154 | + OPENUPGRADE_DIR: openupgrade-${{ env.TO_VERSION }} |
| 155 | + run: | |
| 156 | + for file in $OPENUPGRADE_DIR/openupgrade_scripts/scripts/*/*/{noupdate_changes.xml,upgrade_analysis.txt}; do |
| 157 | + if [ ! -f $file ]; then |
| 158 | + continue |
| 159 | + fi |
| 160 | + git -C $OPENUPGRADE_DIR rm ${file#$OPENUPGRADE_DIR/} |
| 161 | + done |
| 162 | + - name: Create analysis |
| 163 | + env: |
| 164 | + FROM_ODOO: env-${{ env.FROM_VERSION }}/bin/odoo -c odoo-${{ env.FROM_VERSION }}.cfg -d ${{ env.FROM_VERSION }} |
| 165 | + TO_ODOO_SHELL: env-${{ env.TO_VERSION }}/bin/odoo shell -c odoo-${{ env.TO_VERSION }}.cfg -d ${{ env.TO_VERSION }} |
| 166 | + run: | |
| 167 | + $FROM_ODOO --max-cron-threads=0 & |
| 168 | + ODOO_PID=$! |
| 169 | + $TO_ODOO_SHELL <<EOF |
| 170 | + config = env['upgrade.comparison.config'].create({ |
| 171 | + 'database': '${{ env.FROM_VERSION }}', |
| 172 | + }) |
| 173 | + analysis_wizard = env['upgrade.analysis'].create({ |
| 174 | + 'config_id': config.id, |
| 175 | + }) |
| 176 | + analysis_wizard._compute_upgrade_path() |
| 177 | + analysis_wizard.analyze() |
| 178 | + env.cr.commit() |
| 179 | + print(analysis_wizard.log) |
| 180 | + EOF |
| 181 | + kill -s KILL $ODOO_PID |
| 182 | + - name: Determine changed addons |
| 183 | + id: generate_body |
| 184 | + env: |
| 185 | + OPENUPGRADE_DIR: openupgrade-${{ env.TO_VERSION }} |
| 186 | + PR_BODY: pr_body.txt |
| 187 | + run: | |
| 188 | + git -C $OPENUPGRADE_DIR add . |
| 189 | +
|
| 190 | + echo "Analysis or noupdate changes for modules marked as done: |
| 191 | +
|
| 192 | + " > "$PR_BODY" |
| 193 | +
|
| 194 | + for module in $( |
| 195 | + git -C $OPENUPGRADE_DIR status --short | awk '{print $2}' | awk -F/ '{print $3}' | sort -u |
| 196 | + ); do |
| 197 | + if grep -qE "\<$module\>.*\<((Done)|(No))" $OPENUPGRADE_DIR/docsource/modules*; then |
| 198 | + echo Done module $module was updated |
| 199 | + echo "- $module" >> $PR_BODY |
| 200 | + else |
| 201 | + echo $module is not done yet |
| 202 | + fi |
| 203 | + done |
| 204 | +
|
| 205 | + if ! grep -q - $PR_BODY; then |
| 206 | + echo None >> $PR_BODY |
| 207 | + fi |
| 208 | +
|
| 209 | + echo "body-file=$PR_BODY" >> "$GITHUB_OUTPUT" |
| 210 | + - name: Get number of milestone |
| 211 | + id: get_milestone |
| 212 | + run: | |
| 213 | + echo "number=$( |
| 214 | + wget -qO- https://api.github.com/repos/${{ github.repository }}/milestones|jq '.[] | select(.title=="${{ env.TO_VERSION }}") .number' |
| 215 | + )" >> "$GITHUB_OUTPUT" |
| 216 | + - name: Create PR |
| 217 | + uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e #v7 |
| 218 | + with: |
| 219 | + base: "${{ env.TO_VERSION }}" |
| 220 | + body-path: "${{ steps.generate_body.outputs.body-file }}" |
| 221 | + branch: "${{ env.TO_VERSION }}-update-analysis-bot" |
| 222 | + commit-message: "[IMP] Update analysis files" |
| 223 | + delete-branch: true |
| 224 | + milestone: "${{ steps.get_milestone.outputs.number }}" |
| 225 | + path: "openupgrade-${{ env.TO_VERSION }}" |
| 226 | + title: "[${{ env.TO_VERSION }}][IMP] Update analysis files" |
0 commit comments