Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/0.5.0 #433

Merged
merged 22 commits into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d4970ee
Merge pull request #410 from isomerpages/release/0.4.0
seaerchin Mar 30, 2022
d2749e9
build(ci): add ci (#384)
seaerchin Mar 31, 2022
a0ed154
Fix: identity test (#414)
alexanderleegs Mar 31, 2022
7b704a0
chore(build): automate jumphost setup (#412)
seaerchin Apr 1, 2022
b5b7ce9
test(ci): update ci config (#415)
seaerchin Apr 1, 2022
4edec0e
chore(app): replace custom properties on req with res.locals (#413)
seaerchin Apr 4, 2022
05518d3
Refactor/contact us (#349)
alexanderleegs Apr 5, 2022
61b62aa
Refactor/homepage (#331)
alexanderleegs Apr 5, 2022
fbb38c8
Refactor/netlify toml (#357)
alexanderleegs Apr 6, 2022
ae809fc
Refactor/navigation (#363)
alexanderleegs Apr 6, 2022
52b0894
refactor(mailclient): pass api key explicitly (#419)
seaerchin Apr 6, 2022
d2eace1
chore(app): remove deprecated `bin/www` (#418)
seaerchin Apr 14, 2022
6b884b7
Fix: check for JsonWebTokenError (#423)
alexanderleegs Apr 14, 2022
cf34911
test(resourceDirectory): add check for directory/file call order (#420)
seaerchin Apr 14, 2022
82064e1
chore(mergify): change to lower case (#425)
seaerchin Apr 14, 2022
41da898
build(deps): bump async from 3.2.0 to 3.2.3 (#424)
dependabot[bot] Apr 14, 2022
c4ac1b8
build(deps-dev): bump eslint-config-prettier from 8.1.0 to 8.5.0 (#371)
dependabot[bot] Apr 14, 2022
edf9200
Chore: remove duplicate validation in User model (#429)
alexanderleegs Apr 19, 2022
b106ac8
Refactor/use test fixture (#430)
alexanderleegs Apr 20, 2022
2a0071e
Feat/move whitelist into database (#422)
alexanderleegs Apr 20, 2022
eb14d65
Fix/migrate script (#432)
alexanderleegs Apr 20, 2022
3f749bd
0.5.0
alexanderleegs Apr 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pull_request_rules:
- author~=^dependabot\[bot\]$
- check-success~=lint
- check-success~=test
- title~=Bump [^\s]+ from ([\d]+)\..+ to \1\.
- title~=bump [^\s]+ from ([\d]+)\..+ to \1\.
actions:
review:
type: APPROVE
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,79 @@
name: ci

on:
push:
pull_request:
types: [opened, reopened]

env:
PRODUCTION_BRANCH: refs/heads/master
STAGING_BRANCH: refs/heads/staging
EB_APP: isomer-cms
EB_ENV_PRODUCTION: cms-backend-prod
EB_ENV_STAGING: cms-backend-staging
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}

jobs:
install:
# NOTE: Netlify uses ubuntu 16.08 but Github Actions does not offer it by default.
# Hence, we default to the latest version.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: "14.x"
- name: Cache Node.js modules
uses: actions/cache@v2
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- run: npm ci

lint:
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: "14.x"
- name: Load Node.js modules
uses: actions/cache@v2
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
- run: npm ci
- run: npm run lint-fix
- run: npm run format-fix

test:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: "14.x"
- name: Load Node.js modules
uses: actions/cache@v2
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
- run: npm ci
- run: npm run dev:services
- run: . .env.test && npx jest
- run: docker compose down

gatekeep:
name: Determine if Build & Deploy is needed
outputs:
Expand All @@ -29,6 +92,7 @@ jobs:
print('::set-output name=proceed::true')
else:
print('::set-output name=proceed::false')

deploy:
name: Build and deploy to EB
runs-on: ubuntu-18.04
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.env
node_modules/
.vscode/
build/
build/
*.pem
.env*
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,34 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v0.5.0](https://github.com/isomerpages/isomercms-backend/compare/v0.4.0...v0.5.0)

- Fix/migrate script [`#432`](https://github.com/isomerpages/isomercms-backend/pull/432)
- Feat/move whitelist into database [`#422`](https://github.com/isomerpages/isomercms-backend/pull/422)
- Refactor/use test fixture [`#430`](https://github.com/isomerpages/isomercms-backend/pull/430)
- Chore: remove duplicate validation in User model [`#429`](https://github.com/isomerpages/isomercms-backend/pull/429)
- build(deps-dev): bump eslint-config-prettier from 8.1.0 to 8.5.0 [`#371`](https://github.com/isomerpages/isomercms-backend/pull/371)
- build(deps): bump async from 3.2.0 to 3.2.3 [`#424`](https://github.com/isomerpages/isomercms-backend/pull/424)
- chore(mergify): change to lower case [`#425`](https://github.com/isomerpages/isomercms-backend/pull/425)
- test(resourceDirectory): add check for directory/file call order [`#420`](https://github.com/isomerpages/isomercms-backend/pull/420)
- Fix: check for JsonWebTokenError [`#423`](https://github.com/isomerpages/isomercms-backend/pull/423)
- chore(app): remove deprecated `bin/www` [`#418`](https://github.com/isomerpages/isomercms-backend/pull/418)
- refactor(mailclient): pass api key explicitly [`#419`](https://github.com/isomerpages/isomercms-backend/pull/419)
- Refactor/navigation [`#363`](https://github.com/isomerpages/isomercms-backend/pull/363)
- Refactor/netlify toml [`#357`](https://github.com/isomerpages/isomercms-backend/pull/357)
- Refactor/homepage [`#331`](https://github.com/isomerpages/isomercms-backend/pull/331)
- Refactor/contact us [`#349`](https://github.com/isomerpages/isomercms-backend/pull/349)
- chore(app): replace custom properties on req with res.locals [`#413`](https://github.com/isomerpages/isomercms-backend/pull/413)
- test(ci): update ci config [`#415`](https://github.com/isomerpages/isomercms-backend/pull/415)
- chore(build): automate jumphost setup [`#412`](https://github.com/isomerpages/isomercms-backend/pull/412)
- Fix: identity test [`#414`](https://github.com/isomerpages/isomercms-backend/pull/414)
- build(ci): add ci [`#384`](https://github.com/isomerpages/isomercms-backend/pull/384)
- release(0.4.0): merge back to develop [`#410`](https://github.com/isomerpages/isomercms-backend/pull/410)

#### [v0.4.0](https://github.com/isomerpages/isomercms-backend/compare/v0.3.0...v0.4.0)

> 30 March 2022

- feat(identity): verified merged [`#364`](https://github.com/isomerpages/isomercms-backend/pull/364)
- docs: add instructions to run DB migrations on remote DB [`#404`](https://github.com/isomerpages/isomercms-backend/pull/404)
- release: merge 0.3.0 to develop [`#401`](https://github.com/isomerpages/isomercms-backend/pull/401)
Expand Down
33 changes: 26 additions & 7 deletions README → README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,58 @@
## E2E Tests

To run the E2E tests successfully, you will need to define the following environment variables:

```
export E2E_TEST_REPO="e2e-test-repo"
export E2E_TEST_SECRET="blahblahblah" // this should match the value of CYPRESS_COOKIE_VALUE on
export E2E_TEST_SECRET="blahblahblah" // this should match the value of CYPRESS_COOKIE_VALUE on
// the frontend
export E2E_TEST_GH_TOKEN="" // this can be your own personal GH access token, or the token from our
export E2E_TEST_GH_TOKEN="" // this can be your own personal GH access token, or the token from our
// specialized E2E test user
```

### Release

Run the following on the release branch to tag and push changes automatically:

```
npm run release --isomer_update=<versionType>
```

where versionType corresponds to npm version types. This only works on non-Windows platforms, for Windows, modify the release script to use %npm_config_update% instead of $npm_config_update.

### Running migrations on a remote database in a private subnet of a VPC

The following steps are needed before you can run migrations on a remote database in a private subnet of an AWS VPC.
The following steps are needed before you can run migrations on a remote database in a private subnet of an AWS VPC.

First, you will need to ensure that your current device IP address is whitelisted to use the EC2 instance.

First, you will need to ensure that your current device IP address is whitelisted to use the EC2 instance.
- Log into the AWS console and navigate to the EC2 Dashboard.
- Navigate to the Security Groups tab by looking at the Network & Security section in the left pane and clicking on the Security Groups tab.
- Look for the security group titled `cms-bastion-<ENVIRONMENT>`, where `<ENVIRONMENT>` is either staging or production. Click on the security group and then the Inbound rules tab.
- If you see your IP address in the Inbound rules whitelist, you are done with this step.
- If your IP address does not exist in the Inbound rules whitelist, click on the Edit inbound rules button.
- Click on the Add rule button. Select SSH as the Type, and select My IP as the Source. Give a meaningful description for the security rule, e.g. WeWork City House. Click on Save rules to complete this step.

Next, you need to set up a local port-forwarding service that forwards traffic from a specific local port, e.g. 5433, to the database via the bastion host (remember: the bastion host resides in the public subnet of the VPC and thus can be contactable from your computer).
- Open a terminal window and run the following command: ```ssh -L 5433:<DB_HOST>:5432 <SSH_USER>@<SSH_HOST> -i <PATH_TO_SSH_HOST_PEM_FILE>```
Next, you will require the correct environment variables and credentials.

- Go into the 1PW Isomer - Admin vault and search for the `.ssh/.env.<staging | production>` file.
- Create a folder named .ssh in the root directory and place the `.env` files there.
- Search for the corresponding credentials `isomercms-<staging | production>-bastion.pem`
- Put these credentials into the .ssh folder also.

Next, run the following command: `npm run jump:<staging | production>`. This sets up the port-forwarding service.
Finally, run the following command in a separate terminal: `npm run db:migrate:<staging | production>` to run the migration.

What happens under the hood is described below:
You need to set up a local port-forwarding service that forwards traffic from a specific local port, e.g. 5433, to the database via the bastion host (remember: the bastion host resides in the public subnet of the VPC and thus can be contactable from your computer).

- Open a terminal window and run the following command: `ssh -L 5433:<DB_HOST>:5432 <SSH_USER>@<SSH_HOST> -i <PATH_TO_SSH_HOST_PEM_FILE>`
- The `DB_HOST`, `SSH_USER`, `SSH_HOST`, and `PEM_FILE` values can be found in the `CMS <ENVIRONMENT> Database` file in the `Isomer - Admin` 1Password vault.
- The `PEM_FILE` (the actual file) can be found in the `Isomer - Admin` 1Password vault as well. Download the file and save it to your computer. and update the file value for `PATH_TO_SSH_HOST_PEM_FILE`.

Finally, we want to run the migration script.

- Modify the `DB_URI` in the `.env` file so that Sequelize connects to the local port-forwarding service at port 5433: `postgres://<DB_USER>:<DB_PASS>@127.0.0.1:5433/<DB_NAME>`
- Open another terminal window.
- Run `source .env`
- Run `npx sequelize-cli db:migrate`
- Run `npx sequelize-cli db:migrate`
91 changes: 0 additions & 91 deletions bin/www.js

This file was deleted.

Loading