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

chore: Production test 8 #224

Merged
merged 23 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
da0a45d
Update install_sera.yml
DestroyCom Sep 3, 2023
1f32cf5
Revert "Update install_sera.yml"
DestroyCom Sep 3, 2023
4afb8c4
fix: frontend not have the correct env var after build
DestroyCom Sep 4, 2023
927ee9b
fix: develop deployment
DestroyCom Sep 4, 2023
2df8596
fix: fix sera front build action
DestroyCom Sep 4, 2023
011cc26
chore: update build actions
DestroyCom Sep 4, 2023
f9d3d6a
:sob:
DestroyCom Sep 4, 2023
9946366
Update prod.Dockerfile
DestroyCom Sep 4, 2023
471343a
fix : make the pagination stay on projects loading
lucag322 Sep 4, 2023
d1c80af
Update prod.Dockerfile
DestroyCom Sep 4, 2023
e06b759
feat(Step): Validate Post Production
ADR1811 Sep 4, 2023
57805ef
fix : make the pagination stay on projects loading
lucag322 Sep 4, 2023
bc8ba2e
Merge pull request #222 from GoofyComponent/SERA-142
ADR1811 Sep 4, 2023
5f91499
Merge branch 'develop' of https://github.com/GoofyComponent/GoofySeRA…
lucag322 Sep 4, 2023
8d265c0
fix: production laravel migration
DestroyCom Sep 4, 2023
a1371ec
feat: add a default user for production
ADR1811 Sep 4, 2023
03c0729
feat: add the line to run the seeder
ADR1811 Sep 4, 2023
b76e626
Merge pull request #223 from GoofyComponent/SERA-151
ADR1811 Sep 4, 2023
c22bea0
fix(seeder): fix seeder for prod
ADR1811 Sep 4, 2023
605b8ce
Merge branch 'develop' of https://github.com/GoofyComponent/GoofySeRA…
ADR1811 Sep 4, 2023
def3359
chore: test new production deploy
DestroyCom Sep 4, 2023
5ef7331
fix(seeder): fix seeder for prod
ADR1811 Sep 4, 2023
116a0c0
Merge branch 'develop' of https://github.com/GoofyComponent/GoofySeRA…
ADR1811 Sep 4, 2023
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
7 changes: 6 additions & 1 deletion .github/workflows/build_server_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Get Latest Tag
id: latest_tag
uses: WyriHaximus/github-action-get-previous-tag@v1
- name: Echo latest tag
run: echo '${{ steps.latest_tag.outputs.tag }}'
- name: Kaniko build
uses: aevea/action-kaniko@master
with:
image: destcom/sera-server
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
tag: ${{ github.event.inputs.tag || github.ref_name }}
tag: ${{ github.event.inputs.tag || steps.latest_tag.outputs.tag }}
tag_with_latest: true
path: ./sera-back
build_file: ./docker/prod.Dockerfile
9 changes: 7 additions & 2 deletions .github/workflows/build_web_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Get Latest Tag
id: latest_tag
uses: WyriHaximus/github-action-get-previous-tag@v1
- name: Echo latest tag
run: echo '${{ steps.latest_tag.outputs.tag }}'
- name: Kaniko build
uses: aevea/action-kaniko@master
with:
image: destcom/sera-web
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
tag: ${{ github.event.inputs.tag || github.ref_name }}
tag: ${{ github.event.inputs.tag || steps.latest_tag.outputs.tag }}
tag_with_latest: true
path: ./sera-front/
build_file: ./prod.Dockerfile
extra_args: --build-arg port=80 --build-arg ENV_VARIABLE=production_server_only_variable
extra_args: --build-arg port=80 --build-arg VITE_BACKEND_URL=https://sera-api.destcom.website --build-arg VITE_ENV_MODE=production
9 changes: 0 additions & 9 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Push new Tag
uses: butlerlogic/action-autotag@stable
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
strategy: regex
root: "./version.txt"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
min_version: "0.0.1"
- name: Get Latest Tag
id: latest_tag
uses: WyriHaximus/github-action-get-previous-tag@v1
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/create_tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Create new tag based on last commit message

on:
workflow_call:
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v2
env:
commitmsg: ${{ github.event.head_commit.message }}
with:
fetch-depth: 0
- name: Create or update major version
uses: joutvhu/create-tag@v1
with:
tag_name: $commitmsg
message: $commitmsg
on_tag_exists: update
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12 changes: 8 additions & 4 deletions .github/workflows/deploy_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,32 @@ on:
workflow_dispatch:

