-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into TET-3959/add-tracking-to-all-FA-filtres
- Loading branch information
Showing
22 changed files
with
652 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Déploiement à la demande de l'api d'automatisation technique | ||
run-name: Déploiement de l'api d'automatisation technique sur ${{ github.event.inputs.target }} | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
target: | ||
type: choice | ||
description: Quel environnement ? | ||
options: | ||
- preprod | ||
- prod | ||
|
||
jobs: | ||
build-tools-automation-api: | ||
name: Build l'api d'automatisation technique | ||
environment: ${{ github.event.inputs.target }} | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: earthly/actions-setup@v1 | ||
with: | ||
github-token: ${{ secrets.GH_TOKEN }} | ||
version: ^0.8.0 | ||
- name: Login into registry | ||
run: docker login ghcr.io/territoiresentransitions --username "${{ secrets.GH_USER }}" --password "${{ secrets.GH_TOKEN }}" | ||
|
||
- name: Build and push tools-automation-api image | ||
run: > | ||
earthly | ||
--use-inline-cache --save-inline-cache --push | ||
--platform=linux/amd64 | ||
+tools-automation-api-docker | ||
--ENV_NAME=${{ github.event.inputs.target }} | ||
deploy-tools-automation-api: | ||
name: Déploie l'api d'automatisation technique | ||
needs: build-tools-automation-api | ||
environment: ${{ github.event.inputs.target }} | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: earthly/actions-setup@v1 | ||
with: | ||
github-token: ${{ secrets.GH_TOKEN }} | ||
version: ^0.8.0 | ||
- name: Login into registry | ||
run: docker login ghcr.io/territoiresentransitions --username "${{ secrets.GH_USER }}" --password "${{ secrets.GH_TOKEN }}" | ||
- name: Deploy tools-automation-api on Koyeb | ||
run: > | ||
earthly | ||
--use-inline-cache --save-inline-cache | ||
+tools-automation-api-deploy | ||
--ENV_NAME=${{ github.event.inputs.target }} | ||
--KOYEB_API_KEY=${{ secrets.KOYEB_API_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": ["../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
VERSION 0.8 | ||
|
||
build: | ||
FROM ../../+front-deps | ||
|
||
COPY . ./apps/tools-automation-api | ||
|
||
RUN pnpm build:tools-automation-api | ||
|
||
SAVE ARTIFACT dist /dist AS LOCAL earthly-build/dist | ||
|
||
docker: | ||
FROM ../../+prod-deps | ||
|
||
ARG DOCKER_IMAGE=$TOOLS_AUTOMATION_API_IMG_NAME | ||
|
||
ENV NODE_ENV production | ||
ENV PORT 3000 | ||
ENV GIT_COMMIT_SHORT_SHA=$EARTHLY_GIT_SHORT_HASH | ||
ENV GIT_COMMIT_TIMESTAMP=$EARTHLY_GIT_COMMIT_TIMESTAMP | ||
ENV APPLICATION_VERSION=$APPLICATION_VERSION | ||
|
||
EXPOSE ${PORT} | ||
|
||
COPY +build/dist ./dist | ||
|
||
CMD ["node", "dist/apps/tools-automation-api/src/main.js"] | ||
SAVE IMAGE --push $DOCKER_IMAGE | ||
|
||
deploy: ## Déploie le backend dans une app Koyeb existante | ||
ARG --required KOYEB_API_KEY | ||
ARG --required DEPLOYMENT_TIMESTAMP | ||
ARG SERVICE_NAME=$ENV_NAME-tools-automation-api | ||
FROM ../../+koyeb --KOYEB_API_KEY=$KOYEB_API_KEY | ||
|
||
RUN ./koyeb services update $SERVICE_NAME/tools-automation-api \ | ||
--debug \ | ||
--docker $BACKEND_IMG_NAME \ | ||
--env ENV_NAME=$ENV_NAME \ | ||
--env DEPLOYMENT_TIMESTAMP=$DEPLOYMENT_TIMESTAMP | ||
|
||
test-build: ## construit une image pour exécuter les tests du backend | ||
FROM ../../+front-deps | ||
COPY . ./apps/tools-automation-api | ||
|
||
CMD pnpm run test:tools-automation-api | ||
SAVE IMAGE tools-automation-api-test:latest | ||
|
||
test: ## lance les tests | ||
ARG network=host | ||
LOCALLY | ||
RUN earthly +test-build | ||
RUN docker run --rm \ | ||
--name tools-automation-api-test_tet \ | ||
--network $network \ | ||
tools-automation-api-test:latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default { | ||
displayName: 'tools-automation-api', | ||
preset: '../../jest.preset.js', | ||
testEnvironment: 'node', | ||
transform: { | ||
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }], | ||
}, | ||
moduleFileExtensions: ['ts', 'js', 'html'], | ||
coverageDirectory: '../../coverage/apps/tools-automation-api', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/nest-cli", | ||
"collection": "@nestjs/schematics", | ||
"sourceRoot": "./src", | ||
"entryFile": "apps/tools-automation-api/src/main", | ||
"compilerOptions": { | ||
"deleteOutDir": true, | ||
"tsConfigPath": "tsconfig.app.json" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "tools-automation-api", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "apps/tools-automation-api/src", | ||
"projectType": "application", | ||
"tags": [], | ||
"targets": { | ||
"dev": { | ||
"command": "nest start --watch", | ||
"// debug": "nest start --debug --watch", | ||
"options": { | ||
"cwd": "apps/tools-automation-api" | ||
} | ||
}, | ||
"build": { | ||
"command": "nest build", | ||
"options": { | ||
"cwd": "apps/tools-automation-api" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
|
||
import { AppController } from './app.controller'; | ||
import { AppService } from './app.service'; | ||
|
||
describe('AppController', () => { | ||
let app: TestingModule; | ||
|
||
beforeAll(async () => { | ||
app = await Test.createTestingModule({ | ||
controllers: [AppController], | ||
providers: [AppService], | ||
}).compile(); | ||
}); | ||
|
||
describe('getData', () => { | ||
it('should return "Hello API"', () => { | ||
const appController = app.get<AppController>(AppController); | ||
expect(appController.getData()).toEqual({ message: 'Hello API' }); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Controller, Get } from '@nestjs/common'; | ||
|
||
import { AppService } from './app.service'; | ||
|
||
@Controller() | ||
export class AppController { | ||
constructor(private readonly appService: AppService) {} | ||
|
||
@Get() | ||
getData() { | ||
return this.appService.getData(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Module } from '@nestjs/common'; | ||
|
||
import { AppController } from './app.controller'; | ||
import { AppService } from './app.service'; | ||
|
||
@Module({ | ||
imports: [], | ||
controllers: [AppController], | ||
providers: [AppService], | ||
}) | ||
export class AppModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Test } from '@nestjs/testing'; | ||
|
||
import { AppService } from './app.service'; | ||
|
||
describe('AppService', () => { | ||
let service: AppService; | ||
|
||
beforeAll(async () => { | ||
const app = await Test.createTestingModule({ | ||
providers: [AppService], | ||
}).compile(); | ||
|
||
service = app.get<AppService>(AppService); | ||
}); | ||
|
||
describe('getData', () => { | ||
it('should return "Hello API"', () => { | ||
expect(service.getData()).toEqual({ message: 'Hello API' }); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
|
||
@Injectable() | ||
export class AppService { | ||
getData(): { message: string } { | ||
return { message: 'Hello API' }; | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* This is not a production server yet! | ||
* This is only a minimal backend to get started. | ||
*/ | ||
|
||
import { Logger } from '@nestjs/common'; | ||
import { NestFactory } from '@nestjs/core'; | ||
|
||
import { AppModule } from './app/app.module'; | ||
|
||
async function bootstrap() { | ||
const app = await NestFactory.create(AppModule); | ||
const globalPrefix = 'api'; | ||
app.setGlobalPrefix(globalPrefix); | ||
const port = process.env.PORT || 3000; | ||
await app.listen(port); | ||
Logger.log( | ||
`🚀 Application is running on: http://localhost:${port}/${globalPrefix}` | ||
); | ||
} | ||
|
||
bootstrap(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"types": ["node"] | ||
}, | ||
"exclude": [ | ||
"vitest.config.mts", | ||
"src/**/*.spec.ts", | ||
"src/**/*.e2e-spec.ts", | ||
"src/**/*.test.ts" | ||
], | ||
"include": [ | ||
"src/**/*.ts", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"module": "NodeNext", | ||
"moduleResolution": "NodeNext" | ||
}, | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.app.json" | ||
}, | ||
{ | ||
"path": "./tsconfig.spec.json" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"types": [ | ||
"vitest/globals", | ||
"vitest/importMeta", | ||
"vite/client", | ||
"node", | ||
"vitest" | ||
], | ||
"module": "NodeNext", | ||
"moduleResolution": "NodeNext" | ||
}, | ||
"include": [ | ||
"vitest.config.mts", | ||
"src/**/*.test.ts", | ||
"src/**/*.spec.ts", | ||
"src/**/*.e2e-spec.ts", | ||
"test/**/*.e2e-spec.ts", | ||
"src/**/*.test.tsx", | ||
"src/**/*.spec.tsx", | ||
"src/**/*.test.js", | ||
"src/**/*.spec.js", | ||
"src/**/*.test.jsx", | ||
"src/**/*.spec.jsx", | ||
"src/**/*.d.ts" | ||
] | ||
} |
Oops, something went wrong.