Skip to content

Commit

Permalink
Upgrade to php 8.2 & Symfony 6.3
Browse files Browse the repository at this point in the history
includes bootstrap 5 upgrade
  • Loading branch information
andrew-gardener committed May 10, 2024
1 parent ed9aaca commit f0da7d3
Show file tree
Hide file tree
Showing 408 changed files with 8,500 additions and 12,500 deletions.
47 changes: 47 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###

###> phpunit/phpunit ###
.phpunit.cache/
coverage/
###< phpunit/phpunit ###

###> friendsofphp/php-cs-fixer ###
/.php-cs-fixer.cache
###< friendsofphp/php-cs-fixer ###

# Editors
/.idea
.vscode

# Bundles
/public/js/jquery.collection.js
/templates/jquery.collection.html.twig

# Yarn packages.
node_modules

# Docker
.data

# MISC
/*.sql
/data
/src/.preload.php

# Code coverage and QA reports
public/dev

# Mac DS_Store
.DS_Store

# Docker image specific
/docs
/.github/
9 changes: 6 additions & 3 deletions .env
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=a216576ec4fb8ccdae78d6915fa7278e
#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 ###

###> symfony/mailer ###
MAILER_DSN=null://null
MAILER_DSN=smtp://bep:password@mail:1025
###< symfony/mailer ###

###> doctrine/doctrine-bundle ###
DATABASE_URL=mysql://db_user:[email protected]:3306/db_name?serverVersion=5.7
DATABASE_URL=mysql://bep:password@db:3306/bep?serverVersion=mariadb-10.11.0
###< doctrine/doctrine-bundle ###

# Routing information
ROUTE_PROTOCOL=http
ROUTE_HOST=localhost
ROUTE_BASE=/
ROUTE_BASE=
TRUSTED_PROXIES=127.0.0.1

# Piwik
PIWIK_ENABLED=false
151 changes: 151 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
name: Unit Tests & Tagged Deploy

# based on: https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners

on:
push:
branches:
- '*'
tags:
- 'v*'

env:
REGISTRY_IMAGE: dhilsfu/bep
DB_NAME: pipeline_db
DB_USER: pipeline_user
DB_PASSWORD: pipeline_password


jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
# - linux/386
- linux/amd64
# - linux/arm/v5
- linux/arm/v7
- linux/arm64
# - linux/mips64le
# - linux/ppc64le
# - linux/s390x
steps:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Checkout source code
uses: actions/checkout@v4

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ env.PLATFORM_PAIR }}
cache-to: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ env.PLATFORM_PAIR }},mode=max

- name: Shutdown Ubuntu MySQL (SUDO)
run: sudo service mysql stop

- name: Set up MariaDB
uses: getong/[email protected]
with:
mysql database: ${{ env.DB_NAME }}_test
mysql user: ${{ env.DB_USER }}
mysql password: ${{ env.DB_PASSWORD }}

- name: Run Unit Tests
run: |
touch .env.test.local
echo DATABASE_URL="mysql://${{ env.DB_USER }}:${{ env.DB_PASSWORD }}@127.0.0.1:3306/${{ env.DB_NAME }}?serverVersion=mariadb-10.11.0" >> .env.test.local
docker run --rm \
-v "${GITHUB_WORKSPACE}/.env.test.local":/var/www/html/.env.test.local \
--network host \
--platform=${{ matrix.platform }} \
${{ env.REGISTRY_IMAGE }}@${{ steps.build.outputs.digest }} make test
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

push:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
- name: Trigger Gitlab Deploy Job
run: |
curl -X POST \
--fail \
-F token=${{ secrets.GITLAB_CI_TOKEN }} \
-F "ref=main" \
-F "variables[APP_RELEASE_TAG]=${{github.ref_name}}" \
https://git.lib.sfu.ca/api/v4/projects/569/trigger/pipeline
37 changes: 18 additions & 19 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,36 @@
/vendor/
###< symfony/framework-bundle ###

###> symfony/phpunit-bridge ###
.phpunit
.phpunit.result.cache
/phpunit.xml
###< symfony/phpunit-bridge ###

###> phpunit/phpunit ###
/phpunit.xml
.phpunit.result.cache
.phpunit.cache/
coverage/
###< phpunit/phpunit ###

###> friendsofphp/php-cs-fixer ###
/.php-cs-fixer.php
/.php-cs-fixer.cache
###< friendsofphp/php-cs-fixer ###

# Editors
/.idea
/public/yarn
.vscode

# Bundles
/public/js/jquery.collection.js
/templates/jquery.collection.html.twig

# deployment
/config/deploy.yaml
# Yarn packages.
node_modules

# backups
*.sql
# Docker
.data

# public things managed by other things.
/public/dev
/public/docs
/public/images/blog
/public/js/jquery.collection.js
# MISC
/*.sql
/data
/src/.preload.php

# Code coverage and QA reports
public/dev

# Mac DS_Store
.DS_Store
8 changes: 0 additions & 8 deletions .gitmodules

This file was deleted.

25 changes: 6 additions & 19 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<?php

$header = <<<'HEADER'
(c) 2022 Michael Joyce <[email protected]>
This source file is subject to the GPL v2, bundled
with this source code in the file LICENSE.
HEADER;

$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
Expand All @@ -25,8 +19,8 @@
'@PhpCsFixer' => true,
'@PSR2' => true,

'@PHP74Migration' => true,
'@PHP74Migration:risky' => true,
'@PHP82Migration' => true,
'@PHP80Migration:risky' => true,

'align_multiline_comment' => [
'comment_type' => 'all_multiline',
Expand All @@ -37,14 +31,10 @@
'backtick_to_shell_exec' => true,
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true,
// 'blank_line_before_statement' => [
// 'statements' => [
// 'declare', 'die', 'exit', 'for', 'foreach', 'return', 'try',
// ]
// ],
'braces' => [
'allow_single_line_closure' => true,
'position_after_functions_and_oop_constructs' => 'same'

'curly_braces_position' => [
'classes_opening_brace' => 'same_line',
'functions_opening_brace' => 'same_line',
],

'cast_spaces' => [
Expand Down Expand Up @@ -77,9 +67,6 @@
'import_functions' => false,
],

'header_comment' => [
'header' => $header,
],
'heredoc_to_nowdoc' => true,

'implode_call' => true,
Expand Down
1 change: 0 additions & 1 deletion .yarnrc

This file was deleted.

33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM node:21.6-slim AS bep-prod-assets
WORKDIR /app

RUN apt-get update \
&& apt-get install -y git \
&& npm upgrade -g npm \
&& npm upgrade -g yarn \
&& rm -rf /var/lib/apt/lists/*

# build js deps
COPY public/package.json public/yarn.lock /app/

RUN yarn --production \
&& yarn cache clean


FROM dhilsfu/symfony-base:php-8.2-apache AS bep
ENV GIT_REPO=https://github.com/sfu-dhil/bep

# basic deps installer (no script/plugings)
COPY --chown=www-data:www-data --chmod=775 composer.json composer.lock /var/www/html/
RUN composer install --no-scripts

# copy project files and install all symfony deps
COPY --chown=www-data:www-data --chmod=775 . /var/www/html
# copy webpacked js and libs
COPY --chown=www-data:www-data --chmod=775 --from=bep-prod-assets /app/node_modules /var/www/html/public/node_modules

RUN mkdir -p data/prod data/dev data/test var/cache/prod var/cache/dev var/cache/test var/sessions var/log \
&& chown -R www-data:www-data data var \
&& chmod -R 775 data var \
&& composer install \
&& ./bin/console cache:clear
Loading

0 comments on commit f0da7d3

Please sign in to comment.