Skip to content

Commit

Permalink
Merge pull request #3610 from LiteFarmOrg/integration
Browse files Browse the repository at this point in the history
Release 3.7.0
  • Loading branch information
kathyavini authored Dec 12, 2024
2 parents b1b7843 + f046846 commit cd7f9da
Show file tree
Hide file tree
Showing 763 changed files with 69,860 additions and 32,844 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/automated_tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Automated Tests"
name: API Unit Tests

on:
pull_request:
Expand All @@ -7,7 +7,8 @@ on:
- "patch/**"

jobs:
automated_tests:
api_unit_tests:
name: API Unit Tests
runs-on: ubuntu-20.04
container: node:18.16.1
services:
Expand Down
118 changes: 59 additions & 59 deletions .github/workflows/cypress_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,52 @@ name: Run cypress happy path test

on:
workflow_dispatch:
# pull_request:
# branches:
# - integration
pull_request:
types: [enqueued]
branches:
- integration
merge_group:

jobs:
build:
runs-on: ubuntu-20.04
cypress-tests:
name: Cypress E2E Tests
runs-on: ubuntu-latest
timeout-minutes: 30
services:
postgres:
image: postgres
env:
POSTGRES_DB: "pg-litefarm"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
# POSTGRES_HOST: localhost
# POSTGRES_HOST: postgres
options: >-
--health-cmd pg_isready
--health-interval 5s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
volumes:
- ./initdb.d:/docker-entrypoint-initdb.d
- postgres-data:/var/lib/postgresql/data
strategy:
matrix:
node-version: [18.16.1]
env:
JWT_INVITE_SECRET: ${{secrets.JWT_INVITE_SECRET}}
JWT_RESET_SECRET: ${{secrets.JWT_RESET_SECRET}}
JWT_SCHEDULER_SECRET: ${{secrets.JWT_SCHEDULER_SECRET}}
JWT_SECRET: ${{secrets.JWT_SECRET}}
TEST_USER: ${{secrets.TEST_USER}}
TEST_USER_ID: ${{secrets.TEST_USER_ID}}
DEV_DATABASE_HOST: localhost
DEV_DATABASE: pg-litefarm
DEV_DATABASE_USER: postgres
DEV_DATABASE_PASSWORD: postgres
JWT_SECRET: This_will_(really)_work
JWT_INVITE_SECRET: Any_arbitrary_string_will_do
JWT_RESET_SECRET: Production_is_secured_with_a_long_random_string
JWT_FARM_SECRET: Here_we_can_use_friendly_explanations
JWT_SCHEDULER_SECRET: Another_token_was_needed_for_the_scheduler
GOOGLE_API_KEY: ${{secrets.VITE_GOOGLE_MAPS_API_KEY}}
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]

steps:
- uses: ikalnytskyi/action-setup-postgres@v3
with:
username: ${{env.DEV_DATABASE_USER}}
password: ${{env.DEV_DATABASE_PASSWORD}}
database: ${{env.DEV_DATABASE}}
port: 5432

- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
Expand All @@ -53,53 +63,43 @@ jobs:
npm run start &
env:
PORT: 5000
DEV_DATABASE_HOST: localhost
DEV_DATABASE: pg-litefarm
DEV_DATABASE_USER: postgres
DEV_DATABASE_PASSWORD: postgres
NODE_ENV: development

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

- name: Run and test app
- name: Run Webapp
working-directory: packages/webapp
run: |
pnpm install --config.auto-install-peers=true --no-frozen-lockfile --force
pnpm dev &
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/[email protected]
CYPRESS_COVERAGE: true
- name: Run E2E test (English)
env:
CYPRESS_RECORD_KEY: ${{secrets.CYPRESS_RECORD_KEY}}
CYPRESS_USER: 0
uses: cypress-io/github-action@v6
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-timeout: 120
working-directory: packages/end-to-end
headed: true
browser: chrome
record: true
parallel: true
parallel: false
group: "UI - Chrome"
spec: cypress/e2e/happyPath.spec.js
ci-build-id: ${{ github.run_id }}

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

- name: Archive code coverage results
- name: Archive backend logs
uses: actions/upload-artifact@v3
continue-on-error: true
with:
name: code-coverage-report
working-directory: packages/webapp
path: coverage/coverage-summary.json

- name: Set code coverage commit status
continue-on-error: true
working-directory: packages/webapp
run: npx set-gh-status
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
GH_SHA: ${{ github.event.after }}
name: logs
path: packages/api/logs
8 changes: 4 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Deploy'
name: "Deploy"
on:
workflow_dispatch:

