Skip to content

Commit

Permalink
pnpm adjustements (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
loicknuchel authored Jun 17, 2024
1 parent 7141de9 commit c6d718b
Show file tree
Hide file tree
Showing 49 changed files with 596 additions and 233 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: "⚒️ Build docker image"

on:
pull_request:
types: [ready_for_review]

jobs:
build_docker:
name: "⚒️ Build docker image"
runs-on: ubuntu-latest
env:
MIX_ENV: test
strategy:
matrix:
elixir: [ '1.14' ]
otp: [ '25' ]
services:
db:
image: postgres:14
ports: [ '5432:5432' ]
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Get deps cache
uses: actions/cache@v4
with:
path: deps/
key: deps-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }}

- name: Get build cache
uses: actions/cache@v4
with:
path: _build/test/
key: build-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }}

- name: Setup elixir
uses: erlef/setup-elixir@v1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9.1.4+sha256.30a1801ac4e723779efed13a21f4c39f9eb6c9fbb4ced101bce06b422593d7c9

- name: Install Dependencies
env: # needs env for `mix ecto.setup`
PHX_HOST: localhost
PORT: 4000
FILE_STORAGE_ADAPTER: local
run: pnpm run setup

- name: Build docker image
run: docker build -t azimutt .
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
Expand Down
56 changes: 30 additions & 26 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: "👾 Azimutt CI"

