Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

PIN-5952: Scaffolding Turborepo and packages #1

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APPLICATION_NAME="tracing-kpi"
32 changes: 32 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = {
extends: ["@pagopa/eslint-config/strong"],
parserOptions: {
tsconfigRootDir: __dirname,
project: "./tsconfig.eslint.json",
},
rules: {
// Any project level custom rule
"@typescript-eslint/switch-exhaustiveness-check": "error",
"default-case": "off",
"prefer-arrow/prefer-arrow-functions": "off",
eqeqeq: ["error", "smart"],
"@typescript-eslint/consistent-type-definitions": "off",
"sort-keys": "off",
"functional/prefer-readonly-type": "off",
"@typescript-eslint/no-shadow": "off",
"extra-rules/no-commented-out-code": "off",
"sonarjs/no-duplicate-string": "off",
"max-lines-per-function": "off",
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/no-use-before-define": "off",
},
ignorePatterns: [
".eslintrc.cjs",
"vitest.config.ts",
"**/src/model/generated/**/*.ts",
"**/src/generated/**/*.ts",
"**/dist",
"**/patchZodios.ts",
"**/paged.polyfill.js",
],
};
99 changes: 99 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: PR validation
on:
pull_request:

jobs:
formatting:
name: Check formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
node-version-file: ./package.json
- uses: pnpm/action-setup@v4
with:
run_install: true
- run: pnpm format:check

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
node-version-file: ./package.json
- uses: pnpm/action-setup@v4
with:
run_install: true
- run: pnpm lint

check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
node-version-file: ./package.json
- uses: pnpm/action-setup@v4
with:
run_install: true
- run: pnpm check

test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
node-version-file: ./package.json
- uses: pnpm/action-setup@v4
with:
run_install: true
- run: pnpm test

find_dockerfiles:
name: Find Dockerfiles
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.set_packages_output.outputs.packages }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Find packages
id: set_packages_output
run: |
PACKAGES=$(find packages -type f -path "*/Dockerfile" | awk -F'/' '{print $2}' | jq -R -s -c 'split("\n")[:-1]')
echo "packages=$PACKAGES" >> $GITHUB_OUTPUT

docker_build:
name: Build
needs: [find_dockerfiles]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs.find_dockerfiles.outputs.packages) }}
env:
DOCKER_BUILD_SUMMARY: "false"
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Build Docker image
uses: docker/build-push-action@a8d35412fb758de9162fd63e3fa3f0942bdedb4d
with:
context: .
file: packages/${{ matrix.package }}/Dockerfile
push: false

check_build_result:
name: Build Result
needs: [docker_build]
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Check build result
run: |
[[ ${{ needs.docker_build.result }} != 'success' ]] && exit 1
exit 0
46 changes: 46 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Created by https://www.toptal.com/developers/gitignore/api/node,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=node,visualstudiocode

### Node ###
# Logs
logs
*.log
.pnpm-debug.log*

# Dependency directories
node_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Output of 'npm pack'
*.tgz

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/
.turbo/

**/dist
packages/models/src/gen
packages/*/src/model/generated
packages/clients/*/src/model/generated
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
save-prefix=
auto-install-peers = false
strict-peer-dependencies = true
23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"private": true,
"name": "root",
"version": "1.0.0",
"engines": {
"node": ">=20"
},
"scripts": {
"test": "turbo test",
"build": "turbo build",
"check": "turbo check",
"lint": "turbo lint",
"lint:autofix": "turbo lint:autofix",
"format:check": "turbo format:check",
"format:write": "turbo format:write"
},
"devDependencies": {
"@tsconfig/strictest": "2.0.5",
"@tsconfig/node-lts": "20.1.3",
"turbo": "2.2.3"
},
"packageManager": "[email protected]"
}
1 change: 1 addition & 0 deletions packages/alb-logs-analytics-writer/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SERVICE_NAME="alb-logs-analytics-writer"
23 changes: 23 additions & 0 deletions packages/alb-logs-analytics-writer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM node:20.14.0-slim@sha256:5e8ac65a0231d76a388683d07ca36a9769ab019a85d85169fe28e206f7a3208e as build

RUN npm install -g [email protected] && corepack enable

WORKDIR /app
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc /app/

COPY ./packages/alb-logs-analytics-writer/package.json /app/packages/alb-logs-analytics-writer/package.json

RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile

COPY tsconfig.json turbo.json /app/
COPY ./packages/alb-logs-analytics-writer /app/packages/alb-logs-analytics-writer

RUN pnpm build && mkdir /out && cp -a --parents -t /out node_modules packages/alb-logs-analytics-writer/dist

