Skip to content

Commit

Permalink
add symfony app and test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sophie Wigmore committed Dec 14, 2022
1 parent 1750cd6 commit 24d2f72
Show file tree
Hide file tree
Showing 305 changed files with 39,946 additions and 5,035 deletions.
69 changes: 35 additions & 34 deletions integration/framework_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,40 +82,41 @@ func testFrameworkApps(t *testing.T, context spec.G, it spec.S) {
Eventually(container).Should(Serve(ContainSubstring("<title>Laravel</title>")).OnPort(8080))
})
})
// context("building a symfony app", func() {
// var (
// err error
// logs fmt.Stringer
// )

// it.Before(func() {
// source, err = occam.Source(filepath.Join("testdata", "symfony_app"))
// Expect(err).NotTo(HaveOccurred())
// })

// it("builds and runs", func() {
// image, logs, err = pack.Build.
// WithPullPolicy("never").
// WithBuildpacks(buildpacksArray...).
// WithEnv(map[string]string{
// "BP_PHP_SERVER": "nginx",
// "BP_PHP_WEB_DIR": "public",
// "BP_COMPOSER_INSTALL_OPTIONS": "--no-scripts -o",
// "BP_LOG_LEVEL": "DEBUG",
// }).
// Execute(name, source)

// Expect(err).ToNot(HaveOccurred(), logs.String)

// container, err = docker.Container.Run.
// WithEnv(map[string]string{"PORT": "8080"}).
// WithPublish("8080").
// Execute(image.ID)
// Expect(err).NotTo(HaveOccurred())

// Eventually(container).Should(Serve(ContainSubstring("Welcome")).OnPort(8080))
// })
// })

context("building a symfony app", func() {
var (
err error
logs fmt.Stringer
)

it.Before(func() {
source, err = occam.Source(filepath.Join("testdata", "symfony_app"))
Expect(err).NotTo(HaveOccurred())
})

it("builds and runs", func() {
image, logs, err = pack.Build.
WithPullPolicy("never").
WithBuildpacks(buildpacksArray...).
WithEnv(map[string]string{
"BP_PHP_SERVER": "nginx",
"BP_PHP_WEB_DIR": "public",
"BP_COMPOSER_INSTALL_OPTIONS": "--no-scripts -o",
}).
Execute(name, source)

Expect(err).ToNot(HaveOccurred(), logs.String)

container, err = docker.Container.Run.
WithEnv(map[string]string{"PORT": "8080"}).
WithPublish("8080").
Execute(image.ID)
Expect(err).NotTo(HaveOccurred())

Eventually(container).Should(Serve(ContainSubstring("<title>Symfony Demo application</title>")).OnPort(8080))
Eventually(container).Should(Serve(ContainSubstring("Symfony Demo blog")).OnPort(8080).WithEndpoint("/en/blog/"))
})
})

})
}
20 changes: 20 additions & 0 deletions integration/testdata/symfony_app/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/shyim/devcontainers-features/symfony-cli:0": {},
"ghcr.io/shyim/devcontainers-features/php:0": {
"version": "8.1"
},
"ghcr.io/devcontainers/features/node:1": {
"version": "lts"
}
},
"updateContentCommand": {
"composer install": ["composer", "install"],
"yarn": ["yarn"]
},
"postAttachCommand": {
"server": "symfony server:start",
"yarn": ["yarn", "watch"]
}
}
10 changes: 10 additions & 0 deletions integration/testdata/symfony_app/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; top-most EditorConfig file
root = true

; Unix-style newlines
[*]
end_of_line = LF

[*.php]
indent_style = space
indent_size = 4
17 changes: 16 additions & 1 deletion integration/testdata/symfony_app/.env
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,20 @@

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=8c582a1d289c9ad62a1461ce697cfa4f
APP_SECRET=2ca64f8d83b9e89f5f19d672841d6bb8
#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
#TRUSTED_HOSTS='^(localhost|example\.com)$'
###< symfony/framework-bundle ###

###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
DATABASE_URL=sqlite:///%kernel.project_dir%/data/database.sqlite
# DATABASE_URL="mysql://db_user:[email protected]:3306/db_name?serverVersion=5.7",
# DATABASE_URL="postgresql://db_user:[email protected]:5432/db_name?serverVersion=13&charset=utf8"
###< doctrine/doctrine-bundle ###

###> symfony/mailer ###
# MAILER_DSN=null://null
###< symfony/mailer ###
7 changes: 7 additions & 0 deletions integration/testdata/symfony_app/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# define your env variables for the test env here
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
PANTHER_APP_ENV=panther
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
DATABASE_URL=sqlite:///%kernel.project_dir%/data/database_test.sqlite
95 changes: 95 additions & 0 deletions integration/testdata/symfony_app/.github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: "Lint"

on:
pull_request:
push:
branches:
- main

env:
fail-fast: true

permissions:
contents: read

jobs:
php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout@v3

- name: PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --diff --dry-run

linters:
name: Linters
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.1']

steps:
- name: "Checkout code"
uses: actions/checkout@v3

- name: "Install PHP with extensions"
uses: shivammathur/setup-php@v2
with:
coverage: "none"
extensions: intl
php-version: ${{ matrix.php-version }}
tools: composer:v2

