Repository navigation
108 lines (97 loc) · 4.3 KB
/
Copy pathcompile.yml
File metadata and controls
108 lines (97 loc) · 4.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: Magento 2 DI compilation
on:
push:
branches: [main, master]
tags: ['*']
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
detect:
name: Detect Magento versions
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.versions.outputs.versions }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
sparse-checkout: |
MODULE.json
sparse-checkout-cone-mode: false
- name: Determine Magento versions
id: versions
shell: bash
run: |
ALL='["2.4.7-p10", "2.4.8-p5", "2.4.9"]'
if [ ! -f MODULE.json ]; then
echo "::notice::No MODULE.json found, skipping compilation"
echo "versions=[]" >> "$GITHUB_OUTPUT"
exit 0
fi
VERSIONS=$(jq -c --argjson all "$ALL" '(.skip_magento_versions // []) as $skip | $all - $skip' MODULE.json)
echo "Magento versions: $VERSIONS"
echo "versions=$VERSIONS" >> "$GITHUB_OUTPUT"
compile:
name: Magento 2 DI compilation
needs: detect
if: needs.detect.outputs.versions != '[]'
runs-on: ubuntu-latest
timeout-minutes: ${{ fromJSON(vars.COMPILE_JOB_TIMEOUT || '30') }}
strategy:
fail-fast: false
matrix:
magento_version: ${{ fromJSON(needs.detect.outputs.versions) }}
container:
image: yireo/magento2installed:${{ matrix.magento_version }}
credentials: ${{ secrets.DOCKERHUB_USERNAME && fromJSON(format('{{"username":"{0}","password":"{1}"}}', secrets.DOCKERHUB_USERNAME, secrets.DOCKERHUB_TOKEN)) || null }}
options: --user root
env:
MAGENTO_VERSION: ${{ matrix.magento_version }}
COMPOSER_CACHE_DIR: /tmp/composer-cache
steps:
- name: Checkout sources
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Cleanup PHP
run: rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
- name: Setting up module variables
shell: bash
run: |
COMPOSER_NAME=$(jq -er '.name' composer.json)
MAGENTO_MODULE=$(jq -r '.module_name // empty' MODULE.json 2>/dev/null || true)
[[ "$COMPOSER_NAME" =~ ^[a-z0-9_.-]+/[a-z0-9_.-]+$ ]] || { echo "::error::Invalid composer name"; exit 1; }
[[ -z "$MAGENTO_MODULE" || "$MAGENTO_MODULE" =~ ^[A-Za-z0-9]+_[A-Za-z0-9]+$ ]] || { echo "::error::Invalid module name"; exit 1; }
echo "COMPOSER_NAME=$COMPOSER_NAME" >> "$GITHUB_ENV"
echo "MAGENTO_MODULE=$MAGENTO_MODULE" >> "$GITHUB_ENV"
- name: Configure Composer
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
LOKI_REPO_USERNAME: ${{ secrets.LOKI_REPO_USERNAME }}
LOKI_REPO_PASSWORD: ${{ secrets.LOKI_REPO_PASSWORD }}
MAGENTO_MARKETPLACE_PUBLIC_KEY: ${{ secrets.MAGENTO_MARKETPLACE_PUBLIC_KEY }}
MAGENTO_MARKETPLACE_PRIVATE_KEY: ${{ secrets.MAGENTO_MARKETPLACE_PRIVATE_KEY }}
GITHUB_TOKEN: ${{ github.token }}
VALIDATE_GITHUB_TOKEN: "1"
run: bash "$GITHUB_WORKSPACE/.github/workflows/composer-setup.sh"
- name: Restore Composer cache
if: github.event.pull_request.head.repo.fork != true && !env.ACT
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
with:
path: /tmp/composer-cache
key: composer-compile-${{ matrix.magento_version }}-${{ hashFiles('composer.json') }}
restore-keys: |
composer-compile-${{ matrix.magento_version }}-
- name: Add module source
run: |
cp -R "$GITHUB_WORKSPACE" /tmp/magento/package-source
cd /tmp/magento
composer config repositories.local-source path package-source/
composer require -n --prefer-dist -- "${COMPOSER_NAME}:@dev"
- name: Run Magento 2 compilation
run: |
cd /tmp/magento
bin/magento module:enable --all
php -dzend.enable_gc=0 -drealpath_cache_size=64M -drealpath_cache_ttl=7200 -dopcache.enable_cli=1 -dopcache.memory_consumption=512 -dopcache.interned_strings_buffer=64 -dopcache.max_accelerated_files=100000 -dmemory_limit=-1 bin/magento setup:di:compile