FROM node:20.14.0-slim@sha256:5e8ac65a0231d76a388683d07ca36a9769ab019a85d85169fe28e206f7a3208e as final

COPY --from=build /out /app
WORKDIR /app/packages/alb-logs-analytics-writer
EXPOSE 3000

CMD ["node", "."]
3 changes: 3 additions & 0 deletions packages/alb-logs-analytics-writer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# pagopa-interop-be-alb-logs-analytics-writer

Node version required >=node18
36 changes: 36 additions & 0 deletions packages/alb-logs-analytics-writer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "pagopa-alb-logs-analytics-writer",
"private": true,
"version": "1.0.0",
"description": "PagoPA Interoperability load balance logs analytics writer",
"main": "dist",
"type": "module",
"exports": {
".": "./dist/index.js"
},
"scripts": {
"lint": "eslint . --ext .ts,.tsx",
"lint:autofix": "eslint . --ext .ts,.tsx --fix",
"format:check": "prettier --check src",
"format:write": "prettier --write src",
"start": "tsx -r 'dotenv-flow/config' --watch ./src/index.ts",
"build": "tsc",
"check": "tsc --project tsconfig.check.json"
},
"keywords": [],
"author": "",
"license": "Apache-2.0",
"devDependencies": {
"@pagopa/eslint-config": "3.0.0",
"@types/node": "20.14.6",
"prettier": "2.8.8",
"tsx": "4.19.1",
"typescript": "5.4.5",
"vitest": "1.6.0"
},
"dependencies": {
"dotenv-flow": "4.1.0",
"ts-pattern": "5.2.0",
"zod": "3.23.8"
}
}
Empty file.
7 changes: 7 additions & 0 deletions packages/alb-logs-analytics-writer/tsconfig.check.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"noEmit": true,
},
"include": ["src"]
}
9 changes: 9 additions & 0 deletions packages/alb-logs-analytics-writer/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist"
},
"include": [
"src"
]
}
1 change: 1 addition & 0 deletions packages/application-audit-analytics-writer/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SERVICE_NAME="application-audit-analytics-writer"
23 changes: 23 additions & 0 deletions packages/application-audit-analytics-writer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM node:20.14.0-slim@sha256:5e8ac65a0231d76a388683d07ca36a9769ab019a85d85169fe28e206f7a3208e as build

RUN npm install -g [email protected] && corepack enable

WORKDIR /app
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc /app/

COPY ./packages/application-audit-analytics-writer/package.json /app/packages/application-audit-analytics-writer/package.json

RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile

COPY tsconfig.json turbo.json /app/
COPY ./packages/application-audit-analytics-writer /app/packages/application-audit-analytics-writer

RUN pnpm build && mkdir /out && cp -a --parents -t /out node_modules packages/application-audit-analytics-writer/dist

FROM node:20.14.0-slim@sha256:5e8ac65a0231d76a388683d07ca36a9769ab019a85d85169fe28e206f7a3208e as final

COPY --from=build /out /app
WORKDIR /app/packages/application-audit-analytics-writer
EXPOSE 3000

CMD ["node", "."]
3 changes: 3 additions & 0 deletions packages/application-audit-analytics-writer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# pagopa-interop-be-audit-analytics-writer

Node version required >=node18
36 changes: 36 additions & 0 deletions packages/application-audit-analytics-writer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "pagopa-application-audit-analytics-writer",
"private": true,
"version": "1.0.0",
"description": "PagoPA Interoperability audit analytics writer",
"main": "dist",
"type": "module",
"exports": {
".": "./dist/index.js"
},
"scripts": {
"lint": "eslint . --ext .ts,.tsx",
"lint:autofix": "eslint . --ext .ts,.tsx --fix",
"format:check": "prettier --check src",
"format:write": "prettier --write src",
"start": "tsx -r 'dotenv-flow/config' --watch ./src/index.ts",
"build": "tsc",
"check": "tsc --project tsconfig.check.json"
},
"keywords": [],
"author": "",
"license": "Apache-2.0",
"devDependencies": {
"@pagopa/eslint-config": "3.0.0",
"@types/node": "20.14.6",
"prettier": "2.8.8",
"tsx": "4.19.1",
"typescript": "5.4.5",
"vitest": "1.6.0"
},
"dependencies": {
"dotenv-flow": "4.1.0",
"ts-pattern": "5.2.0",
"zod": "3.23.8"
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"noEmit": true,
},
"include": ["src"]
}
9 changes: 9 additions & 0 deletions packages/application-audit-analytics-writer/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist"
},
"include": [
"src"
]
}
1 change: 1 addition & 0 deletions packages/application-audit-archiver/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SERVICE_NAME="application-audit-archiver"
Loading