Skip to content

Commit

Permalink
Symfony and Bootstrap 5 upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-gardener committed Jun 6, 2024
1 parent c088169 commit 5537fca
Show file tree
Hide file tree
Showing 321 changed files with 10,890 additions and 9,445 deletions.
49 changes: 49 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
###> 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
/.github/

#docs
public/docs
8 changes: 4 additions & 4 deletions .env
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ MAILER_DSN=null://null
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# For a PostgreSQL database, use: "postgresql://db_user:[email protected]:5432/db_name?serverVersion=11&charset=utf8"
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
DATABASE_URL=mysql://db_user:[email protected]:3306/db_name?serverVersion=5.7
DATABASE_URL=mysql://btd:password@db:3306/btd?serverVersion=mariadb-10.11.0
###< doctrine/doctrine-bundle ###

# Routing information
ROUTE_PROTOCOL=http
ROUTE_HOST=localhost
ROUTE_BASE=/btd
ROUTE_BASE=

# Piwik
MATOMO_ENABLED=${-:false}
MATOMO_ENABLED=false

# BTD specific
UPLOAD_PATH=data/uploads
UPLOAD_PATH=/uploads
151 changes: 151 additions & 0 deletions .github/workflows/main.yml
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/btd
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/572/trigger/pipeline
56 changes: 31 additions & 25 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,39 @@
/vendor/
###< symfony/framework-bundle ###

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

# Temporary while doing the upgrade.
/old
###> phpunit/phpunit ###
.phpunit.cache/
coverage/
###< phpunit/phpunit ###

# documentation
/docs/src/build
/web/docs
###> friendsofphp/php-cs-fixer ###
/.php-cs-fixer.cache
###< friendsofphp/php-cs-fixer ###

# PHPStorm config.
# Editors
/.idea
.yarn-integrity
public/yarn
config/deploy.yml
*.sql
data/uploads
config/deploy.yaml
public/docs
src/.preload.php
.vscode

###> phpunit/phpunit ###
/phpunit.xml
.phpunit.result.cache
###< phpunit/phpunit ###
# Bundles
/public/js/jquery.collection.js
/templates/jquery.collection.html.twig

Makefile.local
# Yarn packages.
node_modules

# Docker
.data

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

# Code coverage and QA reports
public/dev

# Mac DS_Store
.DS_Store

#docs
public/docs
25 changes: 6 additions & 19 deletions .php-cs-fixer.dist.php → .php-cs-fixer.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.

45 changes: 45 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM python:3.12-slim AS btd-docs
WORKDIR /app

# build python deps
COPY docs/requirements.txt /app/
RUN pip install -r requirements.txt

COPY docs /app

RUN sphinx-build source _site

FROM node:21.6-slim AS btd-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 btd
ENV GIT_REPO=https://github.com/sfu-dhil/btd

# 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=btd-prod-assets /app/node_modules /var/www/html/public/node_modules
# copy docs
COPY --chown=www-data:www-data --chmod=775 --from=btd-docs /app/_site /var/www/html/public/docs/sphinx

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 5537fca

Please sign in to comment.