Skip to content
New issue

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

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

Already on GitHub? # to your account

Upgraded API and Client #103

Merged
merged 80 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
226d106
Initial API commit
miksrv Jul 26, 2024
da47f9f
Implemented API DB models
miksrv Jul 26, 2024
d62cda3
Implemented OpenWeather API Library
miksrv Jul 26, 2024
cb9a5c6
Added Entity API models
miksrv Jul 26, 2024
85232e4
Finalize API save current weather data
miksrv Jul 26, 2024
163bcd3
Refactoring API entities
miksrv Jul 26, 2024
c5f12c4
Finalize average weather data API
miksrv Jul 26, 2024
1dcb1ed
Implemented new source API weather library
miksrv Jul 28, 2024
6315719
Added new DB fields
miksrv Jul 28, 2024
5ea4660
Implemented new API Weather Library
miksrv Jul 28, 2024
45e22d4
Implemented forecast API data tables
miksrv Jul 28, 2024
1237764
Implemented API get forecast weather for OpenWeather Map
miksrv Jul 28, 2024
8c3e1f8
Implemented WeatherAPI forecast
miksrv Jul 28, 2024
e48d2f5
Added Migrate weather data model
miksrv Jul 29, 2024
0a9e647
Added migration controller
miksrv Jul 29, 2024
f3e945f
Added indexes for DB in the migrations
miksrv Jul 29, 2024
3935e16
Added helper function calculateDewPoint and mmHg_to_hPa
miksrv Jul 29, 2024
0128265
Finalize API migration
miksrv Jul 29, 2024
0a61f44
Implemented API get current weather endpoint
miksrv Jul 29, 2024
9c93ab7
Implemented API forecast endpoint
miksrv Jul 29, 2024
b0612ee
Implemented API Deploy GitHub actions
miksrv Jul 30, 2024
ca48dc1
Change SQL queries NOW -> UTC_TIMESTAMP
miksrv Jul 31, 2024
952fc63
Improved API getCurrentWeather controller function
miksrv Jul 31, 2024
cfac0ba
Implemented API history endpoints
miksrv Jul 31, 2024
18aeaf0
Fixed API models
miksrv Aug 2, 2024
18c7198
Initial UI commit
miksrv Aug 2, 2024
6ae9714
Implemented UI base project template
miksrv Aug 2, 2024
e00d409
Implemented UI template for widget component
miksrv Aug 2, 2024
4f2f2af
Implemented UI ChartWidget components
miksrv Aug 3, 2024
78d7ca3
Added UI widgets to main page
miksrv Aug 3, 2024
a1beff9
Implemented header weather updated time
miksrv Aug 9, 2024
a998ac2
Added new icons, improved widgets
miksrv Aug 9, 2024
f9d8012
Added language translations
miksrv Aug 9, 2024
fd0acef
Improved UI Widget Component
miksrv Aug 9, 2024
15c8dce
Finalize UI design skeleton
miksrv Aug 9, 2024
88e9e22
Added widget loading skeleton
miksrv Aug 9, 2024
399d895
Added PHP Doc for API models
miksrv Aug 12, 2024
d5fe24d
Removed API migration models
miksrv Aug 12, 2024
3282280
Removed API migration controller
miksrv Aug 12, 2024
d2ec428
Refactoring UI application slice (Redux RTK)
miksrv Aug 12, 2024
ecb7a24
Implemented new UI component - Table
miksrv Aug 12, 2024
b846869
Implemented UI forecast API methods
miksrv Aug 12, 2024
04ae302
Refactoring (simplify) API weather models
miksrv Aug 12, 2024
34c5b8f
Refactoring API date response
miksrv Aug 12, 2024
c8d124d
Improved UI main page
miksrv Aug 12, 2024
418d56b
Added API weather conditions config
miksrv Aug 13, 2024
6bc2ab1
Implemented weather ID convert libraries
miksrv Aug 13, 2024
0d2d95f
Improved API system functions
miksrv Aug 13, 2024
c8a7cb5
Refactoring API DB models and entitles (removed weather_main and weat…
miksrv Aug 13, 2024
3c150de
Updated UI API Models (removed WeatherIcon and WeatherMain)
miksrv Aug 13, 2024
5ae9be8
Fixed UI date models
miksrv Aug 13, 2024
3501a88
Added UI weather icons
miksrv Aug 13, 2024
36ed77e
Updated 404 page
miksrv Aug 19, 2024
3904c8b
Improved UI styles for mobile devices
miksrv Aug 20, 2024
2ec0fc4
Implemented UI weather icon component
miksrv Aug 20, 2024
4a6be80
Improved UI table component, added new props
miksrv Aug 20, 2024
ee2a74c
Added PHP documentation for Weather Data ID
miksrv Aug 20, 2024
535ab39
Removed UI svg icon files
miksrv Aug 20, 2024
2c2122a
Refactoring UI WidgetForecastTable component
miksrv Aug 21, 2024
45abfd5
Implemented UI Wind Direction Icon Component
miksrv Aug 21, 2024
ea68b18
Added UI utils functions
miksrv Aug 21, 2024
122ef4d
Fixed CI/CD GitHub Action
miksrv Aug 21, 2024
14aa1cb
Implemented new UI component WidgetChart
miksrv Aug 22, 2024
2f5f839
Added UI locales
miksrv Aug 22, 2024
0380765
Improved UI table component
miksrv Aug 22, 2024
396cc70
Improved UI main page layout
miksrv Aug 22, 2024
8e31a76
Implemented new UI functions, helpers and icons
miksrv Aug 22, 2024
e08b1aa
Improved UI chart component
miksrv Aug 23, 2024
5e26696
Removed unused styles, added styles for chart widget
miksrv Aug 23, 2024
6d1bc25
Added global configuration for chart
miksrv Aug 23, 2024
519eb95
improved UI chart component
miksrv Aug 27, 2024
cb206d6
Fixed UI chart config, fixed tooltip undefined value error
miksrv Aug 27, 2024
2053347
Fixed UI themes issues, CSS
miksrv Aug 29, 2024
f55a250
Improved UI components
miksrv Aug 29, 2024
aa32db2
Implemented new UI theme switcher component
miksrv Aug 29, 2024
653b576
Added additional locales for WidgetForecastTable
miksrv Aug 29, 2024
1f71389
Added CI/CD config
miksrv Aug 29, 2024
d14d36a
Fixed UI build issues
miksrv Aug 29, 2024
36c8684
Updated CI/CD UI Deploy action
miksrv Aug 29, 2024
00dcae0
Fixed Prettier issues, updated ESLinter rules for comments
miksrv Aug 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
60 changes: 60 additions & 0 deletions .github/workflows/api-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: API Deploy

on:
push:
branches:
- main
paths:
- 'server/**/*'

# https://github.com/codeigniter4/CodeIgniter4/blob/develop/.github/workflows/deploy-apidocs.yml
jobs:
api-ssh-deploy:
name: Production
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

# Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: mbstring, intl, curl, dom
coverage: none

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
working-directory: server

- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('server/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --no-dev --no-progress --prefer-dist --optimize-autoloader
working-directory: server

- name: Install LFTP
run: sudo apt install lftp

- name: Configure LFTP
run: mkdir ~/.lftp && echo "set ssl:verify-certificate false;" >> ~/.lftp/rc

- name: Load Secrets
run: echo "machine ${{ secrets.FTP_HOSTNAME }} login ${{ secrets.FTP_USERNAME }} password ${{ secrets.FTP_PASSWORD }}" > ~/.netrc

- name: Upload Folder
run: |
lftp -e "put -O / .htaccess" ${{ secrets.FTP_HOSTNAME }}
lftp -e "rm -rf app" ${{ secrets.FTP_HOSTNAME }}
lftp -e "mirror --parallel=100 -R app" ${{ secrets.FTP_HOSTNAME }}
lftp -e "mirror --parallel=100 -R vendor" ${{ secrets.FTP_HOSTNAME }}
lftp -e "mirror --parallel=100 -R public" ${{ secrets.FTP_HOSTNAME }}
lftp -e "mirror --parallel=100 -R writable" ${{ secrets.FTP_HOSTNAME }}
working-directory: server
67 changes: 41 additions & 26 deletions .github/workflows/ui-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,79 @@ on:
branches:
- main
paths:
- 'frontend/**/*'
- 'client/**/*'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
ui-checks:
if: github.event.pull_request.draft == false
name: Build & Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
cache-dependency-path: 'frontend/package-lock.json'
node-version: 20
cache: 'yarn'
cache-dependency-path: 'client/yarn.lock'

- name: Cache node modules
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-npm
with:
path: |
frontend/node_modules
client/node_modules
~/.npm
key: ${{ runner.os }}-modules-${{ hashFiles('frontend/package-lock.json') }}
${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-modules-${{ hashFiles('client/yarn.lock') }}
restore-keys: |
${{ runner.os }}-modules-
${{ runner.os }}-

- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
name: Install dependencies
working-directory: frontend
run: npm ci -f
working-directory: client
run: yarn install

- name: Linter
run: npm run eslint:check
working-directory: frontend
run: yarn eslint:check
working-directory: client

- name: Prettier
run: npm run prettier:check
working-directory: frontend
run: yarn prettier:check
working-directory: client

- name: Cache UI build
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-build
with:
path: client/out
key: ${{ runner.os }}-build-${{ hashFiles('frontend/**/*.ts', 'frontend/**/*.tsx') }}
path: client/.next
key: ${{ runner.os }}-build-${{ hashFiles('client/**/*.ts', 'client/**/*.tsx') }}
restore-keys: |
${{ runner.os }}-build-
${{ runner.os }}-

- if: ${{ steps.cache-build.outputs.cache-hit != 'true' }}
name: Build UI
name: Configure Client
run: |
export dateNow=$(date +"%d.%m.%Y %H:%M")
echo "export const update = '$dateNow'" > src/update.ts
npm run build --if-present
working-directory: frontend
echo "NEXT_PUBLIC_API_HOST = '${{ secrets.NEXT_PUBLIC_API_HOST }}'
NEXT_PUBLIC_SITE_LINK = '${{ secrets.NEXT_PUBLIC_SITE_LINK }}'" > .env
working-directory: client

# - name: UI Unit Tests
# run: yarn test
# working-directory: client

- name: Test
run: npm run test:coverage
working-directory: frontend
- if: ${{ steps.cache-build.outputs.cache-hit != 'true' }}
name: Build UI
run: |
export dateNow=$(date +"%Y-%m-%dT%H:%M")
echo "export const update = '$dateNow'" > update.ts
yarn build
working-directory: client
116 changes: 84 additions & 32 deletions .github/workflows/ui-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,72 +1,124 @@
name: FTP Deploy
name: UI Deploy

on:
push:
branches:
- main
paths:
- 'frontend/**/*'
- 'client/**/*'

pull_request:
branches:
- main

jobs:
ftp-ui-deploy:
ui-ssh-deploy:
name: Production
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
cache-dependency-path: 'frontend/package-lock.json'
node-version: 20
cache: 'yarn'
cache-dependency-path: 'client/yarn.lock'

- name: Cache node modules
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-npm
with:
path: |
frontend/node_modules
client/node_modules
~/.npm
key: ${{ runner.os }}-modules-${{ hashFiles('frontend/package-lock.json') }}
${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-modules-${{ hashFiles('client/yarn.lock') }}
restore-keys: |
${{ runner.os }}-modules-
${{ runner.os }}-

- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
name: Install dependencies
working-directory: frontend
run: npm ci -f

- name: Configure Client
run: echo "REACT_APP_API_HOST = '${{ secrets.CLIENT_API_HOST }}'" > .env
working-directory: frontend
working-directory: client
run: yarn install

- name: Cache UI build
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-build
with:
path: client/out
key: ${{ runner.os }}-build-${{ hashFiles('frontend/**/*.ts', 'frontend/**/*.tsx') }}
path: client/.next
key: ${{ runner.os }}-build-${{ hashFiles('client/**/*.ts', 'client/**/*.tsx') }}
restore-keys: |
${{ runner.os }}-build-
${{ runner.os }}-

- if: ${{ steps.cache-build.outputs.cache-hit != 'true' }}
name: Configure Client
run: |
echo "NEXT_PUBLIC_API_HOST = '${{ secrets.NEXT_PUBLIC_API_HOST }}'
NEXT_PUBLIC_SITE_LINK = '${{ secrets.NEXT_PUBLIC_SITE_LINK }}'" > .env
working-directory: client

- if: ${{ steps.cache-build.outputs.cache-hit != 'true' }}
name: Build UI
run: |
export dateNow=$(date +"%d.%m.%Y %H:%M")
echo "export const update = '$dateNow'" > src/update.ts
npm run build --if-present
working-directory: frontend
export dateNow=$(date +"%Y-%m-%dT%H:%M")
echo "export const update = '$dateNow'" > update.ts
yarn build
working-directory: client

- name: Install LFTP client
run: sudo apt install lftp
- name: Configure SSH
env:
SSH_HOST: ${{secrets.SSH_HOST}}
SSH_PORT: ${{secrets.SSH_PORT}}
SSH_USER: ${{secrets.SSH_USER}}
SSH_KEY: ${{secrets.SSH_KEY}}
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/deploy
chmod 400 ~/.ssh/deploy
cat >>~/.ssh/config <<END
Host vps
HostName $SSH_HOST
Port $SSH_PORT
User $SSH_USER
IdentityFile ~/.ssh/deploy
StrictHostKeyChecking no
END

- name: Configure LFTP
run: mkdir ~/.lftp && echo "set ssl:verify-certificate false;" >> ~/.lftp/rc
# If we just use nginx and the application is exported to plain HTML
#- name: Send files
# run: rsync -avz -e ssh ./client/out/ vps:/var/www/meteo.miksoft.pro

# If we run NextJS on a Node server using PM2
- name: Send files
run: |
ssh vps "cd /var/www/meteo.miksoft.pro && rm -rf .next"
rsync -avz -e ssh client/.next/standalone/ vps:/var/www/meteo.miksoft.pro
rsync -avz -e ssh client/.next/static vps:/var/www/meteo.miksoft.pro/.next
rsync -avz -e ssh client/public vps:/var/www/meteo.miksoft.pro
rsync -avz -e ssh client/ecosystem.config.js vps:/var/www/meteo.miksoft.pro

- name: Load Secrets
run: echo "machine ${{ secrets.FTP_HOSTNAME }} login ${{ secrets.FTP_USERNAME }} password ${{ secrets.FTP_PASSWORD }}" > ~/.netrc
# For the first launch of the application on the server:
# pm2 start ecosystem.config.js && pm2 save
- name: Restart PM2
run: ssh vps "pm2 restart meteo.miksoft.pro"

- name: Deploy UI
run: lftp -e "mirror --parallel=100 -R frontend/build/ /" ${{ secrets.FTP_HOSTNAME }}
# If for deployment we use not SSH, but an FTP connection
# - name: Export UI
# working-directory: client
# run: yarn export
#
# - name: Install LFTP
# run: sudo apt install lftp
#
# - name: Configure LFTP
# run: mkdir ~/.lftp && echo "set ssl:verify-certificate false;" >> ~/.lftp/rc
#
# - name: Load Secrets
# run: echo "machine ${{ secrets.FTP_HOSTNAME }} login ${{ secrets.FTP_USERNAME }} password ${{ secrets.FTP_PASSWORD }}" > ~/.netrc
#
# - name: Upload Folder
# run: lftp -e "mirror --parallel=100 -R client/out/ /" ${{ secrets.FTP_HOSTNAME }}
Loading
Loading