diff --git a/.env.test b/.env.test index d52204b6..b07ce5dc 100644 --- a/.env.test +++ b/.env.test @@ -1,4 +1,4 @@ # define your env variables for the test env here KERNEL_CLASS='App\Kernel' APP_SECRET='s$cretf0rt3st' -DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name_test +DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name_test?serverVersion=5.7 diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml new file mode 100644 index 00000000..87b087fb --- /dev/null +++ b/.github/workflows/test-application.yaml @@ -0,0 +1,158 @@ +name: Test application + +on: + pull_request: + push: + branches: + - master + - release/** + +jobs: + test: + name: "Test and build with php ${{ matrix.php-version }} and Node.js ${{ matrix.node-version }}" + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + include: + - php-version: '7.2' + node-version: '10.x' + create-project: true + create-database: true + checkout-directory: 'project' + working-directory: 'create-project-test' + php-extensions: 'ctype, iconv, mysql, gd' + tools: 'composer:v1' + env: {} + + - php-version: '7.4' + node-version: '12.x' + create-project: false + create-database: false + checkout-directory: 'project' + working-directory: 'project' + php-extensions: 'ctype, iconv, mysql, imagick' + tools: 'composer:v2' + env: + APP_ENV: test + APP_SECRET: a448d1dfcaa563fce56c2fd9981f662b + MAILER_URL: null://localhost + SULU_ADMIN_EMAIL: + DATABASE_URL: "mysql://root:@127.0.0.1:3306/sulu_test?serverVersion=5.7" + + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ALLOW_EMPTY_PASSWORD: yes + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5 + + steps: + - name: Checkout project + uses: actions/checkout@v2 + with: + path: ${{ matrix.checkout-directory }} + + - name: Install and configure PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: ${{ matrix.php-extensions }} + tools: ${{ matrix.tools }} + coverage: none + + - name: Get composer cache directory + id: composer-cache-dir + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + working-directory: ${{ matrix.checkout-directory }} + + - name: Cache dependencies + uses: actions/cache@v2 + id: composer-cache + with: + path: ${{ steps.composer-cache-dir.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + + - name: Install dependencies + if: ${{ !matrix.create-project }} + run: | + composer validate --strict + composer update --prefer-dist --no-interaction + working-directory: ${{ matrix.working-directory }} + + - name: Create project + if: ${{ matrix.create-project }} + run: | + composer create-project sulu/skeleton ${{ matrix.working-directory }} --repository="{\"type\":\"path\",\"url\":\"./${{ matrix.checkout-directory }}/\"}" --stability=dev -n + cd ${{ matrix.working-directory }} + echo 'DATABASE_URL=mysql://root:@127.0.0.1:3306/sulu?serverVersion=5.7' >> .env.local + echo 'DATABASE_URL=mysql://root:@127.0.0.1:3306/sulu_test?serverVersion=5.7' >> .env.test.local + + - name: Create database + if: ${{ matrix.create-database }} + run: bin/adminconsole doctrine:database:create + env: ${{ matrix.env }} + working-directory: ${{ matrix.working-directory }} + + - name: Build sulu + run: bin/adminconsole sulu:build dev --no-interaction + env: ${{ matrix.env }} + working-directory: ${{ matrix.working-directory }} + + - name: Build container + run: | + bin/adminconsole cache:clear --env dev + bin/websiteconsole cache:clear --env dev + bin/adminconsole cache:clear --env test + bin/websiteconsole cache:clear --env test + bin/adminconsole cache:clear --env stage + bin/websiteconsole cache:clear --env stage + bin/adminconsole cache:clear --env prod + bin/websiteconsole cache:clear --env prod + env: ${{ matrix.env }} + working-directory: ${{ matrix.working-directory }} + + - name: Lint container + run: | + bin/adminconsole lint:container --env dev + bin/websiteconsole lint:container --env dev + bin/adminconsole lint:container --env test + bin/websiteconsole lint:container --env test + bin/adminconsole lint:container --env stage + bin/websiteconsole lint:container --env stage + bin/adminconsole lint:container --env prod + bin/websiteconsole lint:container --env prod + env: ${{ matrix.env }} + working-directory: ${{ matrix.working-directory }} + + - name: Lint + run: | + bin/adminconsole doctrine:ensure-production-settings --env prod + bin/adminconsole doctrine:schema:validate + bin/adminconsole lint:twig templates + bin/adminconsole lint:yaml config + env: ${{ matrix.env }} + working-directory: ${{ matrix.working-directory }} + + - name: Run tests + run: bin/phpunit + env: ${{ matrix.env }} + working-directory: ${{ matrix.working-directory }} + + - name: Install and configure Node.js + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Install npm dependencies + run: npm install + working-directory: ${{ matrix.working-directory }}/assets/admin + + - name: Build admin ui + run: npm run build + working-directory: ${{ matrix.working-directory }}/assets/admin diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 13ea5ad7..00000000 --- a/.travis.yml +++ /dev/null @@ -1,85 +0,0 @@ -sudo: false - -language: php - -services: - - mysql - -cache: - directories: - - "$HOME/.composer/cache/files" - -before_install: - - composer self-update - - phpenv config-add tests/travis.php.ini - -env: - global: - - COMPOSER_VALIDATE_FLAGS="--strict" - -matrix: - include: - # With ENVIRONMENT variables - - php: 7.2 - install: - # Install dependencies - - travis_retry composer update $COMPOSER_FLAGS - - composer info -i - # Create database for build test - - bin/adminconsole doctrine:database:create - env: - - APP_ENV=test - - APP_SECRET=a448d1dfcaa563fce56c2fd9981f662b - - MAILER_URL=null://localhost - - SULU_ADMIN_EMAIL= - - DATABASE_URL=mysql://root:@127.0.0.1/sulu_test - - COMPOSER_FLAGS="--no-interaction" - - # Without ENVIRONMENT variables - - php: 7.4 - install: - - composer create-project sulu/skeleton ../test-create-project-dir --repository="{\"type\":\"path\",\"url\":\"./\"}" --stability=dev -n - - cd ../test-create-project-dir - - echo 'DATABASE_URL=mysql://root:@127.0.0.1:3306/sulu' >> .env.local - - echo 'DATABASE_URL=mysql://root:@127.0.0.1:3306/sulu_test' >> .env.test.local - env: - - NPM_BUILD=true - - COMPOSER_VALIDATE_FLAGS="--strict --no-check-publish" - -script: - - pwd - - | - if [[ $NPM_BUILD = true ]]; then - nvm install 12 - cd assets/admin - npm install - npm run build - fi - - if [[ $NPM_BUILD = true ]]; then cd ../..; fi - - composer validate $COMPOSER_VALIDATE_FLAGS - # Test Build - - bin/adminconsole sulu:build dev --no-interaction - # Test container build in different environments - - bin/adminconsole cache:clear --env dev - - bin/websiteconsole cache:clear --env dev - - bin/adminconsole cache:clear --env test - - bin/websiteconsole cache:clear --env test - - bin/adminconsole cache:clear --env stage - - bin/websiteconsole cache:clear --env stage - - bin/adminconsole cache:clear --env prod - - bin/websiteconsole cache:clear --env prod - # Test container lint in different environments - - bin/adminconsole lint:container --env dev - - bin/websiteconsole lint:container --env dev - - bin/adminconsole lint:container --env test - - bin/websiteconsole lint:container --env test - - bin/adminconsole lint:container --env stage - - bin/websiteconsole lint:container --env stage - - bin/adminconsole lint:container --env prod - - bin/websiteconsole lint:container --env prod - # Lint - - bin/adminconsole doctrine:ensure-production-settings --env prod - - bin/adminconsole doctrine:schema:validate - - bin/phpunit - - bin/adminconsole lint:twig templates - - bin/adminconsole lint:yaml config