Expand Down Expand Up @@ -26,8 +26,8 @@ jobs:
with:
script_stop: true
host: ${{ secrets.BETA_SSH_HOST }}
username: ${{ secrets.BETA_SSH_USER }}
passphrase: ${{ secrets.BETA_SSH_PASS }}
key: ${{ secrets.BETA_SSH_KEY }}
username: ${{ secrets.BETA_SSH_USER_NEW }}
passphrase: ${{ secrets.BETA_SSH_PASS_NEW }}
key: ${{ secrets.BETA_SSH_KEY_NEW }}
command_timeout: 20m
script: ${{ steps.script.outputs.content }}
3 changes: 2 additions & 1 deletion .github/workflows/webapp_unit_tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Webapp Unit Tests"
name: Webapp Unit Tests

on:
pull_request:
Expand All @@ -7,6 +7,7 @@ on:

jobs:
webapp_unit_tests:
name: Webapp Unit Tests
runs-on: ubuntu-latest
defaults:
run:
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ packages/api/.env.local
packages/api/tickets
packages/api/.env
packages/webapp/.env
packages/webapp/cypress/videos
packages/webapp/cypress/screenshots
packages/end-to-end/cypress/videos
packages/end-to-end/cypress/screenshots
packages/end-to-end/coverage
packages/webapp/.nyc_output
packages/webapp/.nyc_output/out.json
packages/webapp/cypress.env.json
Expand Down
2 changes: 2 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
node .husky/commit-msg.js $1
59 changes: 59 additions & 0 deletions .husky/commit-msg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import fs from "node:fs";
import { fileURLToPath } from "node:url";
import { execSync } from "node:child_process";

const ticketNumberRegex = /LF-\d+/;
const commitMessageFilePath = process.argv[2];

const git = {
getCurrentBranchName: () =>
execSync("git rev-parse --abbrev-ref HEAD").toString().trim(),
readCommitMsg: () => fs.readFileSync(commitMessageFilePath, "utf8"),
writeCommitMsg: (msg) => fs.writeFileSync(commitMessageFilePath, msg),
};

function processCommitMsg() {
try {
const branchName = git.getCurrentBranchName();
const match = branchName.match(ticketNumberRegex);

// Branch name doesn't contain ticket number
if (!match) {
console.warn(
"JIRA ticket number not found in branch name. Proceeding without modification."
);
return;
}

const commitMessage = git.readCommitMsg();

const filteredCommitMessage = commitMessage
.split("\n")
.filter((line) => !line.trim().startsWith("#"))
.join("\n")
.trim();

if (filteredCommitMessage === "") return;

// Check if commit already contains ticket number
if (filteredCommitMessage.match(ticketNumberRegex)) {
console.log(
"Commit message already contains a JIRA ticket number. Proceeding without modification."
);
return;
}

// Modify commit message
git.writeCommitMsg(match[0] + " " + filteredCommitMessage);
} catch (error) {
console.error("Error processing commit message:", error);
}
}

// Call the hook only when this file is executed directly by node.
// This is needed to ensure proper execution of tests.
if (process.argv[1] === fileURLToPath(import.meta.url)) {
processCommitMsg();
}

export { git, processCommitMsg };
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
| Test | Coverage |
| ----------- | ------------------------------------------------------------------------------- |
| E2E FE Test | ![check-code-coverage](https://img.shields.io/badge/code--coverage-51.2%25-red) |

# LiteFarm

LiteFarm is the world’s first community-led, not-for-profit, digital platform joining farmers and scientists together for participatory assessment of social, environmental and economic outputs of farming systems. LiteFarm is the first application of its kind specifically tailored to the needs of diversified farmers with built-in pathways to provide expert decision support and help them earn additional income through payment for ecological services (PES) schemes and in-app certifications (such as organic). These approaches serve the multiple purposes of incentivizing adoption of sustainable land use practices through the provision of evidence-based decision support, and significantly increasing the amount of data being collected by diversified farming operations around the globe. It was developed with farmers at the center of the design process and built from the ground up with accessibility and approachability in mind. We are proud of our mission:
Expand Down Expand Up @@ -50,7 +46,7 @@ Run `docker compose up` in the root directory to configure and start all develop

For more information, see [services (local development dependencies)](#services-local-development-dependencies) below.

Once the database container is running and the `.env` files have been configured [as described below](#adding-environment-files), in a terminal navigate to the `packages/api` folder. Execute `npm run migrate:dev:db` to run the [migrations](https://knexjs.org/#Migrations) that set up the PostgreSQL database used by the app.
Once the database container is running and the `.env` files have been configured [as described above](#adding-environment-files), in a terminal navigate to the `packages/api` folder. Execute `npm run migrate:dev:db` to run the [migrations](https://knexjs.org/#Migrations) that set up the PostgreSQL database used by the app.

### Database - Native installation

Expand Down Expand Up @@ -310,7 +306,7 @@ Notes:

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 Storybook on your local environment, run `pnpm 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
Expand Down
4 changes: 2 additions & 2 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
'*.{md,yml}': 'prettier --write'
export default {
"*.{md,yml,json,js}": "prettier --write",
};
40 changes: 20 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cd7f9da

Please sign in to comment.