Skip to content

Commit

Permalink
Merge pull request #87 from InseeFr/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
EricThuaud authored Apr 30, 2024
2 parents bc3113b + 84a2c0d commit 18736d1
Show file tree
Hide file tree
Showing 141 changed files with 10,522 additions and 343 deletions.
8 changes: 8 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
VITE_API_ENDPOINT=http://localhost:8000
VITE_AUTH_TYPE=anonymous
VITE_OIDC_CLIENT_ID=
VITE_OIDC_ISSUER=https://localhost:8000
VITE_IDENTITY_PROVIDER=
VITE_ADMIN_LDAP_ROLE=admin
VITE_USER_LDAP_ROLE=user
VITE_APP_URL=http://localhost:5173
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/types/api.ts
20 changes: 9 additions & 11 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@ module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
ignorePatterns: ["dist", ".eslintrc.cjs", "api.ts"],
parser: "@typescript-eslint/parser",
plugins: ["react-refresh"],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
"@typescript-eslint/no-explicit-any": ["off"],
"react-refresh/only-export-components": ["off"],
},
}
};
104 changes: 104 additions & 0 deletions .github/workflows/ci-develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Develop Branch CI - Build release candidate

on:
push:
branches:
- develop

jobs:
check-version:
runs-on: ubuntu-latest
outputs:
release-version: ${{ steps.version.outputs.pe-version }}
tag-already-exists: ${{ steps.checkTag.outputs.exists }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get version
id: version
run: echo "pe-version=$(cat package.json | jq -r '.version')-rc" >> $GITHUB_OUTPUT

- name: Print version
run: echo ${{ steps.version.outputs.pe-version }}

- uses: mukunku/[email protected]
id: checkTag
with:
tag: ${{ steps.version.outputs.pe-version }}

- if: ${{ steps.checkTag.outputs.exists == 'true' }}
name: "Skip release"
run: echo "Nothing to tag/release, the release ${{ steps.version.outputs.pe-version }} already exists"

create-release:
needs: check-version
runs-on: ubuntu-latest
if: ${{ needs.check-version.outputs.tag-already-exists == 'false' }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
fetch-depth: 0

- name: Get previous tag
id: previousTag
run: echo "previousTag=$(git --no-pager tag --sort=creatordate --merged ${{ github.ref_name }} | grep '^[0-9]\+\.[0-9]\+\.[0-9]\+\-rc$' | tail -1)" >> $GITHUB_OUTPUT

- uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.check-version.outputs.release-version }}
target_commitish: ${{ github.head_ref || github.ref }}
name: ${{ needs.check-version.outputs.release-version }}
body: ${{steps.changelog.outputs.changes}}
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-release:
needs: create-release
runs-on: ubuntu-latest
steps:
- name: Extract branch name
shell: bash
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >>$GITHUB_OUTPUT
id: extract_branch

- uses: actions/checkout@v3
with:
ref: ${{ steps.extract_branch.outputs.branch }}

- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18
- run: yarn
- run: yarn build

- name: Upload build
uses: actions/upload-artifact@v3
with:
name: build
path: dist
docker:
needs:
- check-version
- build-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Download build
id: download
uses: actions/download-artifact@v3
with:
name: build
path: dist

- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: inseefr/platine-management
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
tags: "latest, ${{ needs.check-version.outputs.release-version }}"
2 changes: 2 additions & 0 deletions .github/workflows/ci-others.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ on:
push:
branches-ignore:
- main
- develop
pull_request:
branches-ignore:
- main
- develop

jobs:
test_lint:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/sonar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: Sonar analysis
on:
push:
branches:
- "**"
- main
- develop
pull_request:
types: [opened, synchronize, reopened]
jobs:
Expand All @@ -17,4 +18,4 @@ jobs:
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/dist/
/.eslintrc.js
/docs/
/CHANGELOG.md
/CHANGELOG.md
/src/types/api.ts
43 changes: 20 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
# Build environment
FROM node:18-alpine AS build
WORKDIR /app
COPY package.json yarn.lock .env ./
COPY public ./public
RUN yarn install --frozen-lockfile --network-timeout 600000
COPY jsconfig.json .prettierrc ./
COPY scripts ./scripts
COPY src ./src
RUN yarn build
COPY nginx.conf ./

