Skip to content

Commit

Permalink
refactor: De-umbrella this application (#1845)
Browse files Browse the repository at this point in the history
Additional changes of note:
* Remove distillery in favor of native Elixir releases
* Refactors the configuration files, uses `runtime.exs` now
* Updates excoveralls, adds file info to coverage output
* Adds a suite of smoke tests, which
* Deprecates the Elixir tests which use Wallaby
  • Loading branch information
thecristen authored Jan 10, 2024
1 parent e31cb32 commit 0dd9b30
Show file tree
Hide file tree
Showing 4,248 changed files with 4,057 additions and 6,602 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ deps
erl_crash.dump
build.sh
deploy.sh
apps/site/priv/static
priv/static
aws
site-build.zip
dotcom-build.zip
bin
Dockerfile
.dockerignore
4 changes: 1 addition & 3 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
[
inputs: [
"mix.exs",
"apps/*/mix.exs",
"apps/*/{config,lib,test}/**/*.{ex,exs}",
"config/**/*.{ex,exs}",
"{config,lib,test}/**/*.{ex,exs}",
"rel/**/*.{ex,exs}"
]
]
24 changes: 12 additions & 12 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
* @mbta/dotcom

# CMS-related code
/apps/cms/ @mbta/dotcom @amaisano
site/content_rewriter.ex @mbta/dotcom @amaisano
site/content_rewriters/ @mbta/dotcom @amaisano
site_web/controllers/cms_controller.ex @mbta/dotcom @amaisano
site_web/views/cms_view.ex @mbta/dotcom @amaisano
site_web/views/page_content_view.ex @mbta/dotcom @amaisano
site_web/views/paragraph_view.ex @mbta/dotcom @amaisano
site_web/views/partial_view.ex @mbta/dotcom @amaisano
site_web/views/teaser_view.ex @mbta/dotcom @amaisano
site_web/views/helpers/cms_helpers.ex @mbta/dotcom @amaisano
site_web/views/helpers/cms_router_helpers.ex @mbta/dotcom @amaisano
site_web/templates/cms/ @mbta/dotcom @amaisano
cms/ @mbta/dotcom @amaisano
dotcom/content_rewriter.ex @mbta/dotcom @amaisano
dotcom/content_rewriters/ @mbta/dotcom @amaisano
dotcom_web/controllers/cms_controller.ex @mbta/dotcom @amaisano
dotcom_web/views/cms_view.ex @mbta/dotcom @amaisano
dotcom_web/views/page_content_view.ex @mbta/dotcom @amaisano
dotcom_web/views/paragraph_view.ex @mbta/dotcom @amaisano
dotcom_web/views/partial_view.ex @mbta/dotcom @amaisano
dotcom_web/views/teaser_view.ex @mbta/dotcom @amaisano
dotcom_web/views/helpers/cms_helpers.ex @mbta/dotcom @amaisano
dotcom_web/views/helpers/cms_router_helpers.ex @mbta/dotcom @amaisano
dotcom_web/templates/cms/ @mbta/dotcom @amaisano
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
* [ ] **Other accessibility checks** such as sufficient [color constrast](https://thinkdobecreate.com/articles/4-required-tests-before-shipping-new-features/#color-contrast), or whether the layout holds up at 200% [zoom level](https://thinkdobecreate.com/articles/4-required-tests-before-shipping-new-features/#visible-focus).

#### New endpoints, or non-trivial changes to current endpoints
* [ ] **Have we load-tested** any new pages or internal API endpoints that will receive significant traffic? [See load testing docs](./../apps/site/load_tests/README.md)
* [ ] **Have we load-tested** any new pages or internal API endpoints that will receive significant traffic? [See load testing docs](./../load_tests/README.md)
* [ ] **If this change involves routes,** does it work correctly with pertinent "unusual" routes such as the combined Green Line, Silver Line, Foxboro commuter rail, and single-direction bus routes like the 170?

4 changes: 2 additions & 2 deletions .github/actions/build-app/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ runs:
with:
path: |
_build
apps/site/priv
apps/site/react_renderer/dist/app.js
priv
react_renderer/dist/app.js
key: ci-application-cache-${{ github.sha }}
id: build-cache

Expand Down
6 changes: 3 additions & 3 deletions .github/actions/setup-all/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ runs:
- name: Restore cache of Node dependencies from package-lock.json
uses: actions/cache@v3
with:
path: apps/site/assets/node_modules
key: ci-nodejs-cache-${{ hashFiles('apps/site/assets/package-lock.json') }}
path: assets/node_modules
key: ci-nodejs-cache-${{ hashFiles('assets/package-lock.json') }}
id: node-cache

- name: Restore Cypress cache
uses: actions/cache@v3
with:
path: ~/.cache/Cypress
key: ci-cypress-${{ hashFiles('apps/site/assets/package-lock.json') }}
key: ci-cypress-${{ hashFiles('assets/package-lock.json') }}

- name: Install Node dependencies (if needed)
if: ${{ steps.node-cache.outputs.cache-hit != 'true' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ updates:
time: "09:00"
open-pull-requests-limit: 1
- package-ecosystem: "npm" # See documentation for possible values
directory: "/apps/site/assets" # Location of package manifests
directory: "assets" # Location of package manifests
schedule:
interval: "daily"
time: "09:00"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/algolia-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ jobs:
- uses: actions/cache/restore@v3
with:
path: deps
key: ci-mix-cache-${{ hashFiles('**/mix.lock') }}
key: ci-mix-cache-${{ hashFiles('mix.lock') }}
restore-keys: ci-mix-cache-
# the running application runs Webpack to render React stuff :(, so need NPM too
- uses: actions/cache/restore@v3
with:
path: apps/site/assets/node_modules
key: ci-nodejs-cache-${{ hashFiles('apps/site/assets/package-lock.json') }}
path: assets/node_modules
key: ci-nodejs-cache-${{ hashFiles('assets/package-lock.json') }}
restore-keys: ci-nodejs-cache-
- env:
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/changed-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ jobs:
echo "ex=true" >> $GITHUB_OUTPUT
else
changes () { git diff --name-only --diff-filter=ACDMRT ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} ; }
echo "js=$(changes | grep -E 'apps/site/assets/js/.*\.jsx?' | xargs)" >> $GITHUB_OUTPUT
echo "ts=$(changes | grep -E 'apps/site/assets/ts/.*\.tsx?' | xargs)" >> $GITHUB_OUTPUT
echo "scss=$(changes | grep -E 'apps/site/assets/css/.*\.scss' | xargs)" >> $GITHUB_OUTPUT
echo "js=$(changes | grep -E 'assets/js/.*\.jsx?' | xargs)" >> $GITHUB_OUTPUT
echo "ts=$(changes | grep -E 'assets/ts/.*\.tsx?' | xargs)" >> $GITHUB_OUTPUT
echo "scss=$(changes | grep -E 'assets/css/.*\.scss' | xargs)" >> $GITHUB_OUTPUT
echo "ex=$(changes | grep -E '.*(\.exs?|\.eex)' | xargs)" >> $GITHUB_OUTPUT
fi
- name: "List changed files:"
Expand Down
28 changes: 3 additions & 25 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ jobs:
with:
path: |
_build
apps/site/priv
apps/site/react_renderer/dist/app.js
priv
react_renderer/dist/app.js
key: ci-application-cache-${{ github.sha }}
- env:
RECAPTCHA_PUBLIC_KEY: 6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI
RECAPTCHA_PRIVATE_KEY: 6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe
REACT_BUILD_PATH: apps/site/react_renderer/dist/app.js
REACT_BUILD_PATH: react_renderer/dist/app.js
run: npm run ci:unit:exunit
- name: Upload coverage artifact
if: ${{ always() && github.event.pull_request }}
Expand Down Expand Up @@ -165,25 +165,3 @@ jobs:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-all
- run: npm run ci:format:ts

elixir_wallaby:
name: Integration tests / Elixir
runs-on: ubuntu-latest
needs: [file_changes, build_app]
if: ${{ needs.file_changes.outputs.any }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-all
- uses: actions/cache/restore@v3
with:
path: |
_build
apps/site/priv
apps/site/react_renderer/dist/app.js
key: ci-application-cache-${{ github.sha }}
- uses: mbta/setup-chromedriver@master
- env:
RECAPTCHA_PUBLIC_KEY: 6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI
RECAPTCHA_PRIVATE_KEY: 6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe
REACT_BUILD_PATH: apps/site/react_renderer/dist/app.js
run: npm run ci:integration:ex
15 changes: 14 additions & 1 deletion .github/workflows/use-deploy-ecs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ concurrency:

jobs:
deploy:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
Expand All @@ -39,6 +39,7 @@ jobs:
url: ${{ inputs.deployment-env == 'prod' && 'https://www.mbta.com' || format('https://{0}.mbtace.com', inputs.deployment-env) }}
outputs:
deployment-env: ${{ inputs.deployment-env }}
deployment-url: ${{ inputs.deployment-env == 'prod' && 'https://www.mbta.com' || format('https://{0}.mbtace.com', inputs.deployment-env) }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
Expand Down Expand Up @@ -95,6 +96,7 @@ jobs:

- uses: mbta/actions/deploy-ecs@v2
with:
role-to-assume: ${{ secrets.aws-role-arn }}
ecs-cluster: dotcom
ecs-service: dotcom-${{ inputs.deployment-env }}
docker-tag: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
Expand All @@ -108,3 +110,14 @@ jobs:
# environment: ${{ inputs.deployment-env }}
# projects: mbta-site
# version: ${{ needs.app.needs.assets.needs.image.outputs.docker-tag }}
smoke:
runs-on: ubuntu-latest
needs: deploy
name: Run Smoke Tests against new deployment
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-all
- run: npx --prefix assets cypress run --spec cypress/e2e/smoke.cy.js
env:
CYPRESS_BASE_URL: ${{ needs.deploy.outputs.deployment-url }}

48 changes: 45 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,57 @@ erl_crash.dump

# Elastic Beanstalk Files
.elasticbeanstalk/*
/site-build.zip
/dotcom-build.zip
ts-build
stats.json
npm-debug.log
/apps/news/posts.zip
doc/
coverage
/rel/app.js
cover/

.iex.exs
package-lock.json

# App artifacts
/_build
/cover
/db
/deps
/*.ez
/lib/css-styleguide-compiler-brunch/assets/node_modules
# Generate on crash by the VM
erl_crash.dump

# Cache files
/assets/.sass-cache/
/assets/namespaced_header_footer/.sass-cache/

# Files for compiled header and footer
/assets/namespaced_header_footer/compiled/
/priv/compiled_header_footer/*/*

# Static artifacts
node_modules

# compiled js file for react renderer server
/**/react_renderer/dist

# Since we are building assets from assets,
# we ignore priv/static. You may want to comment
# this depending on your deployment strategy.
/priv/static/

# The config/prod.secret.exs file by default contains sensitive
# data and you should not commit it into version control.
#
# Alternatively, you may comment the line below and commit the
# secrets file as long as you replace its contents by environment
# variables.
/config/prod.secret.exs

# Benchmark results
/bench/snapshots

# Wallaby screenshots
/screenshots
.VSCodeCounter
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# shellcheck disable=SC1091
. "$(dirname -- "$0")/_/husky.sh"

npx --prefix apps/site/assets lint-staged
npx --prefix assets lint-staged
25 changes: 10 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,27 @@ ARG SENTRY_DSN=""
# copy in Elixir deps required to build node modules for Phoenix
COPY --from=elixir-builder /root/deps /root/deps

ADD apps/site/assets /root/apps/site/assets
ADD ./assets /root/assets

WORKDIR /root/apps/site/assets/
WORKDIR /root/assets
RUN npm ci --ignore-scripts
# Create apps/site/priv/static
# Create priv/static
RUN npm run webpack:build -- --env SENTRY_DSN=$SENTRY_DSN
# Create apps/site/react_renderer/dist/app.js
# Create react_renderer/dist/app.js
RUN npm run webpack:build:react



# 3) now, build the application back in the Elixir container
FROM elixir-builder as app-builder

WORKDIR /root

# Add frontend assets compiled in the node container, required by phx.digest
COPY --from=assets-builder /root/apps/site/priv/static ./apps/site/priv/static
COPY --from=assets-builder /root/priv/static ./priv/static

# re-compile the application after the assets are copied, since some of them
# are built into the application (SVG icons)
RUN mix do compile, phx.digest
RUN mix distillery.release --verbose
RUN mix release


# 4) Use the nodejs container for the runtime environment
Expand All @@ -66,24 +64,21 @@ FROM node:18.17.1-buster-slim
# Set exposed ports
EXPOSE 4000

ENV PORT=4000 MIX_ENV="prod" TERM=xterm LANG="C.UTF-8" REPLACE_OS_VARS=true
ENV PORT=4000 MIX_ENV="prod" PHX_SERVER=true TERM=xterm LANG="C.UTF-8" REPLACE_OS_VARS=true

# erlang-crypto requires system library libssl1.1
RUN apt-get update && apt-get install -y --no-install-recommends \
libssl1.1 libsctp1 curl dumb-init \
libssl1.1 libsctp1 curl \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /root

COPY --from=app-builder /root/_build/prod/rel /root/rel
COPY --from=assets-builder /root/apps/site/react_renderer/dist/app.js /root/rel/site/app.js

ADD rel/bin/startup /root/rel/site/bin/startup
COPY --from=assets-builder /root/react_renderer/dist/app.js /root/rel/dotcom/app.js

RUN mkdir /root/work

WORKDIR /root/work

# run the application
ENTRYPOINT ["/usr/bin/dumb-init"]
CMD ["/root/rel/site/bin/startup", "foreground"]
CMD ["/root/rel/dotcom/bin/dotcom", "start"]
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The new face of https://www.mbta.com/.
We strive to support all users – but the variety of browsers, operating systems and devices available necessitates a more intentioned approach. Generally speaking, Dotcom supports the stable latest releases of all major web browsers (Chrome, Safari, Firefox, Microsoft Edge, and Internet Explorer 11) and platforms (Windows, MacOS, iOS, Android).
Other interfaces using the underlying engines of the aforementioned browsers – that's WebKit, Blink, Gecko – are not explicitly supported but are expected to function correctly.

From a development standpoint, polyfills and code transforms are implemented via [Babel](https://babeljs.io/docs/en/next/babel-preset-env.html#browserslist-integration) with the target browsers noted in [the site .browserslistrc](apps/site/assets/.browserslistrc).
From a development standpoint, polyfills and code transforms are implemented via [Babel](https://babeljs.io/docs/en/next/babel-preset-env.html#browserslist-integration) with the target browsers noted in [the site .browserslistrc](assets/.browserslistrc).


- [Getting Started](#getting-started)
Expand Down Expand Up @@ -107,9 +107,9 @@ Welcome to [Dotcom](https://www.notion.so/mbta-downtown-crossing/Dotcom-6aa7b0f0
```
npm run install
```
You won't see a `node_modules` folder at the root of this project -- this installs packages into `apps/site/assets`.
You won't see a `node_modules` folder at the root of this project -- this installs packages into `assets`.
Minor note - you may see a prompt to upgrade `npm`. This isn't needed, and `"lockfileVersion": 1` in our `apps/site/assets/package-lock.json` file means it was generated with an `npm` version prior to 7.
Minor note - you may see a prompt to upgrade `npm`. This isn't needed, and `"lockfileVersion": 1` in our `assets/package-lock.json` file means it was generated with an `npm` version prior to 7.
1. Build the project:
```
Expand Down Expand Up @@ -165,8 +165,3 @@ New to the team, or looking for further developer resources?
- [Intro to the V3 API](https://github.com/mbta/wiki/blob/master/api/intro.md): a starter guide to the data model with links to relevant API resources.
- [Dotcom Engineering Guide](https://docs.google.com/document/d/1Vg-8-APtBk7JYuj0TgWvcrWjU5mEA9vCk58aaJgq02Q/edit): a more comprehensive look at the Dotcom ecosystem, the V3 API Data Model, and other project info.
- Documentation for some [features that have come and gone](docs/SeasonalFeatures.md).
### Nested Applications
- [Feedback](apps/feedback/README.md)
- [TripPlan](apps/trip_plan/README.md)
6 changes: 0 additions & 6 deletions apps/alerts/.gitignore

This file was deleted.

Loading

0 comments on commit 0dd9b30

Please sign in to comment.