Skip to content

Commit

Permalink
Merge pull request #3010 from LiteFarmOrg/integration
Browse files Browse the repository at this point in the history
Release 3.5
  • Loading branch information
antsgar committed Nov 21, 2023
2 parents 1de7a1e + 3efb7dc commit 042b146
Show file tree
Hide file tree
Showing 463 changed files with 35,557 additions and 13,709 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @LiteFarmOrg/mandatory-reviewers @LiteFarmOrg/reviewers
9 changes: 4 additions & 5 deletions .github/workflows/automated_tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Automated Tests'
name: "Automated Tests"

on:
pull_request:
Expand All @@ -13,9 +13,9 @@ jobs:
postgres:
image: postgres:13
env:
POSTGRES_DB: 'test_farm'
POSTGRES_USER: 'postgres'
POSTGRES_PASSWORD: 'pipeline'
POSTGRES_DB: "test_farm"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "pipeline"
POSTGRES_HOST: postgres
POSTGRES_PORT: 5432
ports:
Expand Down Expand Up @@ -45,4 +45,3 @@ jobs:
# Run all the CI tests
- name: Run tests
run: cd packages/api && npm run test-ci

20 changes: 9 additions & 11 deletions .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
name: 'Chromatic'

name: "Chromatic"
on:
workflow_dispatch:
push:
branches: [ integration ]
branches:
- integration

jobs:
chromatic-deployment:
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/webapp
strategy:
matrix:
node-version: [ 16 ]
steps:
- uses: actions/checkout@v1
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: pnpm/action-setup@v2.0.1
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 6.26.1
version: latest
- name: Install dependencies
run: pnpm install

- name: Publish to Chromatic
env:
NODE_OPTIONS: "--max-old-space-size=8192"
run: ./node_modules/.bin/chromatic --project-token ${{ secrets.CHROMATIC_PROJECT_TOKEN }}

25 changes: 13 additions & 12 deletions .github/workflows/cypress_tests.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Run cypress happy path test

on:
pull_request:
branches:
- integration
on:
workflow_dispatch:
# pull_request:
# branches:
# - integration

jobs:
build:
Expand All @@ -24,7 +25,7 @@ jobs:
VITE_GOOGLE_MAPS_API_KEY: ${{secrets.VITE_GOOGLE_MAPS_API_KEY}}
VITE_WEATHER_API_KEY: ${{secrets.VITE_WEATHER_API_KEY}}
NODE_ENV: development

strategy:
matrix:
node-version: [16.15.0]
Expand Down Expand Up @@ -52,39 +53,39 @@ jobs:
npm run start &
env:
PORT: 5000

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: latest

- name: Run and test app
env:
env:
VITE_WEATHER_API_KEY: ${{secrets.VITE_WEATHER_API_KEY}}
VITE_ENV: development
VITE_GOOGLE_OAUTH_CLIENT_ID: ${{secrets.VITE_GOOGLE_OAUTH_CLIENT_ID}}
VITE_DO_BUCKET_NAME: litefarm
NODE_ENV: development
VITE_API_URL: http://localhost:5000
CYPRESS_RECORD_KEY: "2630f414-4914-48b0-907d-aa3a9cc6a30b"
uses: cypress-io/github-action@v4.2.0
uses: cypress-io/github-action@v4.2.0
with:
working-directory: packages/webapp
install-command: pnpm install --config.auto-install-peers=true --no-frozen-lockfile --force
install: true
start: pnpm dev
wait-on: 'http://localhost:3000'
wait-on: "http://localhost:3000"
wait-on-timeout: 120
headed: true
browser: chrome
record: true
parallel: true
group: 'UI - Chrome'
group: "UI - Chrome"
spec: cypress/e2e/happyPath.spec.js

