Skip to content

Commit

Permalink
Convert to Symfony and use ToolforgeBundle
Browse files Browse the repository at this point in the history
This is more or less a rewrite, but visually nothing should have
changed. Moving to Symfony and using ToolforgeBundle makes the app more
maintainable, especially for Community Tech (the maintaining team).

All controller actions are now in a single class, AppController. From
here, we build Record objects that get pass to the views. Just as with
before, there are separate classes to communicate with the db and APIs,
now called CopyPatrolRepository and WikiRepository.

Summary of other changes:
* Add .editorconfig
* Use .env.local in local envs, with .env as the template
* Add .nvmrc
* Covert JS to ES6 and use Webpack Encore
* Remove old browser-prefixed rules from the LESS
* Rename status values to work with new bot/schema
* Update all PHP dependencies, remove those we don't need
* Remove code that now lives in ToolforgeBundle
* Remove unused messages from i18n
* Use NPM releases of bootstrap and jquery, and only include the
  parts that we need.
* Remove Select2 JS library as we're not using it anymore
* Do all validations server-side and not just in the JS
* Add caching to main DB queries and HTTP requests
* Convert the data structure for the view in to a Record model
* Fetch WikiProjects at the same time as redlink status of page titles
* Add stylelint and fix violations
* Add integration tests
* Other various code cleanup

This rewrite does NOT check against the user allowlist and auto-mark
records for users who are on it. That job is going to be moved to the
bot. See T341726.

Bug: T340600
  • Loading branch information
MusikAnimal committed Jul 19, 2023
1 parent 2732713 commit f13fcdc
Show file tree
Hide file tree
Showing 285 changed files with 20,734 additions and 13,149 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# https://EditorConfig.org

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

# tab indentation
[*.{php,js,less,twig}]
indent_style = tab
indent_size = 4
47 changes: 47 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=666e4642f204738f71997c183bb4735e
###< symfony/framework-bundle ###

# Credentials for Toolforge replicas
REPLICAS_USERNAME=
REPLICAS_PASSWORD=
REPLICAS_HOST_S1=127.0.0.1
REPLICAS_HOST_S2=127.0.0.1
REPLICAS_HOST_S3=127.0.0.1
REPLICAS_HOST_S4=127.0.0.1
REPLICAS_HOST_S5=127.0.0.1
REPLICAS_HOST_S6=127.0.0.1
REPLICAS_HOST_S7=127.0.0.1
REPLICAS_HOST_S8=127.0.0.1
REPLICAS_PORT_S1=4711
REPLICAS_PORT_S2=4712
REPLICAS_PORT_S3=4713
REPLICAS_PORT_S4=4714
REPLICAS_PORT_S5=4715
REPLICAS_PORT_S6=4716
REPLICAS_PORT_S7=4717
REPLICAS_PORT_S8=4718

# Credentials for CopyPatrol database
TOOLSDB_HOST=127.0.0.1
TOOLSDB_PORT=4720
TOOLSDB_USERNAME=
TOOLSDB_PASSWORD=
COPYPATROL_DB_NAME=s52615__copypatrol_migrate_test_02_p

# OAuth credentials
OAUTH_URL='https://meta.wikimedia.org/w/index.php?title=Special:OAuth'
OAUTH_KEY=
OAUTH_SECRET=

# iThenticate credentials
ITHENTICATE_USERNAME=
ITHENTICATE_PASSWORD=

# App configuration
APP_ENABLED_LANGS=ar,en,es,fr,simple
APP_NOTICE_TEXT=
APP_NOTICE_STYLE=

LOGGED_IN_USER=
28 changes: 28 additions & 0 deletions .env.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Production overrides.
# Passwords and other credentials go in .env.prod.local

APP_ENV=prod

# Wikimedia Cloud Services
TRUSTED_PROXIES=172.16.0.0/21

REPLICAS_HOST_S1=s1.web.db.svc.wikimedia.cloud
REPLICAS_HOST_S2=s2.web.db.svc.wikimedia.cloud
REPLICAS_HOST_S3=s3.web.db.svc.wikimedia.cloud
REPLICAS_HOST_S4=s4.web.db.svc.wikimedia.cloud
REPLICAS_HOST_S5=s5.web.db.svc.wikimedia.cloud
REPLICAS_HOST_S6=s6.web.db.svc.wikimedia.cloud
REPLICAS_HOST_S7=s7.web.db.svc.wikimedia.cloud
REPLICAS_HOST_S8=s8.web.db.svc.wikimedia.cloud
REPLICAS_PORT_S1=3306
REPLICAS_PORT_S2=3306
REPLICAS_PORT_S3=3306
REPLICAS_PORT_S4=3306
REPLICAS_PORT_S5=3306
REPLICAS_PORT_S6=3306
REPLICAS_PORT_S7=3306
REPLICAS_PORT_S8=3306

TOOLSDB_HOST=tools.db.svc.wikimedia.cloud
TOOLSDB_PORT=3306
COPYPATROL_DB_NAME=s52615__copypatrol_migrate_test_02_p
37 changes: 37 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 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