# Production Env

FROM nginx:stable-alpine
COPY --from=build /app/nginx.conf /etc/nginx/conf.d/default.conf
WORKDIR /usr/share/nginx/html

## Remove default nginx index page
RUN rm -rf /usr/share/nginx/html/*

#Add build to nginx root webapp
ADD dist /usr/share/nginx/html

#Copy nginx configuration
RUN rm etc/nginx/conf.d/default.conf
COPY container/nginx.conf etc/nginx/conf.d/


WORKDIR /usr/share/nginx/html

# Add bash
RUN apk add --no-cache bash

## Copy .env file and shell script to container
COPY --from=build /app/build ./
COPY --from=build /app/scripts/env.sh .
COPY --from=build /app/scripts/.env .
COPY scripts/env.sh .
COPY scripts/.env .


## Make shell script executable and prevent windows encoding
RUN sed -i -e 's/\r$//' env.sh && sed -i -e 's/\r$//' .env && chmod +x env.sh
# Make our shell script executable
RUN chmod +x env.sh

# add non-root user
RUN touch /var/run/nginx.pid
Expand All @@ -38,4 +33,6 @@ EXPOSE 8080
USER nginx

# Start Nginx server
ENTRYPOINT bash -c "/usr/share/nginx/html/env.sh && nginx -g 'daemon off;'"
ENTRYPOINT sh -c "./vite-envs.sh && nginx -g 'daemon off;'"
RUN chmod +x vite-envs.sh

File renamed without changes.
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="icon" type="image/svg+xml" href="/logoInsee.png" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Montserrat:wght@500;600&family=Open+Sans:wght@400;600;700&display=swap"
href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600&family=Roboto&display=swap"
rel="stylesheet"
/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
Expand All @@ -16,7 +16,7 @@
padding: 0;
}
</style>
<title>Vite + React + TS</title>
<title>Platine Management</title>
</head>
<body>
<div id="root"></div>
Expand Down
18 changes: 16 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"name": "platine-management",
"private": true,
"version": "1.0.0",
"version": "1.0.18",
"type": "module",
"scripts": {
"dev": "vite",
"openapi": "o2ts ./openapi.json src/types/api.ts",
"build": "tsc && vite build",
"check": "tsc",
"lint:check": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint": "npm run lint:check -- --fix",
"_format": "prettier '**/*.{ts,tsx,json,md}'",
Expand All @@ -16,12 +18,24 @@
"dependencies": {
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@hookform/resolvers": "^3.3.4",
"@mui/icons-material": "^5.14.11",
"@mui/material": "^5.14.10",
"@tanstack/react-query": "^5.17.15",
"date-fns": "^3.3.1",
"oidc-spa": "^4.6.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"react-hook-form": "^7.50.0",
"react-markdown": "^9.0.0",
"react-router-dom": "^6.21.1",
"react-use": "^17.5.0",
"vite-envs": "^4.2.0",
"zod": "^3.22.4",
"zustand": "^4.5.0"
},
"devDependencies": {
"@grafikart/o2ts": "^0.1.14",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@typescript-eslint/eslint-plugin": "^6.0.0",
Expand Down
2 changes: 1 addition & 1 deletion public/configuration.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"authType": "OIDC",
"authType": "anonymous",
"apiUrl": "https://datacollection-management-api.dev.insee.io",
"moogUrl": "https://suivi-gestion-collecte-enquetes.dev.insee.io",
"identityProvider": "insee-ssp"
Expand Down
6 changes: 3 additions & 3 deletions public/keycloak.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"realm": "my-realm",
"auth-server-url": "https://my-nice-server.test/auth",
"realm": "questionnaire-particuliers",
"auth-server-url": "https://auth.insee.test/auth",
"ssl-required": "none",
"resource": "my-client",
"resource": "coleman-pilotage",
"public-client": true,
"confidential-port": 0
}
Loading

0 comments on commit 18736d1

Please sign in to comment.