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

test review app #950

Merged
merged 1 commit into from
Nov 30, 2023
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
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ vite.config.ts
cypress
front/src/assets/
public/assets/
public/dsfr/
public/dsfr/
back/transpile-back-and-prepare-for-prod.js
4 changes: 0 additions & 4 deletions .github/workflows/fullcheck.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: "Fullcheck of the project + integration tests"

on:
push:
branches-ignore:
- main

workflow_call:

jobs:
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/review-app-creation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: "Review app"

on:
pull_request:

jobs:
validation:
uses: ./.github/workflows/fullcheck.yml

deploy-review-app:
if: ${{ github.event.pull_request.draft == false }}
uses: ./.github/workflows/review-app-deploy.yml
needs: validation
with:
pull_request_id: ${{ github.event.number }}
run_number: ${{ github.run_number }}
secrets:
SCALINGO_API_TOKEN: ${{ secrets.SCALINGO_API_TOKEN }}

run-seeds:
needs: deploy-review-app
runs-on: ubuntu-latest
environment: review-app
steps:
- name: Install scalingo CLI
run: |
wget -qO- https://cli-dl.scalingo.com/install.sh | bash
echo "$HOME/bin" >> $GITHUB_PATH
- name: Login to scalingo
run: scalingo login --api-token ${{ secrets.SCALINGO_API_TOKEN }}
- name: Run DB seed
run: scalingo --app if-dev-back-pr${{ github.event.number }} run pnpm db:seed

notify-pr:
runs-on: ubuntu-latest
steps:
- name: Notify PR about the webapp url
if: ${{ github.run_number == '1' }}
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Review app:
https://if-dev-front-pr${{ github.event.number }}.osc-fr1.scalingo.io
23 changes: 23 additions & 0 deletions .github/workflows/review-app-deletion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Destroy review-app"

on:
pull_request:
types: [closed]

jobs:
delete-app:
environment: review-app
runs-on: ubuntu-latest
steps:
- name: Install scalingo CLI
run: |
wget -qO- https://cli-dl.scalingo.com/install.sh | bash
echo "$HOME/bin" >> $GITHUB_PATH
- name: Login to scalingo
run: scalingo login --api-token ${{ secrets.SCALINGO_API_TOKEN }}
- name: Destroy review app
run: |
scalingo --app if-dev-back-pr${{ github.event.number }} integration-link-delete
scalingo --app if-dev-front-pr${{ github.event.number }} integration-link-delete
scalingo --app if-dev-back-pr${{ github.event.number }} destroy --force
scalingo --app if-dev-front-pr${{ github.event.number }} destroy --force
70 changes: 70 additions & 0 deletions .github/workflows/review-app-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: "Generic workflow to deploy to scalingo, given arguments"

on:
workflow_call:
inputs:
pull_request_id:
type: number
required: true
run_number:
type: string
required: true
secrets:
SCALINGO_API_TOKEN:
required: true

jobs:
deploy:
name: "Deploy to review app pr${{ inputs.pull_request_id }}"
runs-on: ubuntu-latest
environment: review-app
concurrency:
group: deploy-to-scalingo-pr${{ inputs.pull_request_id }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 8
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
cache: "pnpm"
- name: Install scalingo CLI
run: |
wget -qO- https://cli-dl.scalingo.com/install.sh | bash
echo "$HOME/bin" >> $GITHUB_PATH
- name: Install dependencies
run: pnpm install
- name: Build front
run: NODE_OPTIONS=--max-old-space-size=4096 pnpm front build-scalingo
- name: Build back
run: pnpm back build
- name: Login to scalingo
run: scalingo login --api-token ${{ secrets.SCALINGO_API_TOKEN }}
- name: Create back review app
run: |
if scalingo --app if-dev-back review-apps | grep -q "pr${{ inputs.pull_request_id }}"; then
echo "Review app for PR_ID ${{ inputs.pull_request_id }} already exists. Skipping creation."
else
echo "Review app for PR_ID ${{ inputs.pull_request_id }} does not exist. Creating now."
scalingo --app if-dev-back integration-link-manual-review-app ${{ inputs.pull_request_id }}
fi
- name: Create front review app
run: |
if scalingo --app if-dev-front review-apps | grep -q "pr${{ inputs.pull_request_id }}"; then
echo "Review app for PR_ID ${{ inputs.pull_request_id }} already exists. Skipping creation."
else
echo "Review app for PR_ID ${{ inputs.pull_request_id }} does not exist. Creating now."
scalingo --app if-dev-front integration-link-manual-review-app ${{ inputs.pull_request_id }}
fi
- name: Remove sslmode from $SCALINGO_POSTGRESQL_URL
run: |
current_db_url=$(scalingo --app if-dev-back-pr${{ inputs.pull_request_id }} env | grep SCALINGO_POSTGRESQL_URL= | cut -d '=' -f2-)
new_db_url=$(echo $current_db_url | sed "s/?sslmode=prefer//")
scalingo --app if-dev-back-pr${{ inputs.pull_request_id }} env-set SCALINGO_POSTGRESQL_URL="$new_db_url"
- name: Deploy back
run: scalingo --app if-dev-back-pr${{ inputs.pull_request_id }} deploy back/back-build.tar.gz ${{ inputs.pull_request_id }}-${{ inputs.run_number }}
- name: Deploy front
run: scalingo --app if-dev-front-pr${{ inputs.pull_request_id }} deploy front/front-build.tar.gz ${{ inputs.pull_request_id }}-${{ inputs.run_number }}
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ public/dsfr/
.git/
.idea/
.angular/
back/transpile-back-and-prepare-for-prod.js
1 change: 1 addition & 0 deletions back/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
transpile-back-and-prepare-for-prod.js
2 changes: 1 addition & 1 deletion back/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"db:down": "pnpm db:migrate down",
"db:migrate": "ts-node --compilerOptions '{\"resolveJsonModule\": true}' node_modules/node-pg-migrate/bin/node-pg-migrate -j ts -m src/adapters/secondary/pg/migrations",
"db:redo": "pnpm db:migrate redo",
"db:seed": "NODE_ENV=local ts-node src/adapters/primary/scripts/seed.ts",
"db:seed": "ts-node src/adapters/primary/scripts/seed.ts",
"db:up": "pnpm db:migrate up",
"deadcode": "ts-prune --ignore 'src/adapters/secondary/pg/migrations'",
"dev": "NODE_ENV=local ts-node-dev src/adapters/primary/scripts/startServer.ts",
Expand Down
5 changes: 4 additions & 1 deletion back/src/adapters/primary/config/appConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,10 @@ export class AppConfig {
}

public get pgImmersionDbUrl() {
return this.#throwIfNotDefinedOrDefault("DATABASE_URL");
return this.#throwIfNotDefinedOrDefault("DATABASE_URL").replace(
"?sslmode=prefer",
"",
);
}

public get poleEmploiAccessTokenConfig(): AccessTokenConfig {
Expand Down
2 changes: 1 addition & 1 deletion back/transpile-back-and-prepare-for-prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ console.log("Copying package.json of back for prod");
fs.copyFileSync("./package.json", "build/back/package.json");

execSync(
"cp -v -R ./src/adapters/secondary/pg/staticData build/back/src/adapters/secondary/pg/staticData"
"cp -v -R ./src/adapters/secondary/pg/staticData build/back/src/adapters/secondary/pg"
);

// Copy dependencies package.json files to build directory
Expand Down
Loading