# Credentials for Toolforge replicas
REPLICAS_USERNAME=
REPLICAS_PASSWORD=
REPLICAS_HOST_S1=127.0.0.1
REPLICAS_HOST_S2=127.0.0.1
REPLICAS_HOST_S3=127.0.0.1
REPLICAS_HOST_S4=127.0.0.1
REPLICAS_HOST_S5=127.0.0.1
REPLICAS_HOST_S6=127.0.0.1
REPLICAS_HOST_S7=127.0.0.1
REPLICAS_HOST_S8=127.0.0.1
REPLICAS_PORT_S1=4711
REPLICAS_PORT_S2=4712
REPLICAS_PORT_S3=4713
REPLICAS_PORT_S4=4714
REPLICAS_PORT_S5=4715
REPLICAS_PORT_S6=4716
REPLICAS_PORT_S7=4717
REPLICAS_PORT_S8=4718

# Credentials for CopyPatrol database
TOOLSDB_HOST=127.0.0.1
TOOLSDB_PORT=4720
TOOLSDB_USERNAME=
TOOLSDB_PASSWORD=
COPYPATROL_DB_NAME=s52615__copypatrol_migrate_test_02_p

APP_ENABLED_LANGS=ar,en,es,fr,simple
APP_NOTICE_TEXT=
APP_NOTICE_STYLE=
31 changes: 0 additions & 31 deletions .env_example

This file was deleted.

27 changes: 27 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = {
extends: [
'wikimedia',
'wikimedia/language/es2019'
],
rules: {
'no-alert': 0
},
parserOptions: {
sourceType: 'module'
},
env: {
browser: true,
node: true,
es6: true
},
globals: {
$: true,
jsUnauthorized: true,
jsDbError: true,
jsUndoOwnOnly: true,
jsUnknownError: true,
jsLoadMore: true,
jsNoMore: true,
wikiLang: true
}
};
18 changes: 0 additions & 18 deletions .github/dependabot.yml

This file was deleted.

9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ jobs:
extensions: json
tools: composer
- run: composer update
- run: composer test
- run: |
composer validate
./vendor/bin/phpcs -s .
./bin/console lint:twig ./templates
./bin/console lint:yaml ./config
./vendor/bin/minus-x check .
./bin/phpunit --exclude-group=integration
build_image:
name: Build Docker image
runs-on: ubuntu-latest
Expand Down Expand Up @@ -87,7 +93,6 @@ jobs:
run: |
docker load --input /tmp/copypatrol-${{ matrix.targets.name }}.image.tar
docker image ls -a
- name: Dive
uses: yuichielectric/[email protected]
with:
Expand Down
49 changes: 24 additions & 25 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
.DS_Store
.lighttpd.conf
.htaccess
.viminfo
.my.cnf
.env
.*_history
.bash*
*.log
tmp/
/vendor/
/cache/*
src/Less/cache/*
fill_patroller/
flask-mwoauth/
.composer/
.npm/
.idea/
.local/
.subversion/
.kube/
replica.my.cnf
service.manifest
restart_webservice.sh
deploy.sh
!.gitkeep

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

###> squizlabs/php_codesniffer ###
/.phpcs-cache
###< squizlabs/php_codesniffer ###

###> symfony/webpack-encore-bundle ###
/node_modules/
npm-debug.log
yarn-error.log
###< symfony/webpack-encore-bundle ###

###> symfony/phpunit-bridge ###
.phpunit.result.cache
/phpunit.xml
###< symfony/phpunit-bridge ###
33 changes: 0 additions & 33 deletions .jshintrc

This file was deleted.

1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14.17.0
7 changes: 7 additions & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "stylelint-config-wikimedia",
"rules": {
"color-named": null,
"declaration-property-unit-disallowed-list": null
}
}
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ RUN apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Add rewrite rules
RUN echo 'url.rewrite-if-not-file += ( "(.*)" => "/index.php/$0" )' >> /etc/lighttpd/conf-enabled/90-copypatrol.conf
RUN echo 'url.rewrite-if-not-file += ( "^(/.*)" => "/index.php$0" )' >> /etc/lighttpd/conf-enabled/90-copypatrol.conf

## Only these two copy statements below actually matter. Everything before this was
## just to set up a Toolforge-like environment for local development.
Expand All @@ -47,9 +47,9 @@ COPY --from=dependencies ${COPYPATROL_ROOT}/vendor ${COPYPATROL_ROOT}/vendor
# Copy files
COPY . ${COPYPATROL_ROOT}

# Symlink CopyPatrol public_html to document root
# Symlink CopyPatrol public to document root
RUN rm -rf /var/www/html
RUN ln -s ${COPYPATROL_ROOT}/public_html /var/www/html
RUN ln -s ${COPYPATROL_ROOT}/public /var/www/html

# Set start command (enable FastCGI and start lighttpd)
CMD [ "lighttpd", "-D", "-f", "/etc/lighttpd/lighttpd.conf" ]
Expand Down
Loading

0 comments on commit f13fcdc

Please sign in to comment.