From a228495d816e1979c74d7648971ffcc4f8b494f9 Mon Sep 17 00:00:00 2001 From: Giovanne Oliveira Date: Fri, 27 May 2022 14:18:17 +0000 Subject: [PATCH 1/4] fix instructions env variables --- app/Commands/CreateInterviewCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Commands/CreateInterviewCommand.php b/app/Commands/CreateInterviewCommand.php index 1a1027a..61c7a75 100644 --- a/app/Commands/CreateInterviewCommand.php +++ b/app/Commands/CreateInterviewCommand.php @@ -269,8 +269,8 @@ private function populateCandidateFolder() $this->databaseInfo['password'], $this->databaseInfo['database'], $this->databaseInfo['port'], - env('PUBLIC_URL'), - env('PHPMYADMIN_URL').$this->candidateName, + env('PUBLIC_URL').$this->candidateName, + env('PHPMYADMIN_URL'), ]; $writeFileResponse = File::put( From 9c2c5709983c2dcbdcf804d20cc011cec657bbb9 Mon Sep 17 00:00:00 2001 From: Giovanne Oliveira Date: Fri, 27 May 2022 14:39:36 +0000 Subject: [PATCH 2/4] changes on process of obtainig process pid list --- app/Commands/CloseInterviewCommand.php | 32 ++++++++++++++++++-------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/app/Commands/CloseInterviewCommand.php b/app/Commands/CloseInterviewCommand.php index 368d25d..0eaa03c 100644 --- a/app/Commands/CloseInterviewCommand.php +++ b/app/Commands/CloseInterviewCommand.php @@ -268,7 +268,15 @@ private function closeCodeServerSession() // Set the interview ID $this->interviewId = $meta[0]->id; - $process = BackgroundProcess::createFromPID($meta[0]->pid); + // Get list of all PIDs from /usr/lib/code-server process + + $cmdOutput = explode("\n", shell_exec("ps aux | grep /usr/lib/code-server | awk '{print $2}'")); + if (!is_array($cmdOutput)) { + // TODO: soft-execution adaptations here + $this->error('Error while fetching PIDs from Code-server process'); + return false; + } + /* // TODO: This was disabled until I found a way to return if the process was already killed // or insert a command flag to allow the "soft-execution" of this script @@ -278,13 +286,19 @@ private function closeCodeServerSession() $this->error('The session is already closed or process not found.'); return false; }*/ - - if ($process->stop()) { - DB::table('code_server_instances')->where('candidate_name', $candidateName)->update(['status' => 0]); - return true; - }else{ - $this->error('Error while closing code-server session.'); - return false; + foreach ($cmdOutput as $pid) { + if ($pid == '') { + continue; + } + $pid = trim($pid); + $process = BackgroundProcess::createFromPID($pid); + if ($process->stop()) { + DB::table('code_server_instances')->where('candidate_name', $candidateName)->update(['status' => 0]); + return true; + } else { + $this->error('Error while closing code-server session.'); + return false; + } } } @@ -313,7 +327,7 @@ private function postActionHooks() // Here we can insert some code to run after the candidate has been removed // Update the candidate's status and recommendations - + // Write the end time for the interview // TODO: Write a better query for this From 3bdf352e76ea21f37920f6907947090d6b9c85a4 Mon Sep 17 00:00:00 2001 From: Giovanne Oliveira Date: Fri, 27 May 2022 14:59:46 +0000 Subject: [PATCH 3/4] added more questions on closing interview --- app/Commands/CloseInterviewCommand.php | 18 ++++++++++- .../2022_05_27_144023_add_candidate_grade.php | 32 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2022_05_27_144023_add_candidate_grade.php diff --git a/app/Commands/CloseInterviewCommand.php b/app/Commands/CloseInterviewCommand.php index 0eaa03c..08d38e9 100644 --- a/app/Commands/CloseInterviewCommand.php +++ b/app/Commands/CloseInterviewCommand.php @@ -36,6 +36,10 @@ class CloseInterviewCommand extends Command private $backupCandidateFiles = true; + private $hireRecommendation; + + private $indicatedPosition; + private $error; private $mysqldumpPath = '/usr/bin/mysqldump'; @@ -96,7 +100,11 @@ public function handle() $this->completionSteps = $this->question('How many steps the candidate completed before the end of the test?', 0); - $this->indicatedPosition = $this->choice('Which position did the candidate indicate?', ['junior', 'plain', 'senior']); + $this->hireRecommendation = $this->choice('What\'s your recommendation for this candidate?', ['strong no hire', 'not recommended', 'recommended', 'strong hire']); + + if($this->hireRecommendation > 1){ + $this->indicatedPosition = $this->choice('What\'s the indicated position for this candidate?', ['junior', 'mid', 'senior', 'lead', 'other']); + } $this->info('Closing interview environment for ' . $this->candidateName); @@ -328,6 +336,14 @@ private function postActionHooks() // Update the candidate's status and recommendations + // TODO: Calculate the general score based on how many steps the candidate completed and how much time it took. + // For now, we'll just set it to 0. + $score = 0; + DB::update( + 'UPDATE code_server_instances SET hire_recommendation_level = ?, position_level_recommendation = ?, general_score = ? WHERE id = ?', + [$this->hireRecommendation, $this->indicatedPosition, $score, $this->interviewId] + ); + // Write the end time for the interview // TODO: Write a better query for this diff --git a/database/migrations/2022_05_27_144023_add_candidate_grade.php b/database/migrations/2022_05_27_144023_add_candidate_grade.php new file mode 100644 index 0000000..dc57839 --- /dev/null +++ b/database/migrations/2022_05_27_144023_add_candidate_grade.php @@ -0,0 +1,32 @@ +string('hire_recommendation_level')->nullable(); // Strong no hire, no hire, hire, strong hire + $table->string('position_level_recommendation')->nullable(); // Junior, Plain, Senior, Tech Lead + $table->string('general_score')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} From 19c104a98a052fb4939f7d567d3e81df35283b04 Mon Sep 17 00:00:00 2001 From: Giovanne Oliveira Date: Fri, 27 May 2022 17:20:33 +0000 Subject: [PATCH 4/4] changes on build workflow --- .github/workflows/build_release.yml | 10 ++++++---- .github/workflows/laravel-zero-build.yml | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml index 2e54ef1..f66cd7b 100644 --- a/.github/workflows/build_release.yml +++ b/.github/workflows/build_release.yml @@ -4,6 +4,8 @@ on: push: branches: [ master ] +permissions: write-all + jobs: build: runs-on: ubuntu-latest @@ -17,7 +19,7 @@ jobs: id: semver_tagbump uses: anothrNick/github-tag-action@1.36.0 env: - GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN}} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}} WITH_V: false DEFAULT_BUMP: patch @@ -31,7 +33,7 @@ jobs: id: changelog uses: loopwerk/tag-changelog@v1 with: - token: ${{ secrets.ACCESS_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} - name: Create release uses: actions/create-release@v1 @@ -43,12 +45,12 @@ jobs: tag_name: ${{ steps.semver_tagbump.outputs.new_tag}} body: ${{ steps.changelog.outputs.changes }} env: - GITHUB_TOKEN: ${{github.token}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - name: Upload artifacts uses: actions/upload-release-asset@v1 env: - GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN}} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}} with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: builds/ivcli diff --git a/.github/workflows/laravel-zero-build.yml b/.github/workflows/laravel-zero-build.yml index f063651..2f14fa0 100644 --- a/.github/workflows/laravel-zero-build.yml +++ b/.github/workflows/laravel-zero-build.yml @@ -4,6 +4,8 @@ on: push: branches: [ beta ] +permissions: write-all + jobs: build: runs-on: ubuntu-latest @@ -17,7 +19,7 @@ jobs: id: semver_tagbump uses: anothrNick/github-tag-action@1.36.0 env: - GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN}} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}} WITH_V: false DEFAULT_BUMP: patch @@ -31,7 +33,7 @@ jobs: id: changelog uses: loopwerk/tag-changelog@v1 with: - token: ${{ secrets.ACCESS_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} - name: Create release uses: actions/create-release@v1 @@ -43,12 +45,12 @@ jobs: tag_name: ${{ steps.semver_tagbump.outputs.new_tag}} body: ${{ steps.changelog.outputs.changes }} env: - GITHUB_TOKEN: ${{github.token}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - name: Upload artifacts uses: actions/upload-release-asset@v1 env: - GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN}} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}} with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: builds/ivcli