Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BRAIN-43 - Implemented integration workflow #143

Draft
wants to merge 8 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@
KERNEL_CLASS='Swag\Braintree\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999

###> braintree/gateway ###
BRAINTREE_TEST_MERCHANT_ACCOUNT_ID='your_merchant_account_id'
BRAINTREE_TEST_ENVIRONMENT='sandbox'
BRAINTREE_TEST_MERCHANT_ID='your_merchant_id'
BRAINTREE_TEST_PUBLIC_KEY='your_public_key'
BRAINTREE_TEST_PRIVATE_KEY='your_private_key'
###< braintree/gateway ###
11 changes: 11 additions & 0 deletions .github/actions/check-manifest/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Check manifest
description: ''

runs:
using: composite
steps:
- name: Check for non-production manifest.xml
shell: bash
run: |
grep -q 'braintree.shopware.com' manifest.xml || (echo "Provided manifest.xml contains no production URL" && exit 1)
grep -q -z -v '<secret>' manifest.xml || (echo "Provided manifest.xml contains a secret" && exit 1)
9 changes: 7 additions & 2 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,22 @@ inputs:
description: Node version file for setup-node
required: false
default: package.json
path:
description: Path to the nodejs project
required: false
default: '.'

runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: ${{ inputs.node-version-file }}
node-version-file: ${{ inputs.path }}/${{ inputs.node-version-file }}
cache-dependency-path: ${{ inputs.path }}/package-lock.json
cache: npm
- name: Install dependencies
shell: bash
run: npm ci --no-audit --prefer-offline
run: npm ci --prefix "${{ inputs.path }}" --no-audit --prefer-offline
env:
CI: TRUE
6 changes: 5 additions & 1 deletion .github/actions/setup-php/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ inputs:
description: PHP version for setup-php
required: false
default: '8.3'
path:
description: Path to the PHP project
required: false
default: '.'

runs:
using: composite
Expand All @@ -26,4 +30,4 @@ runs:
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
shell: bash
run: composer install --prefer-dist --no-progress --no-suggest
run: composer install --working-dir="${{ inputs.path }}" --prefer-dist --no-progress --no-suggest
24 changes: 11 additions & 13 deletions .github/workflows/app-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ on:
workflow_dispatch:

jobs:
zip:
uses: shopware/github-actions/.github/workflows/build-zip.yml@main
with:
extensionName: SwagBraintreeApp