on:
push:
branches-ignore:
- refs/tags/*
pull_request:
types: [ open ]
types: [open]

jobs:
cancel:
Expand Down Expand Up @@ -36,47 +37,50 @@ jobs:
--health-retries 5
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup elixir
uses: erlef/setup-elixir@v1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}
uses: actions/checkout@v4

- name: Get deps cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: deps/
key: deps-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }}

- name: Get build cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: _build/test/
key: build-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }}

- name: Setup elixir
uses: erlef/setup-elixir@v1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9.1.4+sha256.30a1801ac4e723779efed13a21f4c39f9eb6c9fbb4ced101bce06b422593d7c9

- name: Install Dependencies
run: |
npm install
npm run libs:setup
npm run gateway:setup
npm run cli:setup
npm run fe:build
env: # needs env for `mix ecto.setup`
PHX_HOST: localhost
PORT: 4000
FILE_STORAGE_ADAPTER: local
run: pnpm run setup

- name: Check build
run: npm run build

- name: Check format
run: |
npm run ex:install
npm run format
run: npm run format

- name: Check lint
run: |
npm run lint
- name: Check build
run: |
npm run build
run: npm run lint

- name: Run tests
env:
PHX_HOST: localhost
PORT: 4000
FILE_STORAGE_ADAPTER: local
run: |
npm run test
run: npm test
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,13 @@ COPY backend/priv priv
COPY backend/assets assets

COPY package.json .
COPY pnpm-workspace.yaml .
COPY pnpm-lock.yaml .
COPY libs/ libs
COPY frontend/ frontend

RUN npm run docker
RUN npm install -g [email protected]
RUN npm run build:docker

# Compile the release
COPY backend/lib lib
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ We have a lot of projects with a lot of commands, here is how they are structure
- `format` allows to run execute code formatting
- `lint` allows to run execute linters
- `build` generate compilation output
- `docker` same as `build` but in the docker image (paths are different 😕)
- `build:docker` same as `build` but in the docker image (paths are different 😕)
- `update` bumps library versions

### Development commands
Expand Down
8 changes: 8 additions & 0 deletions backend/priv/repo/seeds.exs
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
alias Azimutt.Accounts.User
alias Azimutt.CleverCloud
alias Azimutt.Gallery.Sample
alias Azimutt.Heroku
alias Azimutt.Heroku.Resource, as: HerokuResource
alias Azimutt.Organizations.Organization
alias Azimutt.Organizations.OrganizationMember
alias Azimutt.Organizations.OrganizationInvitation
alias Azimutt.Projects.Project
alias Azimutt.Projects.ProjectToken
alias Azimutt.Projects.Project.Storage
alias Azimutt.Tracking.Event

Azimutt.Repo.delete_all(Event)
Azimutt.Repo.delete_all(HerokuResource)
Azimutt.Repo.delete_all(Sample)
Azimutt.Repo.delete_all(ProjectToken)
Azimutt.Repo.delete_all(Project)
Azimutt.Repo.delete_all(OrganizationInvitation)
Azimutt.Repo.delete_all(OrganizationMember)
Expand Down
3 changes: 3 additions & 0 deletions backend/test/azimutt/gallery_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule Azimutt.GalleryTest do
use Azimutt.DataCase
alias Azimutt.Gallery
alias Azimutt.Gallery.Sample
alias Azimutt.Utils.Result

describe "samples" do
Expand All @@ -10,6 +11,8 @@ defmodule Azimutt.GalleryTest do
import Azimutt.GalleryFixtures

test "list_samples/0 returns all samples" do
Azimutt.Repo.delete_all(Sample)
assert [] == Gallery.list_samples()
user = user_fixture()
organization = organization_fixture(user)
project = project_fixture(organization, user)
Expand Down
6 changes: 1 addition & 5 deletions browser-extension/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"compilerOptions": {
"strict": false,
"lib": [
"es5",
"dom",
"es2015.promise"
],
"lib": ["ES2021", "DOM"],
}
}
1 change: 0 additions & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"lint": "tsc --noEmit",
"build": "rm -rf ./out && tsc",
"exec": "npm run build && node ./out/index.js",
"local": "sudo pnpm install -g && azimutt",
"dry-publish": "pnpm run build && pnpm test && pnpm pack"
},
"dependencies": {
Expand Down
4 changes: 3 additions & 1 deletion desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@electron-forge/maker-zip": "^7.4.0",
"@electron-forge/plugin-webpack": "^7.4.0",
"@electron-forge/publisher-github": "^7.4.0",
"@electron-forge/shared-types": "^7.4.0",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
"@vercel/webpack-asset-relocator-loader": "^1.7.3",
Expand All @@ -56,6 +57,7 @@
"style-loader": "^4.0.0",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"typescript": "^5.4.5"
"typescript": "^5.4.5",
"webpack": "^5.92.0"
}
}
4 changes: 4 additions & 0 deletions desktop/src/main/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ export const setupBridge = (): void => {
withConnector(url, (conn, parsedUrl) => conn.getSchema(application, parsedUrl, {...opts, inferRelations: true, ignoreErrors: true})),
getQueryHistory: (url: DatabaseUrl): Promise<DatabaseQuery[]> =>
withConnector(url, (conn, parsedUrl) => conn.getQueryHistory(application, parsedUrl, opts)),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
execute: (url: DatabaseUrl, query: string, parameters: any[]): Promise<QueryResults> =>
withConnector(url, (conn, parsedUrl) => conn.execute(application, parsedUrl, query, parameters, opts)),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
analyze: (url: DatabaseUrl, query: string, parameters: any[]): Promise<QueryAnalyze> =>
withConnector(url, (conn, parsedUrl) => conn.analyze(application, parsedUrl, query, parameters, opts)),
getEntityStats: (url: DatabaseUrl, ref: EntityRef): Promise<ConnectorEntityStats> =>
Expand All @@ -40,7 +42,9 @@ export const setupBridge = (): void => {
ipcMain.handle('ping', () => bridge.ping())
ipcMain.handle('getSchema', (e: IpcMainInvokeEvent, url: DatabaseUrl) => bridge.getSchema(url))
ipcMain.handle('getQueryHistory', (e: IpcMainInvokeEvent, url: DatabaseUrl) => bridge.getQueryHistory(url))
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ipcMain.handle('execute', (e: IpcMainInvokeEvent, url: DatabaseUrl, query: string, parameters: any[]) => bridge.execute(url, query, parameters))
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ipcMain.handle('analyze', (e: IpcMainInvokeEvent, url: DatabaseUrl, query: string, parameters: any[]) => bridge.analyze(url, query, parameters))
ipcMain.handle('getEntityStats', (e: IpcMainInvokeEvent, url: DatabaseUrl, ref: EntityRef) => bridge.getEntityStats(url, ref))
ipcMain.handle('getAttributeStats', (e: IpcMainInvokeEvent, url: DatabaseUrl, ref: AttributeRef) => bridge.getAttributeStats(url, ref))
Expand Down
3 changes: 2 additions & 1 deletion desktop/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import * as process from "process";
import * as util from "util"
import {setupBridge} from "./bridge"

// eslint-disable-next-line @typescript-eslint/no-var-requires
require('update-electron-app')()

// This allows TypeScript to pick up the magic constants that's auto-generated by Forge's Webpack
// plugin that tells the Electron app where to look for the Webpack-bundled app code (depending on
// whether you're running in development or production).
declare const MAIN_WINDOW_WEBPACK_ENTRY: string
// declare const MAIN_WINDOW_WEBPACK_ENTRY: string
declare const MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY: string

// Handle creating/removing shortcuts on Windows when installing/uninstalling.
Expand Down
3 changes: 3 additions & 0 deletions desktop/src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
QueryResults
} from "@azimutt/models";

// eslint-disable-next-line @typescript-eslint/no-var-requires
const {contextBridge, ipcRenderer} = require('electron')

/* eslint @typescript-eslint/no-explicit-any: 0 */
Expand All @@ -26,7 +27,9 @@ contextBridge.exposeInMainWorld('desktop', {
ping: () => ipcRenderer.invoke('ping'),
getSchema: (url: DatabaseUrl): Promise<Database> => ipcRenderer.invoke('getSchema', url),
getQueryHistory: (url: DatabaseUrl): Promise<DatabaseQuery[]> => ipcRenderer.invoke('getQueryHistory', url),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
execute: (url: DatabaseUrl, query: string, parameters: any[]): Promise<QueryResults> => ipcRenderer.invoke('execute', url, query, parameters),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
analyze: (url: DatabaseUrl, query: string, parameters: any[]): Promise<QueryAnalyze> => ipcRenderer.invoke('analyze', url, query, parameters),
getEntityStats: (url: DatabaseUrl, ref: EntityRef): Promise<ConnectorEntityStats> => ipcRenderer.invoke('getEntityStats', url, ref),
getAttributeStats: (url: DatabaseUrl, ref: AttributeRef): Promise<ConnectorAttributeStats> => ipcRenderer.invoke('getAttributeStats', url, ref),
Expand Down
4 changes: 2 additions & 2 deletions desktop/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "ES6",
"target": "ES2021",
"allowJs": true,
"module": "commonjs",
"skipLibCheck": true,
Expand All @@ -15,5 +15,5 @@
"*": ["node_modules/*"]
}
},
"include": ["src/**/*"]
"include": ["src/**/*", "*.ts"]
}
5 changes: 2 additions & 3 deletions desktop/webpack.main.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Configuration } from 'webpack';

