Skip to content

Latest commit

 

History

History
206 lines (146 loc) · 7.24 KB

readme.md

File metadata and controls

206 lines (146 loc) · 7.24 KB

Open issues    Open PRs    License   

Contribute, request a feature, or check out our resources

Website       Features       Documentation       Pricing       Blog      

Try the Upsun demo

About

This is a simple demo project meant to take users through a product tour of Upsun.

Getting started

If you already have access to Upsun:

Resume the demo

When you start the demo project through the Upsun console, you will receive all the steps you need to go through the entire demo. If for some reason you close your browser and lose your place, however, you can pick back up where you left off by following the instructions below.

  1. Install the Upsun CLI

    brew install upsun/tap/upsun-cli

    [!NOTE] Determine if you already have the CLI installed by running upsun.

  2. Create a project

    First run, upsun project:list. If there is no project listed, you can go right ahead back to https://console.upsun.com/create-project and restart the Demo project option.

    If you already created a project, you will find a PROJECT_ID associated with that project, which you will use in the next step.

  3. Get the demo repository

    [!NOTE] You can determine if you have already pushed the demo project to Upsun using the command upsun activity:list --type push. If you've already pushed code, there will be an entry in the table that says Your Name pushed to Main.

    If you see a push activity, run upsun get PROJECT_ID to get the code, cd the resulting folder, and then move on to step 4.

    Get the demo repo by running:

    git clone [email protected]:platformsh/demo-project.git upsun-demo && cd upsun-demo

    Then push to Upsun

    upsun push -y --set-remote PROJECT_ID
  4. View the environment

    You should be all caught up to resume the demo at this point. Run upsun url --primary to view the environment, and visit https://console.upsun.com/projects/PROJECT_ID to view the project.

Welcome to Upsun!

Contributing

Checkout the Contributing guide guide for more details.

Running this project locally

There is a root package @platformsh/demo-project that controls both the backend and frontend app setup. NPM is required.

  1. git clone [email protected]:platformsh/demo-project.git
  2. cd demo-project
  3. npm install
  4. npm run start

These commands will set up everything you need to get started, serving the frontend React app from localhost:3000

Important

If at any time you want to start over, run npm run clean. This will delete everything you've done in the previous steps.

Testing individual steps of the demo

When running locally, npm run start mimicks the backend connection in frontend/src/utility/api.ts. That is, if you're looking to update steps (defined in frontend/src/App.tsx) or commands (defined in frontend/src/commands.json) and view how they will appear to the user, which state is presented is defined in this file.

In the fetchEnvironment method, you will see an override_state variable

// frontend/src/utility/api.ts

let data;

// If updating the design locally, this variable can help you quickly switch between steps.
//  Note: this value MUST be returned to "default" when pushed to the project repo, or else tests will fail.
// let override_state = "default";
let override_state = "branch"
// let override_state = "redis"
// let override_state = "merge-production"
// let override_state = "scale"
// let override_state = "complete"

Changing which state is commented out in this block for the override_state variable will allow you to quickly switch between states.

Important

This switch is included to make design/command changes easy to visualize quickly. It is required that you reset this variable to let override_state = "default" before pushing to the repository. If you do not, tests will fail and the PR cannot be accepted.

You can usually tell if forgetting to reset this variable is the reason for failure from the following error message during a test run:

 FAIL  src/utility/api.test.tsx
 ● fetchEnvironment › fetches environment successfully

Running tests

This project goes through a number of tests on GitHub that must pass before it can be merged. These tests are of two types:

  1. Code tests
  2. Demo path tests

Code tests

Note

You can run all the tests desribed below with the command:

./utils/tests/all.sh

Before pushing your changes to the repository (or if your PR is failing), please run the following steps locally:

  1. Install project dependencies

    npm install
  2. Run frontend React tests.

    npm run test:frontend -- --watchAll

    [!NOTE] This test will fail on GitHub if any React tests fail.

    Tips:

  3. Audit frontend dependencies.

    cd frontend && npm audit

    [!NOTE] This test will pass on GitHub, so long as there are no High or Critical vulnerabilities found.

  4. Prettier

    npm run prettier:frontend
    npm run lint:frontend

    If, for example, you run into the error [warn] Code style issues found in 3 files. Run Prettier to fix. for the frontend, run cd frontend && npm run pretty:fix to fix.

    The workflow on GitHub will fail if this error occurs, so please fix locally when contributing.