jobs:
create_tag:
uses: ./.github/workflows/create_tag.yml
secrets: inherit
build_server:
needs: create_tag
uses: ./.github/workflows/build_server_image.yml
secrets: inherit
build_webapp:
needs: build_server
needs: create_tag
uses: ./.github/workflows/build_web_image.yml
secrets: inherit
deploy_release:
needs: build_webapp
needs: [build_server, build_webapp]
uses: ./.github/workflows/create_release.yml
secrets: inherit
update_sera_app:
needs: deploy_release
uses: ./.github/workflows/install_sera.yml
secrets: inherit
notify:
needs: deploy_release
needs: update_sera_app
runs-on: ubuntu-latest
steps:
- name: Notify production build & published
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: "A new release just been created on SERA, images pushed to dockerhub."
args: "New production just build, see the new git release !"
9 changes: 6 additions & 3 deletions .github/workflows/install_sera.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ jobs:
- name: Pull new images
run: |
docker-compose -f ./prod.docker-compose.yml -p "prod-sera" pull

- name: Update the prod
run: |
docker-compose -f ./prod.docker-compose.yml -p "prod-sera" up -d

- name: Remove unused images
run: |
docker image prune -f

- name: Wait till the stack is created
run: |
sleep 2
Expand All @@ -48,7 +48,6 @@ jobs:
- name: Execute laravel configs
run: |
docker exec sera-server php artisan cache:clear
docker exec sera-server php artisan config:clear
docker exec sera-server php artisan route:clear
docker exec sera-server php artisan key:generate
docker exec sera-server php artisan config:cache
Expand All @@ -57,3 +56,7 @@ jobs:
docker exec sera-server php artisan optimize
docker exec sera-server php artisan storage:link
docker exec sera-server chown -R www-data:www-data /root
docker exec sera-server php artisan migrate --force
docker exec sera-server php artisan config:cache
docker exec sera-server php artisan config:clear
docker exec sera-server php artisan db:seed --class=UserProdSeeder --force
File renamed without changes.
3 changes: 2 additions & 1 deletion develop.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ services:
target: runner
args:
- port=${PORT_FRONT:-80}
- ENV_VARIABLE=${ENV_VARIABLE:-production_server_only_variable}
- VITE_BACKEND_URL=${ENV_VARIABLE:-https://develop-sera-back.destcom.website}
- VITE_ENV_MODE=${VITE_ENV_MODE:-dev}
networks:
- monolith
- hosted
Expand Down
98 changes: 97 additions & 1 deletion sera-back/app/Http/Controllers/StepController.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,4 +433,100 @@ public function captationToPostProd(Request $request, $project_id){
return $project->steps;
}

}