- name: "Set composer cache directory"
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: "Cache composer"
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }}
restore-keys: ${{ runner.os }}-${{ matrix.php-version }}-composer-

- name: "Composer install"
run: composer install --no-interaction --no-progress

- name: Install PHPUnit
id: install
run: vendor/bin/simple-phpunit install

- name: Lint YAML files
if: always() && steps.install.outcome == 'success'
run: ./bin/console lint:yaml config --parse-tags

- name: Lint Twig templates
if: always() && steps.install.outcome == 'success'
run: ./bin/console lint:twig templates --env=prod

- name: Lint XLIFF translations
if: always() && steps.install.outcome == 'success'
run: ./bin/console lint:xliff translations

- name: Lint Parameters and Services
if: always() && steps.install.outcome == 'success'
run: ./bin/console lint:container --no-debug

- name: Lint Doctrine entities
if: always() && steps.install.outcome == 'success'
run: ./bin/console doctrine:schema:validate --skip-sync -vvv --no-interaction

- name: Lint Composer config
if: always() && steps.install.outcome == 'success'
run: composer validate --strict

- name: Check if any dependencies are compromised
if: always() && steps.install.outcome == 'success'
run: composer audit

- name: Run PHPStan
if: always() && steps.install.outcome == 'success'
run: ./vendor/bin/phpstan analyze
74 changes: 74 additions & 0 deletions integration/testdata/symfony_app/.github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: "Tests"

on:
pull_request:
push:
branches:
- main

env:
fail-fast: true
PHPUNIT_FLAGS: "-v"
SYMFONY_PHPUNIT_DIR: "$HOME/symfony-bridge/.phpunit"
SYMFONY_DEPRECATIONS_HELPER: 7

permissions:
contents: read

jobs:
test:
name: "${{ matrix.operating-system }} / PHP ${{ matrix.php-version }}"
runs-on: ${{ matrix.operating-system }}
continue-on-error: false

strategy:
matrix:
operating-system: ['ubuntu-latest']
php-version: ['8.1']
include:
- operating-system: 'macos-latest'
php-version: '8.1'
- operating-system: 'windows-latest'
php-version: '8.1'

steps:
- name: "Checkout code"
uses: actions/checkout@v3

- name: "Install PHP with extensions"
uses: shivammathur/setup-php@v2
with:
coverage: "none"
extensions: "intl, mbstring, pdo_sqlite"
php-version: ${{ matrix.php-version }}
tools: composer:v2

- name: "Add PHPUnit matcher"
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: "Set composer cache directory"
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
shell: bash

- name: "Cache composer"
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php-version }}-composer-${{ hashFiles('composer.json') }}
restore-keys: ${{ runner.os }}-${{ matrix.php-version }}-composer-

- name: "Require symfony/flex"
run: composer require --no-progress --no-scripts --no-plugins symfony/flex

- name: "Install dependencies"
run: composer update --no-interaction --prefer-dist --optimize-autoloader

- name: "Install PHPUnit"
run: vendor/bin/simple-phpunit install

- name: "PHPUnit version"
run: vendor/bin/simple-phpunit --version

- name: "Run tests"
run: vendor/bin/simple-phpunit ${{ env.PHPUNIT_FLAGS }}
24 changes: 24 additions & 0 deletions integration/testdata/symfony_app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/public/build/fonts/glyphicons-*
/public/build/images/glyphicons-*

.php-version

###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###

###> symfony/phpunit-bridge ###
.phpunit.result.cache
/phpunit.xml
###< symfony/phpunit-bridge ###
###> symfony/webpack-encore-bundle ###
/node_modules/
npm-debug.log
yarn-error.log
###< symfony/webpack-encore-bundle ###
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
location / {
# try to serve file directly, fallback to index.php
try_files $uri /index.php$is_args$args;
}
43 changes: 43 additions & 0 deletions integration/testdata/symfony_app/.php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

$fileHeaderComment = <<<COMMENT
This file is part of the Symfony package.
(c) Fabien Potencier <[email protected]>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
COMMENT;

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude('config')
->exclude('var')
->exclude('public/bundles')
->exclude('public/build')
// exclude files generated by Symfony Flex recipes
->notPath('bin/console')
->notPath('public/index.php')
;

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'header_comment' => ['header' => $fileHeaderComment, 'separate' => 'both'],
'linebreak_after_opening_tag' => true,
'mb_str_functions' => true,
'no_php4_constructor' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'php_unit_strict' => true,
'phpdoc_order' => true,
'strict_comparison' => true,
'strict_param' => true,
'blank_line_between_import_groups' => false,
])
->setFinder($finder)
->setCacheFile(__DIR__.'/var/.php-cs-fixer.cache')
;
2 changes: 2 additions & 0 deletions integration/testdata/symfony_app/.php.ini.d/custom.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extension=pdo.so
extension=pdo_sqlite.so
7 changes: 7 additions & 0 deletions integration/testdata/symfony_app/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Contributing
============

The Symfony Demo application is an open source project. Contributions made by
the community are welcome. Send us your ideas, code reviews, pull requests and
feature requests to help us improve this project. All contributions must follow
the [usual Symfony contribution requirements](https://symfony.com/doc/current/contributing/index.html).
Loading

0 comments on commit 24d2f72

Please sign in to comment.