- name: set code coverage badge
run: npx -p check-code-coverage update-badge --from '${GITHUB_WORKSPACE}/packages/webapp/coverage/coverage-summary.json'
env:
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Archive code coverage results
Expand All @@ -99,6 +100,6 @@ jobs:
continue-on-error: true
working-directory: packages/webapp
run: npx set-gh-status
env:
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
GH_SHA: ${{ github.event.after }}
24 changes: 24 additions & 0 deletions .github/workflows/webapp_unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "Webapp Unit Tests"

on:
pull_request:
branches:
- integration

jobs:
webapp_unit_tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/webapp
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Setup pnpm
uses: pnpm/action-setup@v2.0.1
with:
version: 6.26.1
- name: Install dependencies
run: pnpm install
- name: Run unit tests
run: pnpm test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ packages/webapp/cypress/screenshots
packages/webapp/.nyc_output
packages/webapp/.nyc_output/out.json
packages/webapp/cypress.env.json
.vscode
.vscode/settings.json
.DS_Store
.env
packages/webapp/cypress/integration/1-getting-started
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.16.1
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.github/CODEOWNERS
42 changes: 42 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "API: Attach to Node",
"port": 9230,
"restart": true,
"address": "localhost",
"localRoot": "${workspaceFolder}"
},
{
"type": "node",
"request": "attach",
"name": "Docker Export Server: Attach to Node",
"port": 9229,
"restart": true,
"address": "localhost",
"localRoot": "${workspaceFolder}",
"remoteRoot": "/api"
},
{
"type": "node",
"request": "attach",
"name": "Docker API: Attach to Node",
"port": 9230,
"restart": true,
"address": "localhost",
"localRoot": "${workspaceFolder}",
"remoteRoot": "/api"
},

{
"type": "node",
"request": "attach",
"name": "Debug Jest Tests",
"port": 9229,
"skipFiles": ["<node_internals>/**"]
}
]
}
56 changes: 34 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,27 @@ LiteFarm is comprised of three applications which all reside in this monorepo.

## Preliminaries

