Mozilla Foundation website
moz
Перейти к файлу
Simon Fessehaye f770d8186f Added endofline settings to workspace 2021-06-29 12:24:59 -06:00
.devcontainer Replace Alpine by Debian stretch slim for Docker local dev (#3253) 2019-07-03 12:17:35 +02:00
.github Update dependabot.yml 2021-06-07 09:24:26 -07:00
.vscode Added endofline settings to workspace 2021-06-29 12:24:59 -06:00
bin Add helper command to extract strings to an external repo (#4199) 2020-02-19 15:53:44 +01:00
cypress uplift cypress to 6.9.1 (#6638) 2021-05-05 08:21:01 -07:00
dockerfiles updated wagtailinventory to a custom version that fixes its own bug (#6164) 2021-02-04 16:05:59 -08:00
docs Upgrade django to 3 and wagtail to 2.12 (#6715) 2021-05-20 10:14:27 -06:00
maintenance 6564 - Make sure we are loading italic font styles from Google & update /style-guide to include examples (#6895) 2021-06-21 09:19:16 -06:00
network-api Don't verify SSL certificate for Redis connections (#6937) 2021-06-25 08:06:57 -06:00
source Refactor glyphs mixins 2021-06-23 16:50:27 -06:00
test updated the test url list to all urls (#6718) 2021-05-19 10:18:51 -07:00
.editorconfig Update HTTP to HTTPS (#2219) 2018-11-20 16:38:36 -08:00
.eslintignore Nuke Pug (#1468) 2018-04-27 10:17:12 -07:00
.eslintrc.a11y.json Add 'eslint-plugin-jsx-a11y' and set violation to raise 'warning' for now (#4338) 2020-03-12 16:39:58 -07:00
.eslintrc.json remove 'eslint-config-prettier' (#6328) 2021-03-08 10:24:43 -08:00
.gitignore Added endofline settings to workspace 2021-06-29 12:24:59 -06:00
.mergify.yml remove last mentions of, and vestigial files relating to, Travis CI (#6641) 2021-05-18 09:40:24 -07:00
.prettierignore Added endofline settings to workspace 2021-06-29 12:24:59 -06:00
.prettierrc Added endofline settings to workspace 2021-06-29 12:24:59 -06:00
.stylelintrc Remove 'color-hex-length' stylelint rule since we don't allow color code in all files other than _colors.scss (#4744) 2020-06-04 19:28:22 +00:00
.stylelintrc-colors.js Update a deprecated stylelint rule name (#6021) 2021-01-13 16:59:28 -08:00
CODEOWNERS Template localization (#3529) 2019-11-14 11:18:26 -08:00
CODE_OF_CONDUCT.md Update CODE_OF_CONDUCT.md (#3054) 2019-04-30 09:10:45 +02:00
ISSUE.md adding github issue template (#484) 2017-06-05 09:41:02 -07:00
LICENSE Update HTTP to HTTPS (#2219) 2018-11-20 16:38:36 -08:00
Procfile Gunicorn perf redux (#4530) 2020-04-20 10:02:06 -04:00
README.md remove last mentions of, and vestigial files relating to, Travis CI (#6641) 2021-05-18 09:40:24 -07:00
app.json Bump django-cors-headers from 3.4.0 to 3.5.0 (#5154) 2020-09-16 14:24:34 -07:00
contribute.json Update contribute.json (#3496) 2019-08-06 08:11:45 -07:00
cypress.json Add MozFest homepage and primary page to Percy test (#3951) 2019-11-26 19:16:30 -08:00
dev-requirements.in adding ptvsd 2020-05-13 17:05:44 +02:00
dev-requirements.txt Wagtail 2.12.5 (#6922) 2021-06-23 16:10:57 -07:00
docker-compose.yml mild improvements to docker-compose.yml (#6680) 2021-05-11 13:26:55 -07:00
env.default quote unsafe-inline targets (#6574) 2021-05-03 10:54:38 -07:00
esbuild.config.js explicit target names for esbuild source (#6277) 2021-03-01 09:56:36 -08:00
esbuild.react.shim.js Replace webpack+babel with esbuild (#6230) 2021-02-23 10:44:11 -08:00
invoke.yaml Simplify docker invoke tasks (#3673) 2019-09-23 10:59:38 +02:00
package-lock.json Upgrade django to 3 and wagtail to 2.12 (#6715) 2021-05-20 10:14:27 -06:00
package.json improve local dev workflow (#6681) 2021-05-13 12:48:52 -06:00
postcss.config.js Replace webpack+babel with esbuild (#6230) 2021-02-23 10:44:11 -08:00
release-steps.sh Add a release steps file (#2240) 2018-11-22 12:26:51 +01:00
requirements.in Wagtail 2.12.5 (#6922) 2021-06-23 16:10:57 -07:00
requirements.txt Wagtail 2.12.5 (#6922) 2021-06-23 16:10:57 -07:00
runtime.txt update to python 3.7.8 (#4968) 2020-07-27 16:12:31 +00:00
tasks.py updated task name and all references, also added alias (#6684) 2021-05-13 08:48:06 -07:00
tox.ini Remove extra semicolon + add tasks file to lint check + move tox.ini to top-level dir (#1799) 2018-09-11 12:28:47 -07:00
translation-management.sh Localize RegretsReporter landing page (#6623) 2021-05-04 10:08:20 -07:00

README.md

foundation.mozilla.org

Dependency Status Dev Dependency Status Uses Mofo Standards Code Coverage

Table of contents

Setup

Setup with Docker

Local development

Engineer Workflow

OPS and Heroku Settings

Scheduled Task

Stack

How to Setup your Dev Environment with Docker

Requirements: Docker Desktop (macOS and Windows) or Docker CE and Docker Compose (Linux), invoke, and git.

Installing Invoke

We recommend that you install Invoke using pipx.

Check your environment

  • docker run hello-world.
  • invoke --version should return 0.22.1 or higher.

Setup steps

Run the following terminal commands to get started:

  • git clone https://github.com/mozilla/foundation.mozilla.org.git
  • cd foundation.mozilla.org
  • inv new-env

You're done 🎉

This task creates a .env that is in charge of managing your environment variables while running Docker. The installation will take a few minutes: you need to download images from the Docker Hub, install JS and Python dependencies, create fake data, migrate your database, etc.

When it's done, run docker-compose up, wait until the static files to be built, and go to 0.0.0.0:8000. You should have a local working version of the foundation site with fake data. When you want to stop, do ^C to shut down your containers.

To log into the admin site, a superuser will have been created with username admin with password admin.

To catch up on new dependencies, migrations, etc. after initial setup, you can use the inv catch-up command. To get a full new environment with a new database, run inv new-env again.

Use inv -l to get a list of all the available invoke commands.

More information on how to work with Docker and how to manage Python dependencies are available in the local development part of the documentation.

Testing

Code tests

When relevant, we encourage you to write tests. You can run the tests using inv test, or you can run the Node and Python testing suites separately:

  • Run Node tests: inv test-node
  • Run Python tests: inv test-python

Fixing linting errors

If inv test-node shows linting errors for either JS/JSX or CSS/SCSS, you can run the inv npm "run fix" command to make the linting utilities automatically fix (or at least try to fix) any errors they knows how to fix. This will almost always be the only step required to ensure the linting phase of testing passes.

Visual regression tests

In addition to the code tests there are also visual regression tests, located in the ./cypress/integration directory. You can run these tests locally by installing cypress using npm i cypress@3.0.3, after which the command npm run cypress will run these tests locally. However, note that these tests are currently intended for screenshot comparisons across branches, and so will not yield any meaningful results when run for a single branch.

Accessibility tests (a11y tests)

Accessibility tests are not part of the standard tests covered by inv test. You can run them locally by running npm install and npm run cypress:install once, after which the following command will run the a11y testing:

  • npm run cypress:a11y

Note that when tests fail, the ./cypress/screenshots directory will contain one screenshot for each failed test.

Mozilla Festival

The fake data generator can generate a site structure for the Mozilla Festival that can be served under it's own domain, or in the case of review apps on Heroku, where we're limited to a single domain, as a sub-directory of the main foundation site, at {review_app_host}/mozilla-festival.

In order to access the Mozilla Festival site locally on a different domain than the main Foundation site, you'll need to edit your hosts file (/etc/hosts on *nix systems, C:\Windows\System32\Drivers\etc\hosts on Windows) to allow you to access the site at mozfest.localhost:8000. To enable this, add the following line to your hosts file: 127.0.0.1 mozfest.localhost

Gotchas

As this is REST API and CMS built on top of Django, there are some "gotcha!"s to keep in mind due to the high level of magic in the Django code base (where things will happen automatically without the code explicitly telling you).

DEBUG=True

The DEBUG flag does all sorts of magical things, to the point where testing with debugging turned on effectively runs a completely different setup compared to testing with debugging turned off. When debugging is on, the following things happen:

  • Django bypasses the ALLOWED_HOST restrictions, which again can lead to 400 Bad Request errors in DEBUG=False setting.
  • Rather than HTTP error pages, Django will generate stack traces pages that expose pretty much all environment variables except any that match certain substrings such as KEY, PASS, etc. for obvious security reasons.
  • ...there are probably more gotchas just for DEBUG so if you find any please add them to this list.

Translations

Translations of UI strings (from the Django and React apps) are stored in the fomo-l10n repository. Translations are happening in Pontoon, in multiple projects: Foundation website, *Privacy Not Included and Mozilla Festival.

The latest source strings are regularly exposed to Pontoon by a Localization PM using the following process:

Initial setup:

  • Clone the fomo-l10n repository locally.
  • Set the LOCAL_PATH_TO_L10N_REPO variable in your .env file. Use the absolute path to your copy of the fomo-l10n repository and include the trailing slash. E.g. LOCAL_PATH_TO_L10N_REPO=/Users/username/Documents/GitHub/fomo-l10n/

Exposing latest source strings:

  • Make sure your local repositories of fomo-l10n and foundation.mozilla.org are matching the latest revision from master.
  • Run inv docker-makemessages from your foundation.mozilla.org repository.
  • Files should have been updated in your fomo-l10n repository. You can now create a pull-request.

Getting the latest translations for local dev

Latest translations are uploaded to S3. To get them, run:

  • curl -o translations.tar https://foundation-site-translations.s3.amazonaws.com/translations.tar
  • tar -C network-api -xvf translations.tar

You don't need to run compilemessages and it works for both pipenv or docker workflows.

The translations_github_commit_[...] file from the archive is only used for debug purposes on Heroku. It can be safely deleted if needed.

Contributing

We love contributors, but the team maintaining this project is small and not structured to significantly support new and inexperienced contributors. If there's an unassigned issue that catches your eye, feel free to open a PR for it, but keep in mind our support will be limited. We usually don't have the capacity to walk you through the process of spinning up the project, opening a PR or describing what the solution to the issue could be.