/**
* @OA\Post(
* path="/api/projects/{project_id}/validate/postproduction",
* tags={"Step"},
* summary="Validate postproduction",
* description="Validate postproduction",
* operationId="ValidatePostProd",
* @OA\Parameter(
* description="Project id",
* in="path",
* name="project_id",
* required=true,
* @OA\Schema(
* type="integer",
* format="int64"
* )
* ),
* @OA\RequestBody(
* required=true,
* description="Validate postproduction",
* @OA\JsonContent(
* required={"version"},
* @OA\Property(property="version", type="integer", example="1"),
* ),
* ),
* @OA\Response(
* response=200,
* description="Video review",
* @OA\JsonContent(
* @OA\Property(property="id", type="integer", example="1"),
* @OA\Property(property="version", type="integer", example="1"),
* @OA\Property(property="link", type="string", example="https://www.youtube.com/watch?v=1"),
* @OA\Property(property="validated", type="boolean", example="false"),
* @OA\Property(property="project_id", type="integer", example="1"),
* @OA\Property(property="created_at", type="string", example="2021-05-05T14:48:00.000000Z"),
* @OA\Property(property="updated_at", type="string", example="2021-05-05T14:48:00.000000Z"),
* ),
* ),
* @OA\Response(
* response=400,
* description="Bad request",
* @OA\JsonContent(
* @OA\Property(property="error", type="string", example="Post-Production is not ongoing."),
* ),
* ),
* )
*/
public function validatePostProd(Request $request, $project_id){

$request->validate([
'version' => 'required|integer',
]);


$project = Project::find($project_id);

if ($project === null) {
return response()->json(['error' => 'Project not found.'], 404);
}

$steps = json_decode($project->steps);

// si dans steps -> Post-Production -> status not ongoing return 400
if(!isset($steps->{'Post-Production'}) || $steps->{'Post-Production'}->status !== 'ongoing'){
return response()->json(['error' => 'Post-Production is not ongoing.'], 400);
}

$review = $project->videoReviews;

if($review === null){
return response()->json(['error' => 'Project has no video review.'], 400);
}

// on cherche la review avec la version
$review = $review->where('version', $request->version)->first();

if($review === null){
return response()->json(['error' => 'Project has no video review with this version.'], 400);
}

$review->validated = true;
$review->save();

// on mets Post-Production en done
$steps->{'Post-Production'}->status = 'done';
$steps->{'Transcription'}->status = 'ongoing';
$steps->{'Subtitling'}->status = 'ongoing';

$project->steps = json_encode($steps);
$project->save();


return response()->json($review, 200);

}
}
4 changes: 2 additions & 2 deletions sera-back/config/roles.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"cursus_director" => [
"projects-requests" => ["show", "index", "store", "update", "destroy"],
"users" => ["show", "index", "store", "update", "destroy", "roles", "image", "password","reservations","reservations"],
"projects" => ["show", "index", "store", "update", "destroy", "init","stepsGet","stepsUpdateDate","planificationToCaptation","addLink","captationToPostproduction"],
"projects" => ["show", "index", "store", "update", "destroy", "init","stepsGet","stepsUpdateDate","planificationToCaptation","addLink","captationToPostproduction","validatePostProd"],
"teams" => ["add", "index", "show", "remove"],
"rooms" => ["show", "index", "store", "update", "destroy", "reserve","unreserve","available","showByProject"],
"video-reviews" => ["getReviewsByProjectId","store","destroy","addAComment"],
Expand All @@ -15,7 +15,7 @@
"project_manager" => [
"projects-requests" => ["show", "index", "update"],
"users" => ["show", "index", "store", "update", "destroy", "roles", "image", "password","reservations"],
"projects" => ["show", "index", "store", "update", "destroy", "init","stepsGet","stepsUpdateDate","planificationToCaptation","addLink","captationToPostproduction"],
"projects" => ["show", "index", "store", "update", "destroy", "init","stepsGet","stepsUpdateDate","planificationToCaptation","addLink","captationToPostproduction","validatePostProd"],
"teams" => ["add", "index", "show", "remove"],
"rooms" => ["show", "index", "reserve","unreserve","available","showByProject"],
"video-reviews" => ["getReviewsByProjectId","store","destroy","addAComment"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function up(): void
$table->string('provider')->nullable(false);
$table->string('type')->nullable(false);
$table->string('resolution')->nullable(false);
$table->boolean('validated')->nullable(false)->default(false);
$table->timestamps();
});
}
Expand Down
1 change: 1 addition & 0 deletions sera-back/database/seeders/ProjectSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@ public function run(): void
$project->steps->{'Post-Production'}->status = 'ongoing';
$project->steps = json_encode($project->steps);
$project->save();

}
}
41 changes: 41 additions & 0 deletions sera-back/database/seeders/UserProdSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Database\Seeders;

use Illuminate\Support\Str;
use Illuminate\Database\Seeder;
use App\Services\CreateMinioUser;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;

class UserProdSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$s3_credentials = (new CreateMinioUser())->create();
$s3_credentials['secretkey'] = Crypt::encrypt($s3_credentials['secretkey']);
$s3_credentials['accesskey'] = Crypt::encrypt($s3_credentials['accesskey']);

// on search si l'utilisateur existe déjà
if (\App\Models\User::where('email', '[email protected]')->exists()) {
return;
}

// adapted for production and use only model and not factory
$user = \App\Models\User::firstOrCreate([
'email' => '[email protected]',
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
'firstname' => 'Admin',
'lastname' => 'Istrator',
'role' => 'cursus_director',
'avatar_filename' => 'lulu',
's3_credentials' => json_encode($s3_credentials),
]);

}
}
3 changes: 3 additions & 0 deletions sera-back/routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
Route::post('projects/{project_id}/planification-to-captation', 'App\Http\Controllers\StepController@planificationToCaptation')->name('projects.planificationToCaptation');
Route::post('projects/{project_id}/add-link', 'App\Http\Controllers\ProjectController@addLinkToCaptation')->name('projects.addLink');
Route::post('projects/{project_id}/captation-to-postproduction', 'App\Http\Controllers\StepController@captationToPostProd')->name('projects.captationToPostproduction');
Route::post('projects/{project_id}/validate/postproduction', 'App\Http\Controllers\StepController@validatePostProd')->name('projects.validatePostProd');

/****TEAM ****/

Expand Down Expand Up @@ -83,6 +84,8 @@

/************************/



Route::resource('rooms', 'App\Http\Controllers\RoomController');

/*********************************/
Expand Down
Loading
Loading