release:
uses: shopware/github-actions/.github/workflows/store-release.yml@main
with:
extensionName: SwagBraintreeApp
publishOnly: true
secrets:
accountUser: ${{ secrets.SHOPWARE_ACCOUNT_USER }}
accountPassword: ${{ secrets.SHOPWARE_ACCOUNT_PASSWORD }}
ghToken: ${{ secrets.GITHUB_TOKEN }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/check-manifest
- uses: shopware/github-actions/store-release@main
with:
extensionName: SwagBraintreeApp
publishOnly: 'true'
accountUser: ${{ secrets.SHOPWARE_ACCOUNT_USER }}
accountPassword: ${{ secrets.SHOPWARE_ACCOUNT_PASSWORD }}
ghToken: ${{ secrets.GITHUB_TOKEN }}
33 changes: 33 additions & 0 deletions .github/workflows/app-zip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: App Zip
on:
workflow_dispatch:
pull_request:
paths:
- 'Resources/**/*'
- 'templates/manifest.xml.twig'
- '.shopware-extension.yml'
- .github/workflows/app-zip.yml

jobs:
zip:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/check-manifest
- uses: shopware/github-actions/build-zip@main
with:
extensionName: SwagBraintreeApp

manifest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-php
- uses: ./.github/actions/check-manifest
- name: Generate manifest.xml
run: composer setup:manifest -- -f --env=prod
- uses: ./.github/actions/check-manifest
- name: Check manifest.xml
run: |
git update-index --refresh || printf ''
git diff-index "${{ github.sha }}" --quiet -- manifest.xml || (echo "Please run 'composer setup:manifest' to sync the manifest.xml" && exit 1)
96 changes: 96 additions & 0 deletions .github/workflows/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: PHP

on:
workflow_dispatch:
pull_request:
push:
branches:
- trunk

jobs:
application:
runs-on: ubuntu-latest
needs: [phpstan, phpunit-unit, phpunit-integration]
services:
mariadb:
image: mariadb:10.5
env:
MARIADB_ROOT_PASSWORD: swagbraintree
MYSQL_DATABASE: swagbraintree_test
ports: [ '3306:3306' ]
env:
DATABASE_URL: mysql://root:[email protected]:3306/swagbraintree
BRAINTREE_TEST_ENVIRONMENT: sandbox
BRAINTREE_TEST_MERCHANT_ID: ${{ secrets.BRAINTREE_TEST_MERCHANT_ID }}
BRAINTREE_TEST_MERCHANT_ACCOUNT_ID: ${{ secrets.BRAINTREE_TEST_MERCHANT_ACCOUNT_ID }}
BRAINTREE_TEST_PUBLIC_KEY: ${{ secrets.BRAINTREE_TEST_PUBLIC_KEY }}
BRAINTREE_TEST_PRIVATE_KEY: ${{ secrets.BRAINTREE_TEST_PRIVATE_KEY }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-php
- name: Setup database
run: composer setup:test
- name: Run PHPUnit
continue-on-error: true
run: composer phpunit:application -- --coverage-clover=coverage.xml
- name: Codecov
if: steps.phpunit-application.outcome == 'success' && steps.phpunit-application.conclusion == 'success'
uses: codecov/codecov-action@v4
with:
files: ./coverage.xml

e2e:
runs-on: ubuntu-latest
needs: [phpstan, phpunit-unit, phpunit-integration]
services:
mariadb:
image: mariadb:10.11
env:
MARIADB_ROOT_PASSWORD: root
MYSQL_DATABASE: swagbraintree_test
ports: ['3306:3306']
steps:
- name: Setup Shopware
uses: shopware/setup-shopware@main
env:
DATABASE_URL: mysql://root:[email protected]:3306/shopware
with:
shopware-version: trunk
mysql-version: skip # will use a service
install: true
install-admin: true
install-storefront: true
path: shopware
- uses: actions/checkout@v4
with:
path: braintree
- name: Setup Braintree (PHP)
uses: ./braintree/.github/actions/setup-php
with:
path: braintree
- name: Setup Braintree (Node)
uses: ./braintree/.github/actions/setup-node
with:
path: braintree
- name: Setup Braintree (Database)
env:
APP_URL: http://localhost:8001
DATABASE_URL: mysql://root:[email protected]:3306/swagbraintree
run: composer -d braintree setup
- name: Start Braintree
working-directory: braintree
env:
APP_URL: http://localhost:8001
DATABASE_URL: mysql://root:[email protected]:3306/swagbraintree
SYMFONY_DAEMON: '1'
SYMFONY_NO_TLS: '1'
SYMFONY_ALLOW_HTTP: '1'
SYMFONY_PORT: '8001'
SYMFONY_ALLOW_ALL_IP: '1'
run: symfony server:start
- name: Install Braintree
env:
DATABASE_URL: mysql://root:[email protected]:3306/shopware
run: |
ln -s braintree shopware/custom/apps/SwagBraintreeApp
shopware/bin/console app:install --activate SwagBraintreeApp
38 changes: 36 additions & 2 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,57 @@ jobs:
- name: Run PHPStan
run: composer phpstan

phpunit:
unit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-php
- name: Run PHPUnit
run: composer phpunit -- --coverage-clover=coverage.xml
run: composer phpunit:unit -- --coverage-clover=coverage.xml
- name: Codecov
uses: codecov/codecov-action@v4
with:
files: ./coverage.xml

integration:
runs-on: ubuntu-latest
services:
mariadb:
image: mariadb:10.5
env:
MARIADB_ROOT_PASSWORD: swagbraintree
MYSQL_DATABASE: swagbraintree_test
ports: ['3306:3306']
env:
DATABASE_URL: mysql://root:[email protected]:3306/swagbraintree
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-php
- name: Setup database
run: composer setup:test
- name: Run PHPUnit
run: composer phpunit:integration -- --coverage-clover=coverage.xml
- name: Codecov
uses: codecov/codecov-action@v5
with:
files: ./coverage.xml

infection:
runs-on: ubuntu-latest
services:
mariadb:
image: mariadb:10.5
env:
MARIADB_ROOT_PASSWORD: swagbraintree
MYSQL_DATABASE: swagbraintree_test
ports: ['3306:3306']
env:
DATABASE_URL: mysql://root:[email protected]:3306/swagbraintree
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-php
- name: Setup database
run: composer setup:test
- name: Run Infection
run: composer infection -- --min-msi=95
env:
Expand Down
47 changes: 30 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"php": ">=8.2",
"ext-ctype": "*",
"ext-iconv": "*",
"ext-json": "*",
"ext-simplexml": "*",
"braintree/braintree_php": "^6.19",
"doctrine/doctrine-bundle": "^2.10",
"doctrine/doctrine-migrations-bundle": "^3.2",
Expand All @@ -15,18 +17,18 @@
"guzzlehttp/psr7": "^2.6",
"nelmio/cors-bundle": "^2.3",
"shopware/app-bundle": "^4.0",
"symfony/console": "^7.1",
"symfony/dotenv": "^7.1",
"symfony/http-foundation": "^7.1",
"symfony/console": "^7.2",
"symfony/dotenv": "^7.2",
"symfony/http-foundation": "^7.2",
"symfony/flex": "^2",
"symfony/framework-bundle": "^7.1",
"symfony/framework-bundle": "^7.2",
"symfony/monolog-bundle": "^3.8",
"symfony/property-access": "^7.1",
"symfony/psr-http-message-bridge": "^7.1",
"symfony/runtime": "^7.1",
"symfony/serializer": "^7.1",
"symfony/uid": "^7.1",
"symfony/yaml": "^7.1"
"symfony/property-access": "^7.2",
"symfony/psr-http-message-bridge": "^7.2",
"symfony/runtime": "^7.2",
"symfony/serializer": "^7.2",
"symfony/uid": "^7.2",
"symfony/yaml": "^7.2"
},
"config": {
"allow-plugins": {
Expand All @@ -47,7 +49,8 @@
"autoload-dev": {
"psr-4": {
"Swag\\Braintree\\Tests\\Unit\\": "tests/unit/",
"Swag\\Braintree\\Tests\\Integration\\": "tests/integration/"
"Swag\\Braintree\\Tests\\Integration\\": "tests/integration/",
"Swag\\Braintree\\Tests\\Application\\": "tests/application/"
}
},
"replace": {
Expand Down Expand Up @@ -80,33 +83,43 @@
"setup": [
"bin/console doctrine:schema:drop --force --full-database",
"bin/console doctrine:migrations:migrate -n",
"@setup:url"
"@setup:url",
"@setup:manifest"
],
"setup:url": [
"bin/console setup:url",
"npm run dev"
]
],
"setup:manifest": "bin/console manifest:generate",
"setup:test": [
"bin/console doctrine:schema:drop --env=test --force --full-database",
"bin/console doctrine:migrations:migrate --env=test -n"
],
"phpunit:unit": "@phpunit --testsuite=SwagBraintreeUnitTest",
"phpunit:integration": "@phpunit --testsuite=SwagBraintreeIntegrationTest",
"phpunit:application": "@phpunit --testsuite=SwagBraintreeApplicationTest"
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "7.1.*"
"require": "7.2.*"
}
},
"require-dev": {
"dama/doctrine-test-bundle": "*",
"friendsofphp/php-cs-fixer": "^3.63",
"infection/infection": "^0.29.6",
"kubawerlos/php-cs-fixer-custom-fixers": "^3.16",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-symfony": "^1.3",
"phpunit/phpunit": "^11",
"symfony/debug-bundle": "^7.1",
"symfony/stopwatch": "^7.1",
"symfony/web-profiler-bundle": "^7.1",
"symfony/debug-bundle": "^7.2",
"symfony/stopwatch": "^7.2",
"symfony/web-profiler-bundle": "^7.2",
"symplify/phpstan-rules": "13.0.1",
"tomasvotruba/type-coverage": "^1.0.0"
}
Expand Down
Loading