1. Check to see if you have Node.js installed. On a Mac use the command `node-v` in terminal. If it is installed, the version in use will be reported in the terminal. If not, install it from [node.js](https://nodejs.org/en/download/package-manager/).
2. Check to see if you have pnpm installed. On a Mac use the command `pnpm -v`. If it is installed, the version will be reported. If you do not have it installed, run `npm install -g pnpm` in a terminal.
3. Check to see if you have NVM installed. On a Mac use the command `nvm -v`. If you do not have NVM (Node Version Manager) installed, install it using these instructions: [NVM](https://www.loginradius.com/blog/engineering/run-multiple-nodejs-version-on-the-same-machine/)
1. Check to see if you have Node.js installed. We use the version specified in the `.nvmrc` file of each folder with package imports. On a Mac use the command `node -v` in terminal. If it is installed, the version in use will be reported in the terminal. If not, install it from [node.js](https://nodejs.org/en/download/package-manager/).
2. Check to see if you have NVM installed. On a Mac use the command `nvm -v`. If you do not have NVM (Node Version Manager) installed, install it using these instructions: [NVM](https://www.loginradius.com/blog/engineering/run-multiple-nodejs-version-on-the-same-machine/)
3. Check to see if you have pnpm installed. On a Mac use the command `pnpm -v`. If it is installed, the version will be reported. If you do not have it installed, run `npm install -g pnpm` in a terminal.
4. Clone the repository from Github to your computer. On a Mac, in a Terminal window navigate to the directory you want to put the files in. Then use the command `git clone https://github.com/LiteFarmOrg/LiteFarm.git`.
5. In a terminal, navigate to the root folder of the repo and run `npm install`.
6. Navigate to the `packages/api` folder, and run `npm install`.
If trying to run this command results in the error,
`npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: objection@2.2.17...`
5. Install all packages:

Use nvm to install and use the Node version 16.15.0 with the commands, `nvm install 16.15.0` then `nvm use 16.15.0`. Then try again.
- Switch to current version of Node.js by running `nvm use` in the root folder
- Navigate to the root folder `/` of the repo and run `npm install`.
- Navigate to the `packages/api` folder, and run `npm install`.
- Navigate to the `packages/webapp` folder, and run `pnpm install`.
- Navigate to the `packages/shared` folder, and run `npm install`.

7. Navigate to the `packages/webapp` folder, and run `pnpm install`.
8. (Highly recommended) Go to [Get Docker | Docker Documentation](https://docs.docker.com/get-docker/) and install Docker. Docker is the recommended method for setting up development dependencies, but alternative instructions will be provided as well if you are unable to use Docker.
6. (Highly recommended) Go to [Get Docker | Docker Documentation](https://docs.docker.com/get-docker/) and install Docker. Docker is the recommended method for setting up development dependencies, but alternative instructions will be provided as well if you are unable to use Docker. There will be extra instructions for each operating system. For example: Windows requires Windows subsystem for linux (WSL). Mac users may need to enable experimental/beta settings for Mac users.

## Adding environment files

The applications are configured with environment variables stored in `.env` files. Configuration information includes secrets like API keys, so the `.env` files are not included in this git repository.

This repository contains a `.env.default` file for both api and webapp. These files contain directions to acquire the personal keys needed to get LiteFarm running locally. Please note you will want to copy `.env.default` and rename the file to `.env`. Only after adding the `.env` file should you proceed to add the new keys. If you add your api keys to `.env.default` you may accidentally expose your keys since this file is tracked on git.

If you have questions about the other api keys, or wish to join the LiteFarm team, please contact community@litefarm.org.

## Database setup

Expand Down Expand Up @@ -98,14 +103,6 @@ In a Terminal window:

</details>

## Adding environment files

The applications are configured with environment variables stored in `.env` files. Configuration information includes secrets like API keys, so the `.env` files are not included in this git repository.

This repository contains a `.env.default` file for api and webapp. These files contain directions to acquire the personal keys needed to get LiteFarm running locally. Please note you will want to copy `.env.default` and rename the file to `.env`. Only after adding the `.env` file should you proceed to add the new keys. If you add your api keys to `.env.default` you may accidentally expose your keys since this file is tracked on git.

If you have questions about the other api keys, or wish to join the LiteFarm team, please contact community@litefarm.org.

# Running the apps

## api
Expand Down Expand Up @@ -237,7 +234,7 @@ You can also test LiteFarm on your actual mobile device using the network adddre

Please see https://ngrok.com/ for more general information about ngrok.

Use cases in which we currently utilize ngrok at LiteFarm include:
While not required for most developers, use cases in which we currently utilize ngrok at LiteFarm include:

- Testing local changes on phones or different devices
- Testing local changes when working with other APIs and integrations
Expand Down Expand Up @@ -285,6 +282,14 @@ Use cases in which we currently utilize docker at LiteFarm include:
- create a `.env` file at the root directory of the project i.e. LiteFarm
- Add key-value pairs in the `.env` by referring to the `docker-compose.[ENV].yml` that contains the docker env keys.

## Troubleshooting

1. On Windows: During `npm run nodemon` of `/packages/api` there is an error - possibly with the client variable of knex.

The NODE_ENV variable is not being set properly you will need to adjust the nodemon script in `/packages/api/package.json`.

We hope to improve our `package.json` scripts in the near future.

## Commands

These commands can be run from the root of the repo.
Expand All @@ -303,6 +308,13 @@ Notes:
- [container_name] are litefarm-db, litefarm-api and litefarm-web.
- [ENV] are beta and prod

## Storybook

You can use Storybook to visualize and test out the UI components used throughout the app.

- To view Storybook on your local environment, run `pnmp storybook` on the `packages/webapp` directory and navigate to http://localhost:6006
- To view the deployed version of Storybook, which is updated automatically with the latest changes on the integration branch, go to https://65316fc4f177c73a9181a843-yobioprfjv.chromatic.com

## How to Contribute

Please email: community@litefarm.org for more details.

0 comments on commit 042b146

Please sign in to comment.