Manual trigger #24
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Manual trigger | |
# yamllint disable-line rule:truthy | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
type: choice | |
options: | |
- '7.0' | |
- '7.1' | |
- '7.2' | |
- '8.0' | |
- 'custom' | |
default: '8.0' | |
description: 'Version of the metapackage' | |
scenario: | |
type: choice | |
options: | |
- 'full' | |
- 'slim' | |
default: 'slim' | |
description: 'Scenario' | |
limit: | |
type: choice | |
options: | |
- 'no' | |
- 'PHP8.0/MySQL5.7' | |
- 'PHP8.0/MySQL8.0' | |
- 'PHP8.1/MySQL5.7' | |
- 'PHP8.1/MySQL8.0' | |
- 'PHP8.2/MySQL5.7' | |
- 'PHP8.2/MySQL8.0' | |
- 'PHP8.3/MySQL5.7' | |
- 'PHP8.3/MySQL8.0' | |
default: 'PHP8.1/MySQL5.7' | |
description: 'Limit to one PHP/MySQL combination' | |
custom_testplan: | |
type: string | |
required: true | |
description: 'Custom testplan' | |
default: '~/defaults/php8.2_mysql5.7_only.yaml,~/metapackage-8.0-full.yaml' | |
runs_on: | |
type: string | |
description: 'JSON string/array describing the runner' | |
required: true | |
default: '["ubuntu-latest"]' | |
use_dev_version: | |
type: choice | |
options: ['no', 'v0'] | |
description: 'Use the dev version of github actions' | |
default: 'no' | |
jobs: | |
build_testplan: | |
runs-on: ${{ fromJson(inputs.runs_on) }} | |
outputs: | |
testplan: '${{ steps.build.outputs.testplan }}' | |
steps: | |
- name: 'Build matrix' | |
id: build | |
run: | | |
# Build matrix | |
# shellcheck disable=SC2088 | |
case "${{ inputs.limit }}" in | |
"no") LIMIT='';; | |
"PHP8.0/MySQL5.7") LIMIT='~/defaults/php8.0_mysql5.7_only.yaml,' ;; | |
"PHP8.0/MySQL8.0") LIMIT='~/defaults/php8.0_mysql8.0_only.yaml,' ;; | |
"PHP8.1/MySQL5.7") LIMIT='~/defaults/php8.1_mysql5.7_only.yaml,' ;; | |
"PHP8.1/MySQL8.0") LIMIT='~/defaults/php8.1_mysql8.0_only.yaml,' ;; | |
"PHP8.2/MySQL5.7") LIMIT='~/defaults/php8.2_mysql5.7_only.yaml,' ;; | |
"PHP8.2/MySQL8.0") LIMIT='~/defaults/php8.2_mysql8.0_only.yaml,' ;; | |
"PHP8.3/MySQL5.7") LIMIT='~/defaults/php8.3_mysql5.7_only.yaml,' ;; | |
"PHP8.3/MySQL8.0") LIMIT='~/defaults/php8.3_mysql8.0_only.yaml,' ;; | |
*) echo "Illegal choice, fix the workflow" | |
exit 1 | |
;; | |
esac | |
# shellcheck disable=SC2088 | |
case '${{ inputs.version}}' in | |
"7.0") PRE="~/defaults/7.0.x.yaml," ;; | |
"7.1") PRE="~/defaults/7.1.x.yaml," ;; | |
"7.2") PRE="~/defaults/7.2.x.yaml," ;; | |
"8.0") PRE="~/defaults/8.0.x.yaml," ;; | |
custom) TESTPLAN="${{ inputs.custom_testplan }}" ;; | |
*) | |
echo "Illegal choice, fix the workflow" | |
exit 1 | |
;; | |
esac | |
if [ -z "${TESTPLAN}" ]; then | |
# shellcheck disable=SC2088 | |
TESTPLAN="${PRE}${LIMIT}~/metapackage-${{inputs.version}}-${{inputs.scenario}}.yaml" | |
fi | |
echo "testplan=${TESTPLAN}" | tee -a "${GITHUB_OUTPUT}" | |
stable: | |
needs: build_testplan | |
if: ${{ inputs.use_dev_version == 'no' }} | |
uses: oxid-eSales/github-actions/.github/workflows/universal_workflow_light.yaml@v4 | |
with: | |
testplan: ${{ needs.build_testplan.outputs.testplan }} | |
runs_on: ${{ inputs.runs_on }} | |
defaults: 'v4' | |
plan_folder: '.github/oxid-esales' | |
secrets: | |
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }} | |
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }} | |
CACHE_ENDPOINT: ${{ secrets.CACHE_ENDPOINT }} | |
CACHE_ACCESS_KEY: ${{ secrets.CACHE_ACCESS_KEY }} | |
CACHE_SECRET_KEY: ${{ secrets.CACHE_SECRET_KEY }} | |
enterprise_github_token: ${{ secrets.enterprise_github_token }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
dev: | |
needs: build_testplan | |
if: ${{ inputs.use_dev_version == 'v0' }} | |
uses: oxid-eSales/github-actions/.github/workflows/universal_workflow_light.yaml@v0 | |
with: | |
testplan: ${{ needs.build_testplan.outputs.testplan }} | |
runs_on: ${{ inputs.runs_on }} | |
defaults: 'v0' | |
plan_folder: '.github/oxid-esales' | |
secrets: | |
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }} | |
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }} | |
CACHE_ENDPOINT: ${{ secrets.CACHE_ENDPOINT }} | |
CACHE_ACCESS_KEY: ${{ secrets.CACHE_ACCESS_KEY }} | |
CACHE_SECRET_KEY: ${{ secrets.CACHE_SECRET_KEY }} | |
enterprise_github_token: ${{ secrets.enterprise_github_token }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
gather_data: | |
needs: ['build_testplan', 'stable', 'dev'] | |
if: always() | |
runs-on: ${{ fromJson(inputs.runs_on) }} | |
outputs: | |
mysql: ${{ steps.mysql.outputs.result }} | |
php: ${{ steps.php.outputs.result }} | |
steps: | |
- name: 'Checkout testplan defaults' | |
uses: actions/checkout@v4 | |
with: | |
repository: 'OXID-eSales/github-actions' | |
ref: 'v4' | |
path: 'defaults' | |
sparse-checkout: '.github/oxid-esales' | |
- name: 'Checkout testplans' | |
uses: actions/checkout@v4 | |
with: | |
sparse-checkout: | | |
.github/oxid-esales | |
composer.json | |
path: workflow | |
- name: 'Consolidate plans' | |
id: consolidate_plans | |
run: | | |
mkdir -p '.github/oxid-esales/defaults' | |
if [ -d workflow/.github/oxid-esales ]; then | |
mv -v workflow/.github/oxid-esales/* '.github/oxid-esales/' | |
/bin/rm -r 'workflow/.github/oxid-esales' | |
fi | |
if [ -f workflow/composer.json ]; then | |
mv workflow/composer.json '.github/oxid-esales/' | |
fi | |
mv defaults/.github/oxid-esales/defaults/* '.github/oxid-esales/defaults/' | |
if [ '${{ github.event_name }}' == 'pull_request' ]; then | |
REF=$(echo '${{ github.ref_name }}'|sed -e 's|/refs/heads/||') | |
# This is the git ref name | |
sed -e "s|safe_ref_name:.*|safe_ref_name: ${REF}|" -i.backup '.github/oxid-esales/defaults/defaults_light.yaml' | |
# This is the same for composer but with an added dev- prefix | |
sed -e "s|ref_name: dev-.*|ref_name: dev-${REF}|" -i.backup '.github/oxid-esales/defaults/defaults_light.yaml' | |
fi | |
TESTPLAN=$(echo "${{ needs.build_testplan.outputs.testplan }}"|sed -e 's|~|.github/oxid-esales|g') | |
# ToDo: Remove the ,.github/oxid-esales/defaults/_rename.yaml when releasing v5 | |
DEFAULTS=".github/oxid-esales/defaults/defaults_light.yaml" | |
echo "testplan=${DEFAULTS},${TESTPLAN},.github/oxid-esales/defaults/_rename.yaml" >>"${GITHUB_OUTPUT}" | |
- name: 'Load Testplan' | |
id: ltp | |
uses: 'joernott/load_testplan@v1' | |
with: | |
files: '${{ steps.consolidate_plans.outputs.testplan }}' | |
set_output: true | |
set_env: true | |
set_print: true | |
loglevel: info | |
logfile: load_testplan_init.log | |
yaml: generated_testplan.yaml | |
- name: Get MySQL version | |
id: mysql | |
run: | | |
MYSQL=$(echo "${install_matrix_mysql}"|sed -e 's#,.*##' -e 's#["|\s|[]##g') | |
echo "result=${MYSQL}" >>"${GITHUB_OUTPUT}" | |
- name: Get PHP array | |
id: php | |
run: | | |
# get PHP array | |
echo "result=${install_matrix_php}" >>"${GITHUB_OUTPUT}" | |
consolidate: | |
needs: 'gather_data' | |
if: always() | |
runs-on: ${{ fromJson(inputs.runs_on) }} | |
strategy: | |
matrix: | |
php: ${{ fromJSON(needs.gather_data.outputs.php) }} | |
branch: ['b-${{inputs.version}}'] | |
steps: | |
- name: 'Download artifacts' | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: 'install-*b-*-PHP${{matrix.php}}-MYSQL${{needs.gather_data.outputs.mysql}}' | |
merge-multiple: true | |
path: data | |
- name: 'Rename files' | |
run: | | |
find data | |
mv data/source/composer.lock ${{matrix.branch}}-${{matrix.php}}-composer.lock | |
mv data/source/composer.json.bak ${{matrix.branch}}-${{matrix.php}}-composer.json | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: 'composer-${{matrix.branch}}-${{matrix.php}}' | |
path: ${{matrix.branch}}-${{matrix.php}}-composer.* | |
retention-days: 4 | |
overwrite: true | |
process_data: | |
needs: ['gather_data', 'consolidate'] | |
if: always() | |
runs-on: ${{ fromJson(inputs.runs_on) }} | |
steps: | |
- name: 'Download artifacts' | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: '*-composer.*' | |
path: files | |
- name: Process files | |
uses: actions/github-script@v7 | |
id: mysql | |
with: | |
script: | | |
var fs = require('fs'); | |
var branches = ['b-7.0', 'b-7.1', 'b-7.2', 'b-8.0']; | |
var php_versions = JSON.parse('${{ needs.gather_data.outputs.php }}'); | |
if (php_versions.constructor !== Array) | |
core.info(`Could not get PHP matrix from ${php_versions}`); | |
core.setFailed(`Could not get PHP matrix from ${php_versions}`); | |
for (var b = 0; b < branches.length; b++) { | |
var branch = branches[b]; | |
composer_file=`./${branch}-${php_versions[0]}-composer.json`; | |
core.info(`Load ${composer_file}`); | |
var composer_json = JSON.parse(fs.readFileSync(composer_file, 'utf8')); | |
var all = {}; | |
var require = {}; | |
for (r in composer_json["require"]) { | |
require[r]='' | |
core.info(`Add ${r} to mandatory list`); | |
} | |
for (var p = 0; p < php_versions.length; p++) { | |
lock_file=`./${branch}-${php_versions[p]}-composer.lock` | |
core.info(`Load ${lock_file}`); | |
var composer_lock = JSON.parse(fs.readFileSync(lock_file, 'utf8')); | |
for (l = 0; l < composer_lock.packages.length; l++) { | |
package=composer_lock.packages[l].name | |
version=composer_lock.packages[l].version | |
core.info(`Process ${package}:${version} from composer.lock ...`); | |
if (! (package in all)) { | |
all[package]=version | |
core.info("... added to all"); | |
} else { | |
a=all[package]; | |
i=a.indexOf(version); | |
core.info(`... already exists with value ${a} (${i})`); | |
if (a.indexOf(version) === -1) { | |
all[package] = `${all[package]} || ${version}`; | |
core.info("... extended previous definition in all"); | |
} | |
} | |
if (package in require) { | |
if (require[package] == '') { | |
core.info("... set value in mandatory list"); | |
require[package] = version; | |
} else { | |
if (require[package].indexOf(version) === -1) { | |
require[package] = `${require[package]} || ${version}`; | |
core.info("... extended previous definition in mandatory list"); | |
} | |
} | |
} else { | |
core.info("... ignore for mandatory list"); | |
} | |
} | |
} | |
core.summary.addSeparator() | |
core.summary.addHeading(`Pinned versions for ${branch}`, '1') | |
core.summary.addCodeBlock(JSON.stringify(all), 'json') | |
core.info(`Mandatory list for ${branch}`); | |
core.info("========================"); | |
core.info(require); | |
core.info("========================"); | |
core.info(`Full list for ${branch}`); | |
core.info("========================"); | |
core.info(all); | |
} |