import { rules } from './webpack.rules';
import type {Configuration} from 'webpack';
import {rules} from './webpack.rules';

export const mainConfig: Configuration = {
/**
Expand Down
8 changes: 4 additions & 4 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@
"lint": "pnpm run \"/^(ts|elm):lint$/\"",
"build": "pnpm run \"/^\\w+:build$/\"",
"update": "elm-json upgrade --unsafe --yes && cd review && elm-json upgrade --unsafe --yes",
"docker": "pnpm run tailwind:docker && pnpm run ts:docker && pnpm run elm:docker",
"build:docker": "pnpm run build:docker:tailwind && pnpm run build:docker:ts && pnpm run build:docker:elm",
"elm:start": "elm-go ./src/Main.elm --dir=../backend/priv/static/elm --pushstate --no-server -- --output=../backend/priv/static/elm/dist/elm.js",
"elm:start:alone": "elm-go ./src/Main.elm --dir=../backend/priv/static/elm --pushstate --port=4001 --proxy-prefix=/api --proxy-host=http://localhost:4000/api -- --output=../backend/priv/static/elm/dist/elm.js",
"elm:test": "elm-test --fuzz 5",
"elm:lint": "elm-review",
"elm:format": "elm-format src tests --validate",
"elm:build": "elm-spa gen && elm make src/Main.elm --optimize --output=../backend/priv/static/elm/dist/elm.js",
"elm:docker": "npx elm-spa gen && elm make src/Main.elm --optimize --output=../priv/static/elm/dist/elm.js",
"build:docker:elm": "npx elm-spa gen && elm make src/Main.elm --optimize --output=../priv/static/elm/dist/elm.js",
"ts:start": "./node_modules/.bin/esbuild ts-src/index.ts --outfile=../backend/priv/static/elm/script.js --bundle --sourcemap --watch",
"ts:test": "jest",
"ts:lint": "tsc --project tsconfig.json --noEmit && rm -rf ./public",
"ts:build": "./node_modules/.bin/esbuild ts-src/index.ts --outfile=../backend/priv/static/elm/script.js --bundle --sourcemap --minify",
"ts:docker": "./node_modules/.bin/esbuild ts-src/index.ts --outfile=../priv/static/elm/script.js --bundle --sourcemap --minify",
"build:docker:ts": "./node_modules/.bin/esbuild ts-src/index.ts --outfile=../priv/static/elm/script.js --bundle --sourcemap --minify",
"tailwind:start": "tailwindcss -i ../backend/priv/static/elm/styles.css -o ../backend/priv/static/elm/dist/styles.css --watch",
"tailwind:build": "tailwindcss -i ../backend/priv/static/elm/styles.css -o ../backend/priv/static/elm/dist/styles.css --minify",
"tailwind:docker": "tailwindcss -i ../priv/static/elm/styles.css -o ../priv/static/elm/dist/styles.css --minify",
"build:docker:tailwind": "npx tailwindcss -i ../priv/static/elm/styles.css -o ../priv/static/elm/dist/styles.css --minify",
"book": "elm-book src/Components/Book.elm --dir=../backend/priv/static/elm --start-page=book.html --port 4002 -- --output=../backend/priv/static/elm/dist/book.js"
},
"dependencies": {
Expand Down
6 changes: 4 additions & 2 deletions gateway/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
NODE_ENV=development
LOG_LEVEL=info
API_HOST=localhost
API_PORT=4177
CORS_ALLOW_ORIGIN=https://azimutt.app
API_PORT=3000
# API_PORT=4177
CORS_ALLOW_ORIGIN=http://localhost:4000
# CORS_ALLOW_ORIGIN=https://azimutt.app
Loading

0 comments on commit c6d718b

Please sign in to comment.