-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
30 changed files
with
3,912 additions
and
757 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[flake8] | ||
ignore = E501,E731,W503 | ||
exclude = | ||
.chalice | ||
.venv |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
* @skaplan-dev | ||
deploy.sh @devinmatte @nathan-weinberg | ||
.github @devinmatte @nathan-weinberg | ||
.flake8 @devinmatte @nathan-weinberg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## Motivation | ||
|
||
<!-- Why are you making this change, what problem does it solve? Include links to relevant issues --> | ||
|
||
## Changes | ||
|
||
<!-- What does this change exactly? Include relevant screenshots, videos, links --> | ||
|
||
## Testing Instructions | ||
|
||
<!-- How can the reviewer confirm these changes do what you say they do? --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
ci/cd: | ||
- .github/**/* | ||
- deploy.sh | ||
|
||
dependencies: | ||
- package.json | ||
- package-lock.json | ||
|
||
documentation: | ||
- README.md | ||
- LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: deploy | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: ["20"] | ||
env: | ||
AWS_PROFILE: transitmatters | ||
AWS_DEFAULT_REGION: us-east-1 | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
TM_LABS_WILDCARD_CERT_ARN: ${{ secrets.TM_LABS_WILDCARD_CERT_ARN }} | ||
MBTA_V3_API_KEY: ${{ secrets.MBTA_V3_API_KEY }} | ||
DD_API_KEY: ${{ secrets.DD_API_KEY }} | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.12 | ||
- name: Install Poetry | ||
run: | | ||
curl -sSL https://install.python-poetry.org | python3 - | ||
- name: Set up Node ${{ matrix.node-version }}.x | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Set up CI Cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.npm | ||
${{ github.workspace }}/.next/cache | ||
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}- | ||
- name: Check if package-lock.json is up to date | ||
run: | | ||
npx --yes [email protected] | ||
- name: Generate AWS profile | ||
run: | | ||
mkdir ~/.aws | ||
cat >> ~/.aws/credentials << EOF | ||
[$AWS_PROFILE] | ||
aws_access_key_id = $AWS_ACCESS_KEY_ID | ||
aws_secret_access_key = $AWS_SECRET_ACCESS_KEY | ||
EOF | ||
- name: Run deploy shell script | ||
run: | | ||
npm ci | ||
npm run build | ||
bash deploy.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: lint | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
frontend: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: ['20'] | ||
python-version: ['3.12'] | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Set up Node ${{ matrix.node-version }}.x | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Check if package-lock.json is up to date | ||
run: | | ||
npx --yes [email protected] | ||
- name: Lint frontend code with ESLint | ||
run: | | ||
curl -sSL https://install.python-poetry.org | python3 - | ||
npm ci | ||
npm run lint-frontend | ||
backend: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: ['20'] | ||
python-version: ['3.12'] | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Set up Node ${{ matrix.node-version }}.x | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Check if package-lock.json is up to date | ||
run: | | ||
npx --yes [email protected] | ||
- name: Lint backend code with Flake8 | ||
run: | | ||
curl -sSL https://install.python-poetry.org | python3 - | ||
npm ci | ||
npm run lint-backend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"recommendations": [ | ||
"dbaeumer.vscode-eslint", | ||
"esbenp.prettier-vscode", | ||
"bradlc.vscode-tailwindcss" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,17 @@ | ||
# Pride Bus Tracker | ||
|
||
- Tracks the MBTA Pride bus #1833 | ||
|
||
## Requirements to develop locally | ||
|
||
- node 20.x and npm 10+ required | ||
- With `nvm` installed, use `nvm install && nvm use` | ||
- verify with `node -v` | ||
- Python 3.12 with recent poetry (1.7.0 or later) | ||
- Verify with `python --version && poetry --version` | ||
- `poetry self update` to update poetry | ||
- If using `pyenv`, `pyenv install 3.12.0` | ||
|
||
## Support TransitMatters | ||
|
||
If you've found this app helpful or interesting, please consider [donating](https://transitmatters.org/donate) to TransitMatters to help support our mission to provide data-driven advocacy for a more reliable, sustainable, and equitable transit system in Metropolitan Boston. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash -x | ||
|
||
set -e | ||
|
||
export AWS_PROFILE=transitmatters | ||
export AWS_REGION=us-east-1 | ||
export AWS_DEFAULT_REGION=us-east-1 | ||
export AWS_PAGER="" | ||
|
||
if [[ -z "$DD_API_KEY" || -z "$TM_LABS_WILDCARD_CERT_ARN" || -z "$MBTA_V3_API_KEY" ]]; then | ||
echo "Must provide DD_API_KEY, TM_LABS_WILDCARD_CERT_ARN and MBTA_V3_API_KEY in environment" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
STACK_NAME=pride-bus | ||
CHALICE_STAGE=production | ||
|
||
FRONTEND_HOSTNAME="pride-bus.labs.transitmatters.org" | ||
FRONTEND_ZONE="labs.transitmatters.org" | ||
FRONTEND_BUCKET="$FRONTEND_HOSTNAME" | ||
FRONTEND_CERT_ARN="$TM_LABS_WILDCARD_CERT_ARN" | ||
|
||
BACKEND_HOSTNAME="pride-bus-api.labs.transitmatters.org" | ||
BACKEND_ZONE="labs.transitmatters.org" | ||
BACKEND_BUCKET=pride-bus-backend | ||
BACKEND_CERT_ARN="$TM_LABS_WILDCARD_CERT_ARN" | ||
|
||
# Identify the version and commit of the current deploy | ||
GIT_VERSION=`git describe --tags --always` | ||
GIT_SHA=`git rev-parse HEAD` | ||
echo "Deploying version $GIT_VERSION | $GIT_SHA" | ||
|
||
# Adding some datadog tags to get better data | ||
DD_TAGS="git.commit.sha:$GIT_SHA,git.repository_url:github.com/transitmatters/pride-bus" | ||
|
||
npm run build | ||
|
||
# Deploy to cloudformation | ||
pushd server/ > /dev/null | ||
poetry export --without-hashes --output requirements.txt | ||
poetry run chalice package --stage $CHALICE_STAGE --merge-template cloudformation.json cfn/ | ||
aws cloudformation package --template-file cfn/sam.json --s3-bucket $BACKEND_BUCKET --output-template-file cfn/packaged.yaml | ||
aws cloudformation deploy --template-file cfn/packaged.yaml --stack-name $STACK_NAME --capabilities CAPABILITY_IAM --no-fail-on-empty-changeset --parameter-overrides \ | ||
TMFrontendHostname=$FRONTEND_HOSTNAME \ | ||
TMFrontendZone=$FRONTEND_ZONE \ | ||
TMFrontendCertArn=$FRONTEND_CERT_ARN \ | ||
TMBackendCertArn=$BACKEND_CERT_ARN \ | ||
TMBackendHostname=$BACKEND_HOSTNAME \ | ||
TMBackendZone=$BACKEND_ZONE \ | ||
MbtaV3ApiKey=$MBTA_V3_API_KEY \ | ||
DDApiKey=$DD_API_KEY \ | ||
GitVersion=$GIT_VERSION \ | ||
DDTags=$DD_TAGS | ||
|
||
popd > /dev/null | ||
aws s3 sync dist/ s3://$FRONTEND_BUCKET | ||
|
||
# Grab the cloudfront ID and invalidate its cache | ||
CLOUDFRONT_ID=$(aws cloudfront list-distributions --query "DistributionList.Items[?Aliases.Items!=null] | [?contains(Aliases.Items, '$FRONTEND_HOSTNAME')].Id | [0]" --output text) | ||
aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_ID --paths "/*" |
Oops, something went wrong.