From 3b241a50756ba3ef11a026228606985110b84590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Kr=C3=A4ml?= Date: Fri, 29 Nov 2024 11:39:52 +0100 Subject: [PATCH] NEXT-00000 - Add github actions --- .github/workflows/admin.yaml | 43 +++++++++ .github/workflows/integration.yaml | 134 +++++++++++++++++++++++++++++ .github/workflows/php.yaml | 45 ++++++++++ 3 files changed, 222 insertions(+) create mode 100644 .github/workflows/admin.yaml create mode 100644 .github/workflows/integration.yaml create mode 100644 .github/workflows/php.yaml diff --git a/.github/workflows/admin.yaml b/.github/workflows/admin.yaml new file mode 100644 index 00000000..b761c7d2 --- /dev/null +++ b/.github/workflows/admin.yaml @@ -0,0 +1,43 @@ +name: Admin + +on: + workflow_dispatch: + push: + branches: + - trunk + pull_request: + workflow_call: + +jobs: + eslint: + name: ESLint + runs-on: ubuntu-latest + steps: + - uses: shopware/github-actions/eslint@main + with: + extensionName: ${{ github.event.repository.name }} + projectPath: tests/Jest + + jest: + name: Jest + runs-on: ubuntu-latest + env: + ARTIFACTS_PATH: ${{ github.workspace }}/development + steps: + - uses: shopware/github-actions/setup-extension@main + with: + extensionName: ${{ github.event.repository.name }} + install: true + install-admin: true + install-storefront: false + extraRepositories: | + { + "${{ github.event.repository.name }}": { + "type": "path", + "url": "custom/plugins/${{ github.event.repository.name }}", + "symlink": true + } + } + - run: | + composer -d custom/plugins/${{ github.event.repository.name }} run admin:install + composer -d custom/plugins/${{ github.event.repository.name }} run admin:unit -- --ci diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml new file mode 100644 index 00000000..eac9f569 --- /dev/null +++ b/.github/workflows/integration.yaml @@ -0,0 +1,134 @@ +name: Integration + +on: + pull_request: + +jobs: + danger: + runs-on: ubuntu-latest + if: ${{ !github.event.act }} + steps: + - name: Clone + uses: actions/checkout@v1 + + - name: Danger + uses: shyim/danger-php@0.3.4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_PULL_REQUEST_ID: ${{ github.event.pull_request.number }} + + build_zip: + name: Build and validate zip + runs-on: ubuntu-latest + steps: + - name: Build + uses: shopware/github-actions/build-zip@main + with: + extensionName: ${{ github.event.repository.name }} + + codestyle_php: + name: Codestyle PHP + runs-on: ubuntu-latest + steps: + - uses: shopware/github-actions/cs-fixer@main + with: + rules: "" + phpunit: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + PLATFORM_BRANCH: ["v6.6.1.0", "trunk"] + steps: + - uses: shopware/github-actions/setup-extension@main + with: + extensionName: ${{ github.event.repository.name }} + install: true + shopwareVersion: ${{ matrix.PLATFORM_BRANCH }} + extraRepositories: | + { + "${{ github.event.repository.name }}": { + "type": "path", + "url": "custom/plugins/${{ github.event.repository.name }}", + "symlink": true + } + } + - name: Clone TestData + working-directory: custom/plugins/${{ github.event.repository.name }}/tests + run: | + # TODO: As soon as the TestData gets migrated to GH use octo-sts + git clone https://${{ secrets.TESTDATA_CLONE_TOKEN }}@gitlab.shopware.com/shopware/6/services/testdata.git testData + mysql -uroot < testData/Migration/sw55.sql + - name: Run PHPUnit + working-directory: custom/plugins/${{ github.event.repository.name }} + run: php -d pcov.enabled=1 -d pcov.directory=${PWD} -d pcov.exclude='~(vendor|tests|node_modules)~' ${GITHUB_WORKSPACE}/vendor/bin/phpunit --configuration phpunit.xml.dist + + smoke_test: + runs-on: ubuntu-latest + steps: + - uses: shopware/github-actions/setup-extension@main + with: + extensionName: ${{ github.event.repository.name }} + install: true + install-admin: true + install-storefront: true + extraRepositories: | + { + "${{ github.event.repository.name }}": { + "type": "path", + "url": "custom/plugins/${{ github.event.repository.name }}", + "symlink": true + } + } + - name: Uninstall Plugin + run: php bin/console plugin:uninstall ${{ github.event.repository.name }} + + acceptance: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + PLATFORM_BRANCH: ["v6.6.1.0", "trunk"] + services: + mysql: + image: mysql:8.0 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: shopware + ports: + - 3306:3306 + env: + DATABASE_URL: mysql://root:root@127.0.0.1:3306/shopware + steps: + - uses: shopware/github-actions/setup-extension@main + with: + extensionName: ${{ github.event.repository.name }} + install: true + install-admin: true + install-storefront: true + mysqlVersion: skip + env: prod + extraRepositories: | + { + "${{ github.event.repository.name }}": { + "type": "path", + "url": "custom/plugins/${{ github.event.repository.name }}", + "symlink": true + } + } + - name: Setup Migration Assistant + run: | + composer run build:js:admin + cd custom/plugins/${{ github.event.repository.name }}/tests + # TODO: As soon as the TestData gets migrated to GH use octo-sts + git clone https://${{ secrets.TESTDATA_CLONE_TOKEN }}@gitlab.shopware.com/shopware/6/services/testdata.git testData + mysql -uroot < testData/Migration/sw55.sql + - name: Install playwright + working-directory: custom/plugins/${{ github.event.repository.name }}/tests/acceptance + run: | + npm ci + npx playwright install --with-deps + - name: Run Playwright + working-directory: custom/plugins/${{ github.event.repository.name }}/tests/acceptance + run: | + npx playwright test --workers=1 diff --git a/.github/workflows/php.yaml b/.github/workflows/php.yaml new file mode 100644 index 00000000..98848b8c --- /dev/null +++ b/.github/workflows/php.yaml @@ -0,0 +1,45 @@ +name: PHP Checks + +on: + pull_request: + +jobs: + phpstan: + runs-on: ubuntu-latest + steps: + - uses: shopware/github-actions/setup-extension@main + env: + DATABASE_URL: mysql://root@127.0.0.1/shopware + with: + extensionName: ${{ github.event.repository.name }} + install: true + install-admin: true + install-storefront: true + extraRepositories: | + { + "${{ github.event.repository.name }}": { + "type": "path", + "url": "custom/plugins/${{ github.event.repository.name }}", + "symlink": true + } + } + - name: Create phpstan.neon + working-directory: custom/plugins/${{ github.event.repository.name }} + shell: bash + run: | + printf "parameters:\n tmpDir: ${GITHUB_WORKSPACE}/var/phpstan\nincludes:\n - phpstan.neon.dist" > phpstan.neon + - name: PHPStan cache + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/var/phpstan + key: ${{ runner.OS }}-${{ github.repository }}-phpstan-${{ github.sha }} + restore-keys: | + ${{ runner.OS }}-${{ github.repository }}-phpstan- + - name: Build PHPStan Bootstrap + shell: bash + run: php ${GITHUB_WORKSPACE}/src/Core/DevOps/StaticAnalyze/phpstan-bootstrap.php + - name: Run PHPStan + shell: bash + run: | + symfony composer -d custom/plugins/${{ github.event.repository.name }} dump-autoload --dev + symfony composer -d custom/plugins/${{ github.event.repository.name }} run phpstan