Skip to content

Commit

Permalink
Merge pull request #10 from shopware/fix-storefront-only
Browse files Browse the repository at this point in the history
feat: update GitHub Actions workflow to support separate builds for a…
  • Loading branch information
shyim authored Oct 25, 2024
2 parents 5147f46 + 3e0eded commit d299044
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 47 deletions.
34 changes: 32 additions & 2 deletions .github/workflows/blank.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ name: CI
on:
push:
branches: [ "main" ]
pull_request:
workflow_dispatch:

jobs:
build:
mysql-variation:
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -15,9 +16,38 @@ jobs:
- mysql:8.1
- mariadb:11
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Shopware
uses: shopware/setup-shopware@main
uses: ./.
with:
mysql-version: ${{ matrix.mysql }}
install: 'true'
path: 'sw-test'

only-storefront:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Shopware
uses: ./.
with:
install: 'true'
installStorefront: 'true'
path: 'sw-test'

only-admin:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Shopware
uses: ./.
with:
install: 'true'
installAdmin: 'true'
path: 'sw-test'



48 changes: 19 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,21 @@ Setup Shopware in your GitHub Actions pipeline to run tests.

### Inputs:

- `shopware-version` (default: `v6.5.3.2`) - The Shopware version to install.
- `php-version` (default: `8.1`) - The PHP version to use. The `php-version` can be any PHP version supported by [setup-php](https://github.com/shivammathur/setup-php).
- `php-extensions` (default: `pcov`) - A comma-separated list of PHP extensions to install. See setup-php project
- `env` (default: `test`) - The environment for the setup. Should be `test` for PHPUnit or `e2e` for E2E tests.
- `install` (default: `false`) - Whether to install Shopware or not. If set to `false`, the action will only install PHP, MySQL, Composer packages.
- `install-locale` (default: `en-GB`) - The locale to install Shopware with.
- `install-currency` (default: `EUR`) - The currency to install Shopware with.
- `mysql-version` (default: `builtin` - Uses by default the bundled MySQL version of GitHub Actions this is MySQL 8) - Specify any docker image to use instead like `mariadb:11` or `mysql:5.7`.

```yaml
- name: Setup Shopware
uses: shopware/setup-shopware@v1
with:
shopware-version: v6.5.3.2
php-version: 8.1
```
- `env`: The environment for Shopware. Should be `test` for PHPUnit or `e2e` for E2E tests. (default: `test`)
- `shopware-version`: The Shopware version to install. (required)
- `shopware-repository`: The Shopware repository to check out. (required, default: `shopware/shopware`)
- `php-version`: The PHP version to use. Can be any PHP version supported by [setup-php](https://github.com/shivammathur/setup-php). (default: `8.2`)
- `php-extensions`: A comma-separated list of PHP extensions to install. See setup-php project (default: `")
- `composer-root-version`: The COMPOSER_ROOT_VERSION that should be set. Can be `.auto` to use the version from `composer.json`. (optional, default: `.auto`)
- `install`: Whether to install Shopware or not. If set to `false`, the action will only install PHP, MySQL, Composer packages. (required, default: `false`)
- `install-locale`: The locale to install Shopware with. (required, default: `en-GB`)
- `install-currency`: The currency to install Shopware with. (required, default: `EUR`)
- `keep-composer-tools`: Whether to keep Shopware Composer tools (PHP Stan, ECS/PHP-CS-Fixer, BC-Checker). (required, default: `false`)
- `mysql-version`: Specify any docker image to use instead of the bundled MySQL version of GitHub Actions (default: `builtin`)
- `node-version`: The Node.js version to use. Can be omitted if not needed. (optional, default: `20.x`)
- `install-admin`: Whether to install Administration and build the assets. Can be omitted if not needed. (optional, default: "")
- `install-storefront`: Whether to install Storefront and build the assets. Can be omitted if not needed. (optional, default: "")
- `path`: Relative path under `$GITHUB_WORKSPACE` to place the Shopware repository. (required, default: "")

## Example pipeline to run PHPUnit tests

Expand All @@ -33,17 +32,8 @@ jobs:
- name: Setup Shopware
uses: shopware/setup-shopware@v1
with:
shopware-version: '6.5.7.3'
env: test
shopware-version: v6.5.3.2
shopware-repository: shopware/shopware
php-version: 8.1

- name: Checkout
uses: actions/checkout@v3
with:
path: custom/plugins/FroshPlatformTemplateMail

- name: Run Tests
run: |
cd custom/plugins/FroshPlatformTemplateMail/
php -d pcov.enabled=1 ../../../vendor/bin/phpunit --coverage-clover clover.xml
```
install: true
44 changes: 28 additions & 16 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ inputs:
description: nodejs version to use
required: false
default: "20.x"
installAdmin:
install-admin:
description: Whether to install administration npm dependencies and prepare jest
required: false
default: ""
installStorefront:
install-storefront:
description: Whether to install storefront npm dependencies
required: false
default: ""
Expand Down Expand Up @@ -128,20 +128,20 @@ runs:
working-directory: ${{ inputs.path }}

- uses: actions/setup-node@v4
if: inputs.installStorefront || inputs.installAdmin
if: inputs.install-storefront || inputs.install-admin
with:
node-version: 20
node-version: ${{ inputs.node-version }}

- name: Retrieve the cached "node_modules" directory (if present)
uses: actions/cache@v4
if: inputs.installStorefront
if: inputs.install-storefront
id: storefront-node-cache
with:
path: ${{ inputs.path || '.' }}/src/Storefront/Resources/app/storefront/node_modules
key: storefront-node-modules-${{ runner.os }}-${{ hashFiles(format('{0}/src/Storefront/Resources/app/storefront/package-lock.json', inputs.path || '.')) }}

- name: Install dependencies (if the cached directory was not found)
if: inputs.installStorefront && steps.storefront-node-cache.outputs.cache-hit != 'true'
if: inputs.install-storefront && steps.storefront-node-cache.outputs.cache-hit != 'true'
working-directory: ${{ inputs.path }}
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: "true"
Expand All @@ -150,28 +150,28 @@ runs:

- name: Retrieve the cached "node_modules" directory (if present)
uses: actions/cache@v4
if: inputs.installAdmin
if: inputs.install-admin
id: admin-node-cache
with:
path: ${{ inputs.path || '.' }}/src/Administration/Resources/app/administration/node_modules
key: admin-node-modules-${{ runner.os }}-${{ hashFiles(format('{0}/src/Administration/Resources/app/administration/package-lock.json', inputs.path || '.')) }}

- name: Install dependencies (if the cached directory was not found)
if: inputs.installAdmin && steps.admin-node-cache.outputs.cache-hit != 'true'
if: inputs.install-admin && steps.admin-node-cache.outputs.cache-hit != 'true'
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: "true"
shell: bash
working-directory: ${{ inputs.path }}
run: npm --prefix src/Administration/Resources/app/administration ci --no-audit --prefer-offline

- name: Prepare Jest environment
if: ${{ inputs.installAdmin }}
if: ${{ inputs.install-admin }}
shell: bash
working-directory: ${{ inputs.path || '.' }}/src/Administration/Resources/app/administration
run: npm run unit-setup

- name: Entity schema
if: ${{ inputs.installAdmin }}
if: ${{ inputs.install-admin }}
shell: bash
working-directory: ${{ inputs.path || '.' }}
run: |
Expand Down Expand Up @@ -229,19 +229,31 @@ runs:
run: |
composer run init:db -- --shop-locale=${{ inputs.install-locale }} --shop-currency=${{ inputs.install-currency }}
- name: Build JS
if: inputs.installAdmin == 'true' || inputs.installStorefront == 'true'
- name: Build JS Admin
if: inputs.install-admin == 'true'
shell: bash
working-directory: ${{ inputs.path }}
run: |
composer run build:js
bin/console assets:install --env="${{ inputs.env }}"
composer run build:js:admin
bin/console assets:install
- name: Build JS Storefront
if: inputs.install-storefront == 'true'
shell: bash
working-directory: ${{ inputs.path }}
run: |
composer run build:js:storefront
- name: Assign default Storefront theme to all sales channels
if: inputs.installStorefront == 'true'
if: inputs.install-storefront == 'true'
shell: bash
working-directory: ${{ inputs.path }}
run: bin/console theme:change --sync --all Storefront
run: |
if bin/console theme:change --help | grep -q '--sync'; then
bin/console theme:change --sync --all Storefront
else
bin/console theme:change --all Storefront
fi
- name: Start Webserver
if: inputs.install == 'true'
Expand Down

0 comments on commit d299044

Please sign in to comment.