From a8b71a0d6013139f175133ca3b968862a2639240 Mon Sep 17 00:00:00 2001 From: John Madden Date: Tue, 25 Aug 2026 15:11:25 -0700 Subject: [PATCH 1/7] Added deploy action --- .github/workflows/deploy.yaml | 82 +++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .github/workflows/deploy.yaml diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..0929ea7 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,82 @@ +--- +name: Deploy + +permissions: + contents: read + issues: write + pull-requests: write + +on: + push: + workflow_dispatch: + +concurrency: + group: production + cancel-in-progress: true + +jobs: + deploy: + + runs-on: ubuntu-latest + environment: + name: development + url: http://${{ vars.PROD_HOST }}:3001/ + + steps: + - name: Setup SSH key + run: | + mkdir -p ~/.ssh + echo "${{ secrets.PROD_SSH_KEY }}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh-keyscan -H ${{ vars.PROD_HOST }} >> ~/.ssh/known_hosts + + - name: Deploy via SSH + run: | + ssh ${{ secrets.PROD_USER }}@${{ vars.PROD_HOST }} << 'EOF' + set -e + + export COMPOSE_PROGRESS=plain + export NO_COLOR=1 + + export AWS_ACCESS_KEY_ID="${{ secrets.AWS_ACCESS_KEY_ID }}" + export AWS_SECRET_ACCESS_KEY="${{ secrets.AWS_SECRET_ACCESS_KEY }}" + export AWS_DEFAULT_REGION=us-west-2 + + APP_DIR="NodeFlow" + REPO_URL="https://github.com/jlab-sensing/NodeFlow.git" + + echo "::group::Cloning repository" + sudo rm -rf $APP_DIR + git clone "$REPO_URL" "$APP_DIR" + cd "$APP_DIR" + git fetch origin + git reset --hard ${{ steps.pr.outputs.sha }} + echo "::endgroup::" + + echo "::group::Setting up env file" + aws s3 cp s3://nodeflow-ucsc/secrets .env + sed -i "s/localhost/${{ vars.PROD_HOST }}/g" .env + echo "::endgroup::" + + echo "::group::Remove previous deployment" + docker ps -aq | xargs -r docker stop + docker ps -aq | xargs -r docker rm + docker system prune -af --volumes + docker volume prune -a -f + echo "::endgroup::" + + echo "::group::Starting services" + docker compose pull --ignore-buildable + docker compose up -d --build + sleep 5 + echo "::endgroup::" + + echo "::group::Waiting for startup" + sleep 15 + echo "::endgroup::" + + echo "::group::Startup logs" + docker compose logs --no-color + echo "::endgroup::" + EOF + From 99219d16d40ae2e18f2c93e452d4cdee29da7224 Mon Sep 17 00:00:00 2001 From: John Madden Date: Tue, 25 Aug 2026 16:51:20 -0700 Subject: [PATCH 2/7] Update backend Dockerfile images --- backend/Dockerfile | 8 ++++++-- docker-compose.yml | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index f9c1b03..24752c7 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -25,8 +25,6 @@ WORKDIR /app # copy files from source tree COPY . . -EXPOSE 8001 -CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8001"] # CI image with test-only dependencies and coverage reporting. FROM base AS test @@ -34,3 +32,9 @@ FROM base AS test RUN pip install --no-cache-dir -r requirements-dev.txt CMD ["pytest", "--cov=app", "--cov-report=term-missing", "--cov-report=xml:/app/coverage.xml"] + + +FROM base AS webserver + +EXPOSE 8001 +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8001"] diff --git a/docker-compose.yml b/docker-compose.yml index 555f2eb..9d62873 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,7 @@ services: build: context: ./backend dockerfile: Dockerfile + target: webserver image: nodeflow-backend env_file: - ${ENV_FILE:-.env} From 97f85063b910e51c5d264deafccf0202b0f4ffec Mon Sep 17 00:00:00 2001 From: John Madden Date: Tue, 25 Aug 2026 17:01:36 -0700 Subject: [PATCH 3/7] Updated git clone command --- .github/workflows/deploy.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 0929ea7..5ef8bed 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -44,10 +44,11 @@ jobs: APP_DIR="NodeFlow" REPO_URL="https://github.com/jlab-sensing/NodeFlow.git" + BRANCH="${{ github.ref_name }}" echo "::group::Cloning repository" sudo rm -rf $APP_DIR - git clone "$REPO_URL" "$APP_DIR" + git clone -b "$BRANCH" "$REPO_URL" "$APP_DIR" cd "$APP_DIR" git fetch origin git reset --hard ${{ steps.pr.outputs.sha }} From e0651ea09f019faf4772a14b9cb6aeb58ef237f6 Mon Sep 17 00:00:00 2001 From: John Madden Date: Tue, 25 Aug 2026 17:33:16 -0700 Subject: [PATCH 4/7] Allow all hosts in frontend --- frontend/vite.config.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/vite.config.js b/frontend/vite.config.js index ea0dd38..05004f4 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -3,6 +3,10 @@ import react from '@vitejs/plugin-react' export default defineConfig({ plugins: [react()], + server: { + host: true, + allowedHosts: true, + }, test: { environment: 'jsdom', setupFiles: './tests/setup.js', From ed39848721e4d499977a3141befe81c77c5f4d18 Mon Sep 17 00:00:00 2001 From: John Madden Date: Tue, 25 Aug 2026 17:55:55 -0700 Subject: [PATCH 5/7] Updated to deploy on pushes to main --- .github/workflows/deploy.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 5ef8bed..9221331 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -8,6 +8,8 @@ permissions: on: push: + branches: + - main workflow_dispatch: concurrency: From f14ecf87cd59c101bfb3a1f3491a2fb6484f95b9 Mon Sep 17 00:00:00 2001 From: David Glover Date: Wed, 26 Aug 2026 10:32:49 -0700 Subject: [PATCH 6/7] formatting and testing/linting/formatting instructions in README --- frontend/README.md | 36 ++++++++++++++++++++++++++++++++++++ frontend/vite.config.js | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/frontend/README.md b/frontend/README.md index 4cc1d56..96d8a6b 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -3,3 +3,39 @@ ## Introduction The NodeFlow client is being built with [React](https://react.dev/), a component based web library + +## Testing + +We use vitest to run frontend tests. You can automatically run the frontend tests by running + +``` +npm run test:ci +``` + +## Linting + +We use eslint as the frontend linter. You can check the current status of your files by running + +``` +npm run lint +``` + +Supported lint issues can be automatically fixed by running + +``` +npx eslint --fix +``` + +## Formatting + +We use Prettier as the frontend formatter. You can check the formatting of the frontend by running + +``` +npm run format:check +``` + +and can automatically format the frontend files by running + +``` +npm run format +``` diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 05004f4..f6b899c 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -5,7 +5,7 @@ export default defineConfig({ plugins: [react()], server: { host: true, - allowedHosts: true, + allowedHosts: true, }, test: { environment: 'jsdom', From 843ff85e582a15a7421479743738fd53345ca50a Mon Sep 17 00:00:00 2001 From: David Glover Date: Fri, 28 Aug 2026 12:44:10 -0700 Subject: [PATCH 7/7] readme format update --- README.md | 3 ++- frontend/README.md | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5fe4156..22acef7 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ Low Cost, Real-Time Automated Irrigation | Python | | Docker | -test for lint ## Getting Started @@ -21,3 +20,5 @@ For documentation on the backend, refer to [backend readme](backend/README.md) ## Builders - David Glover [dvdthr5](https://github.com/dvdthr5) + +- John Madden [jmadden173](https://github.com/jmadden173) diff --git a/frontend/README.md b/frontend/README.md index 96d8a6b..a4330e9 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -28,7 +28,7 @@ npx eslint --fix ## Formatting -We use Prettier as the frontend formatter. You can check the formatting of the frontend by running +We use Prettier as the frontend formatter. You can check the formatting of the frontend by running ``` npm run format:check